# Refresh JWT Token

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

## Credentials

- Header `PayMe-Partner-Key` (required): The unique Partner identifier.
- Header `PayMe-Merchant-Key` (required): The unique Seller identifier.
- Request body field `refresh_token` (required): The refresh token.

Refreshes an existing JWT token using the refresh token.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `PayMe-Partner-Key` | header | string | yes | The unique Partner identifier. |
| `PayMe-Merchant-Key` | header | string | yes | The unique Seller identifier. |

## Request body

Content type: `application/json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `refresh_token` | string | yes | The refresh token. |

### Request example

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

```json
{
  "refresh_token": "<refresh_token>"
}
```

## Code samples

### curl

```bash
curl -X POST 'https://sandbox.payme.io/api/auth/refresh' \
  -H 'Content-Type: application/json' \
  -H 'PayMe-Partner-Key: <PayMe-Partner-Key>' \
  -H 'PayMe-Merchant-Key: <PayMe-Merchant-Key>' \
  --data-raw '{
  "refresh_token": "<refresh_token>"
}'
```

### Node.js

```javascript
const response = await fetch("https://sandbox.payme.io/api/auth/refresh", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "PayMe-Partner-Key": "<PayMe-Partner-Key>",
    "PayMe-Merchant-Key": "<PayMe-Merchant-Key>",
  },
  body: JSON.stringify({
    "refresh_token": "<refresh_token>"
  }),
});

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

### Python

```python
import requests

response = requests.post(
    "https://sandbox.payme.io/api/auth/refresh",
    headers={
        "PayMe-Partner-Key": "<PayMe-Partner-Key>",
        "PayMe-Merchant-Key": "<PayMe-Merchant-Key>",
    },
    json={
        "refresh_token": "<refresh_token>",
    },
)

print(response.text)
```

### PHP

```php
<?php

$body = <<<'BODY'
{
  "refresh_token": "<refresh_token>"
}
BODY;

$ch = curl_init('https://sandbox.payme.io/api/auth/refresh');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
        'PayMe-Partner-Key: <PayMe-Partner-Key>',
        'PayMe-Merchant-Key: <PayMe-Merchant-Key>',
    ],
    CURLOPT_POSTFIELDS => $body,
]);

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

echo $response;
```

## Responses

### 200 — Token refreshed successfully. (success)

| Field | Type | Description |
| --- | --- | --- |
| `access_token` | string | The new JWT token. |
| `expires_in` | integer | The expiration time of the token in seconds. |

### 400 — Bad Request (error)

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

### 401 — Unauthorized (error)

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

### 500 — Internal Server Error (error)

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