# Get Customers

- Sandbox: `GET https://sandbox.payme.io/api/customers`
- Production: `GET https://live.payme.io/api/customers`

## Credentials

- Header `Authorization: Bearer <token>`

The GET /customers endpoint provides access to customer data, enabling clients to filter and sort through available customers.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `status` | query | boolean | no | The customer status - indicates if the customer is available or not. 0 - Deacativated, 1 - Active, 2 - Draft |
| `created_at` | query | string | no | Common date range. Use [min] / [max] on query parameters. |
| `due_date` | query | string | no | Common date range. Use [min] / [max] on query parameters. |
| `items_per_page` | query | integer | no | The number of items per page. |
| `page` | query | integer | no | The page number. |
| `first_name` | query | string | no | The customer's first name. |
| `last_name` | query | string | no | The customer's last name. |
| `email` | query | string | no | The customer's email. |
| `phone_number` | query | string | no | The customer's phone number. |
| `description` | query | string | no | The customer description. |
| `sort_by` | query | string | no | The column name for ordering results. |
| `sort_direction` | query | string | no | The direction for ordering results. |

## Code samples

### curl

```bash
curl -X GET 'https://sandbox.payme.io/api/customers' \
  -H 'Authorization: Bearer <YOUR_TOKEN>'
```

### Node.js

```javascript
const response = await fetch("https://sandbox.payme.io/api/customers", {
  method: "GET",
  headers: {
    "Authorization": "Bearer <YOUR_TOKEN>",
  },
});

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

### Python

```python
import requests

response = requests.get(
    "https://sandbox.payme.io/api/customers",
    headers={
        "Authorization": "Bearer <YOUR_TOKEN>",
    },
)

print(response.text)
```

### PHP

```php
<?php

$ch = curl_init('https://sandbox.payme.io/api/customers');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer <YOUR_TOKEN>',
    ],
]);

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

echo $response;
```

## Responses

### 200 — User Found (success)

| Field | Type | Description |
| --- | --- | --- |
| `items_count` | integer |  |
| `items` | array |  |
| `items[].guid` | string |  |
| `items[].first_name` | string |  |
| `items[].last_name` | string |  |
| `items[].email` | string |  |
| `items[].phone_number` | string |  |
| `items[].additional_phone_number` | string |  |
| `items[].country` | string |  |
| `items[].city` | string |  |
| `items[].street` | string |  |
| `items[].building_number` | string |  |
| `items[].floor` | string |  |
| `items[].zip` | string |  |
| `items[].middle_name` | string |  |
| `items[].company_name` | string |  |
| `items[].gender` | string |  |
| `items[].description` | string |  |
| `items[].birthday` | string |  |
| `items[].created_at` | string |  |
| `items[].updated_at` | string |  |
| `items[].status` | integer | The status of the product. Options: 1 = `Available`, 0 = `Not Available` |
| `items[].payment_tokens` | object |  |
| `items[].payment_tokens.payment_method` | string | The payment method of the token. Allowed values: 1. `Credit Card` 2. `IL Direct Debit` |
| `items[].payment_tokens.token_guid` | string | The unique identifier of the token in PayMe. |

```json
{
  "items_count": 1,
  "items": [
    {
      "guid": "string",
      "first_name": "string",
      "last_name": "string",
      "email": "string",
      "phone_number": "string",
      "additional_phone_number": "string",
      "country": "string",
      "city": "string",
      "street": "string",
      "building_number": "string",
      "floor": "string",
      "zip": "string",
      "middle_name": "string",
      "company_name": "string",
      "gender": "string",
      "description": "string",
      "birthday": "2019-08-24",
      "created_date": "2019-08-24",
      "update_date": "2019-08-24",
      "status": 0,
      "payment_tokens": {
        "payment_method": "string",
        "token_guid": "string"
      }
    }
  ]
}
```

### 400 — Bad Request (error)

| Field | Type | Description |
| --- | --- | --- |
| `message` | string |  |
| `status_error_code` | integer |  |

### 401 — Unauthorized (error)

| Field | Type | Description |
| --- | --- | --- |
| `message` | string |  |
| `status_error_code` | integer |  |

### 500 — Internal Server Error (error)

| Field | Type | Description |
| --- | --- | --- |
| `message` | string |  |
| `status_error_code` | integer |  |
