# Create New Customer

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

## Credentials

- Header `Authorization: Bearer <token>`

This endpoint allows clients to add new customers to the system by sending the necessary information in the request.

## Parameters

This endpoint takes no path, query or header parameters.

## Request body

Content type: `application/json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `customer_remote_id` | string | no | The customer's first name. |
| `first_name` | string | yes | The customer's first name. |
| `last_name` | string | yes | The customer's last name. |
| `email` | string | yes | The customer's email. |
| `phone_number` | string | yes | The customer's mobile number. |
| `country` | string | no | The customer's country. |
| `city` | string | no | The customer's city. |
| `street` | string | no | The customer's street. |
| `building_number` | string | no | The customer's building number. |
| `floor` | string | no | The customer's floor. |
| `zip` | string | no | The customer's ZIP code. |
| `middle_name` | string | no | The customer's middle name. |
| `company_name` | string | no | The customer's company name. |
| `gender` | string | no | The customer's gender. Allowed values: 1. `Male` 2. `Female` 3. `Other` |
| `description` | string | no | The customer description. |
| `birthday` | string | no | The customer's birthday. MM-DD-YYYY Format |
| `additional_phone` | string | no | Additional phone number of the customer. |
| `payment_tokens` | object | no |  |
| `payment_tokens.payment_method` | string | no | The payment method of the token. Allowed values: 1. `Credit Card` 2. `IL Direct Debit` |
| `payment_tokens.token_guid` | string | no | The unique identifier of the token in PayMe. |

### Request example

No example is documented; this template is generated from the fields — replace the placeholder values.

```json
{
  "customer_remote_id": "<customer_remote_id>",
  "first_name": "<first_name>",
  "last_name": "<last_name>",
  "email": "<email>",
  "phone_number": "<phone_number>",
  "country": "<country>",
  "city": "<city>",
  "street": "<street>",
  "building_number": "<building_number>",
  "floor": "<floor>",
  "zip": "<zip>",
  "middle_name": "<middle_name>",
  "company_name": "<company_name>",
  "gender": "<gender>",
  "description": "<description>",
  "birthday": "<birthday>",
  "additional_phone": "<additional_phone>",
  "payment_tokens": {}
}
```

## Code samples

### curl

```bash
curl -X POST 'https://sandbox.payme.io/api/customers' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <YOUR_TOKEN>' \
  --data-raw '{
  "first_name": "<first_name>",
  "last_name": "<last_name>",
  "email": "<email>",
  "phone_number": "<phone_number>"
}'
```

### Node.js

```javascript
const response = await fetch("https://sandbox.payme.io/api/customers", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <YOUR_TOKEN>",
  },
  body: JSON.stringify({
    "first_name": "<first_name>",
    "last_name": "<last_name>",
    "email": "<email>",
    "phone_number": "<phone_number>"
  }),
});

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

### Python

```python
import requests

response = requests.post(
    "https://sandbox.payme.io/api/customers",
    headers={
        "Authorization": "Bearer <YOUR_TOKEN>",
    },
    json={
        "first_name": "<first_name>",
        "last_name": "<last_name>",
        "email": "<email>",
        "phone_number": "<phone_number>",
    },
)

print(response.text)
```

### PHP

```php
<?php

$body = <<<'BODY'
{
  "first_name": "<first_name>",
  "last_name": "<last_name>",
  "email": "<email>",
  "phone_number": "<phone_number>"
}
BODY;

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

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

echo $response;
```

## Responses

### 200 — Customer created successfully. (success)

| Field | Type | Description |
| --- | --- | --- |
| `guid` | integer | The unique PayMe customer identifier. |
| `created_at` | string | The timestamp of the creation. |

### 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 |  |
