# Cancel income document

- Sandbox: `POST https://sandbox.payme.io/api/seller/api/documents/income/{id}/cancel`
- Production: `POST https://live.payme.io/api/seller/api/documents/income/{id}/cancel`

## Credentials

- Header `Authorization: Bearer <token>`

Cancel an existing income document. This will create a cancellation record.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | Document ID to cancel |

## Request body

Content type: `application/json`

## Code samples

### curl

```bash
curl -X POST 'https://sandbox.payme.io/api/seller/api/documents/income/<id>/cancel' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <YOUR_TOKEN>' \
  --data-raw '{}'
```

### Node.js

```javascript
const response = await fetch("https://sandbox.payme.io/api/seller/api/documents/income/<id>/cancel", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <YOUR_TOKEN>",
  },
  body: JSON.stringify({}),
});

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

### Python

```python
import requests

response = requests.post(
    "https://sandbox.payme.io/api/seller/api/documents/income/<id>/cancel",
    headers={
        "Authorization": "Bearer <YOUR_TOKEN>",
    },
    json={},
)

print(response.text)
```

### PHP

```php
<?php

$body = <<<'BODY'
{}
BODY;

$ch = curl_init('https://sandbox.payme.io/api/seller/api/documents/income/<id>/cancel');
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 — Document cancelled successfully (success)

### 400 — Bad Request (error)

| Field | Type | Description |
| --- | --- | --- |
| `statusCode` | integer | HTTP status code |
| `message` | string | Error message(s) |
| `error` | string | Error type |

```json
{
  "statusCode": 400,
  "message": [
    "Validation failed"
  ],
  "error": "Bad Request"
}
```

### 401 — Unauthorized (error)

| Field | Type | Description |
| --- | --- | --- |
| `statusCode` | integer | HTTP status code |
| `message` | string | Error message(s) |
| `error` | string | Error type |

```json
{
  "statusCode": 401,
  "message": "Unauthorized",
  "error": "Unauthorized"
}
```

### 404 — Not Found (error)

| Field | Type | Description |
| --- | --- | --- |
| `statusCode` | integer | HTTP status code |
| `message` | string | Error message(s) |
| `error` | string | Error type |

```json
{
  "statusCode": 404,
  "message": "Document not found",
  "error": "Not Found"
}
```
