> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pazy.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Mark As Paid Batch Status API

> Poll the progress of an asynchronous mark-as-paid batch

## Authentication

All requests require an API key in the request headers.

**Headers:**

```
Authorization: Api-Key YOUR_API_KEY
```

The permission required on your API key is **Payment** with the **Read** action enabled.

<Info>
  This endpoint is only relevant for batches submitted to the [Mark Invoice as Paid API](/apis/mark-as-paid) that exceeded 100 invoices and returned `status: "PENDING"` with a `bulkActionSlug`.
</Info>

## Request

**Content-Type:** `application/json`

### Path Parameters

| Parameter | Type   | Required | Description                                                                                         |
| --------- | ------ | -------- | --------------------------------------------------------------------------------------------------- |
| `slug`    | string | Yes      | The `bulkActionSlug` returned by an asynchronous [Mark Invoice as Paid](/apis/mark-as-paid) request |

## Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET https://api.pazy.io/v1.0/payment/mark-as-paid/batch/bulk_action_identifier \
    -H "Authorization: Api-Key YOUR_API_KEY"
  ```

  ```javascript JavaScript (Fetch API) theme={null}
  const response = await fetch('https://api.pazy.io/v1.0/payment/mark-as-paid/batch/bulk_action_identifier', {
    method: 'GET',
    headers: {
      'Authorization': 'Api-Key YOUR_API_KEY'
    }
  });

  const result = await response.json();
  ```

  ```python Python (requests) theme={null}
  import requests

  url = "https://api.pazy.io/v1.0/payment/mark-as-paid/batch/bulk_action_identifier"
  headers = {
      "Authorization": "Api-Key YOUR_API_KEY"
  }

  response = requests.get(url, headers=headers)
  result = response.json()
  ```
</CodeGroup>

## Success Response

**HTTP Status:** `200 OK`

| Field                 | Type    | Description                                                               |
| --------------------- | ------- | ------------------------------------------------------------------------- |
| `ok`                  | boolean | Indicates whether the request was successful                              |
| `data.slug`           | string  | The batch identifier (same as the `bulkActionSlug` you polled with)       |
| `data.status`         | string  | Current batch state — see [Status Values](#status-values)                 |
| `data.totalCount`     | number  | Total number of invoices in the batch                                     |
| `data.pendingCount`   | number  | Number of invoices not yet processed                                      |
| `data.discardedCount` | number  | Number of invoices that were skipped (could not be paid) — see note below |

### Status Values

| Value        | Meaning                                                                          |
| ------------ | -------------------------------------------------------------------------------- |
| `PROCESSING` | The batch is still running                                                       |
| `COMPLETED`  | The batch finished and every invoice was paid successfully                       |
| `PROCESSED`  | The batch finished, but one or more invoices were skipped (see `discardedCount`) |

<Info>
  This endpoint reports aggregate counts only — it does not expose which specific invoices were skipped or why. If you need to confirm the outcome for a particular invoice, check its state via the [Invoice Details API](/apis/invoice-details) once `status` is `COMPLETED` or `PROCESSED`.
</Info>

### Response Example — still processing

```json theme={null}
{
  "ok": true,
  "data": {
    "slug": "bulk_action_identifier",
    "status": "PROCESSING",
    "totalCount": 250,
    "pendingCount": 130,
    "discardedCount": 4
  }
}
```

### Response Example — completed with some skipped

```json theme={null}
{
  "ok": true,
  "data": {
    "slug": "bulk_action_identifier",
    "status": "PROCESSED",
    "totalCount": 250,
    "pendingCount": 0,
    "discardedCount": 6
  }
}
```

### Response Example — completed, all succeeded

```json theme={null}
{
  "ok": true,
  "data": {
    "slug": "bulk_action_identifier",
    "status": "COMPLETED",
    "totalCount": 250,
    "pendingCount": 0,
    "discardedCount": 0
  }
}
```

## Error Responses

### Batch Not Found

**HTTP Status:** `404 Not Found`

```json theme={null}
{
  "ok": false,
  "error": {
    "code": "BATCH_NOT_FOUND",
    "message": "Mark-as-paid batch not found"
  }
}
```

### Authentication Errors

**HTTP Status:** `401 Unauthorized`

```json theme={null}
{
  "ok": false,
  "error": {
    "code": "MISSING_CREDENTIALS",
    "message": "Missing Credentials"
  }
}
```

```json theme={null}
{
  "ok": false,
  "error": {
    "code": "INVALID_API_KEY",
    "message": "Invalid API Key"
  }
}
```

### Permission Errors

**HTTP Status:** `403 Forbidden`

```json theme={null}
{
  "ok": false,
  "error": {
    "code": "INSUFFICIENT_PERMISSIONS",
    "message": "Permission check failed - PERMISSION_CHECK_FAILED"
  }
}
```

## Best Practices

* Poll on an interval (e.g. every 10–30 seconds) rather than continuously — batches can take time to process, especially larger ones
* Stop polling once `status` is `COMPLETED` or `PROCESSED` — both are terminal states
* A non-zero `discardedCount` doesn't indicate a mark-as-paid API failure — it means specific invoices in that batch couldn't be paid (e.g. no longer in `APPROVED` state, or amount exceeded the due balance) while the rest of the batch proceeded normally
