# List Past Withdrawals

- Sandbox: `POST https://sandbox.payme.io/api/get-withdrawals`
- Production: `POST https://live.payme.io/api/get-withdrawals`

## Credentials

- Request body field `payme_client_key` (required): PayMe Partner Key

## Overview

You can retreive data on withdrawals requested by your sellers using this endpoint. 


#### Query pagination (more than 500 results)

If you are sending a query and expect to receive more than 500 results, make sure you use this function of Query Pagination. 

```json
{
  "seller_payme_id": "MPL1DEMO-XXXXXXXX-XXXXXXXX-XXXXXXXX",
  ...
  "page_size": 100, // Max allowed page size is 500
  "page": 1
}
```

## Parameters

This endpoint takes no path, query or header parameters.

## Request body

Content type: `application/json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `payme_client_key` | string | yes | PayMe Partner Key |
| `seller_payme_id` | string | no | Our unique seller ID (MPL). If you are a partner, you can use multiple seller_payme_id attributes to retreive data for these specific sellers |
| `seller_id` | string | no | Merchant's unique seller ID for correlation with us |
| `withdrawal_created` | string | no | Exact creation date and time for which to retrieve withdrawals. ISO-8601 formatted |
| `withdrawal_created_min` | string | no | Earliest creation date and time for which to retrieve withdrawals. ISO-8601 formatted |
| `withdrawal_created_max` | string | no | Latest date and time for which to retrieve withdrawals. ISO-8601 formatted |
| `withdrawal_total` | string | no | Withdrawal total amount. For example, if the amount is 50.75 (max 2 decimal points) the value that recieved is 5075 |
| `withdrawal_currency` | string | no | Withdrawal currency. 3-letter ISO 4217 name |

### Request example

```json
{
  "payme_client_key": "XXXXXXXX",
  "withdrawal_payme_code": "1234"
}
```

## Code samples

### curl

```bash
curl -X POST 'https://sandbox.payme.io/api/get-withdrawals' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "payme_client_key": "XXXXXXXX",
  "withdrawal_payme_code": "1234"
}'
```

### Node.js

```javascript
const response = await fetch("https://sandbox.payme.io/api/get-withdrawals", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "payme_client_key": "XXXXXXXX",
    "withdrawal_payme_code": "1234"
  }),
});

console.log(await response.text());
```

### Python

```python
import requests

response = requests.post(
    "https://sandbox.payme.io/api/get-withdrawals",
    json={
        "payme_client_key": "XXXXXXXX",
        "withdrawal_payme_code": "1234",
    },
)

print(response.text)
```

### PHP

```php
<?php

$body = <<<'BODY'
{
  "payme_client_key": "XXXXXXXX",
  "withdrawal_payme_code": "1234"
}
BODY;

$ch = curl_init('https://sandbox.payme.io/api/get-withdrawals');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => $body,
]);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
```

## Responses

### 200 — OK (success)

| Field | Type | Description |
| --- | --- | --- |
| `items_count` | number |  |
| `items` | array |  |
| `items[].seller_payme_id` | string | Our unique seller ID |
| `items[].withdrawal_payme_code` | number | Unique withdrawl PayMe code |
| `items[].withdrawal_created` | string | Withdrwal creation date |
| `items[].withdrawal_currency` | string | Withdrawal currency. 3-letter ISO 4217 name |
| `items[].withdrawal_total` | number | Withdrawl total amount |
| `items[].withdrawal_description` | string | Withdrawl description |
| `status_code` | number |  |

```json
{
  "items_count": 1,
  "items": [
    {
      "seller_payme_id": "XXXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX",
      "withdrawal_payme_code": 10001,
      "withdrawal_created": "2016-01-01 15:15:15",
      "withdrawal_currency": "USD",
      "withdrawal_total": 600000,
      "withdrawal_description": "משיכה לבנק"
    }
  ],
  "status_code": 0
}
```

### 500 — Internal Server Error (error)

| Field | Type | Description |
| --- | --- | --- |
| `status_code` | number |  |
| `status_error_details` | string |  |
| `status_additional_info` | string |  |
| `status_error_code` | number |  |

```json
{
  "status_code": 1,
  "status_error_details": "Required parameter is missing",
  "status_additional_info": "payme_client_key",
  "status_error_code": 1
}
```
