# Cancel

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

## Credentials

- Request body field `seller_payme_id` (required): Our unique seller ID
- Request body field `sub_payme_id` (required): Our unique subscription ID

## Overview

This endpoint is used to cancel existing subscriptions.

## Parameters

This endpoint takes no path, query or header parameters.

## Request body

Content type: `application/json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `seller_payme_id` | string | yes | Our unique seller ID |
| `sub_payme_id` | string | yes | Our unique subscription ID |
| `language` | string | no | Changes the error message language to English. Default value is Hebrew (he) |

### Request example

```json
{
  "seller_payme_id": "string",
  "sub_payme_id": "string",
  "language": "string"
}
```

## Code samples

### curl

```bash
curl -X POST 'https://sandbox.payme.io/api/cancel-subscription' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "seller_payme_id": "string",
  "sub_payme_id": "string",
  "language": "string"
}'
```

### Node.js

```javascript
const response = await fetch("https://sandbox.payme.io/api/cancel-subscription", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "seller_payme_id": "string",
    "sub_payme_id": "string",
    "language": "string"
  }),
});

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

### Python

```python
import requests

response = requests.post(
    "https://sandbox.payme.io/api/cancel-subscription",
    json={
        "seller_payme_id": "string",
        "sub_payme_id": "string",
        "language": "string",
    },
)

print(response.text)
```

### PHP

```php
<?php

$body = <<<'BODY'
{
  "seller_payme_id": "string",
  "sub_payme_id": "string",
  "language": "string"
}
BODY;

$ch = curl_init('https://sandbox.payme.io/api/cancel-subscription');
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 |
| --- | --- | --- |
| `status_code` | string | Cancellation status code ( 0 - Success, 1 - Failure) |

```json
{
  "status_code": "string"
}
```

### 500 — Internal Server Error (error)

| Field | Type | Description |
| --- | --- | --- |
| `status_code` | string | Cancellation status code ( 0 - Success, 1 - Failure) |

```json
{
  "status_code": "string"
}
```
