> Index of every page: https://docs.merchantservicedepot.com/llms.txt

# Collect due invoices now (sandbox)


`POST /v1/invoices/scheduler/run`

**Sandbox only** — returns `permission_denied` anywhere else, where scheduled invoices collect on their own. Collects your invoices that are due right now, up to a batch limit, and answers `{claimed, collected, released}`; call it again if `claimed` came back at the limit.

Use it to see a schedule through to a charge without waiting for its date: schedule with a `collectAt` in the past, then call this. The charge is real, with the same statuses and Attempts rows a dated collection produces — nothing here is simulated. Calling it twice is safe; a second pass reuses the transaction rather than charging again.

Auth: a secret key with the `invoices.schedule` permission. Returns `200` with Collection run.

## Request

**curl**

```curl
curl -X POST "https://payments-api-sandbox.merchantservicedepot.com/v1/invoices/scheduler/run" \
  -H "Authorization: Bearer $MYELA_API_KEY"
```

**Node**

```node
const res = await fetch("https://payments-api-sandbox.merchantservicedepot.com/v1/invoices/scheduler/run", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MYELA_API_KEY}`,
  },
});

if (!res.ok) {
  const { error } = await res.json();
  // Branch on error.code — never on error.message.
  throw new Error(error.code);
}
const data = await res.json();
```

**Python**

```python
import os
import requests

res = requests.post(
    "https://payments-api-sandbox.merchantservicedepot.com/v1/invoices/scheduler/run",
    headers={
        "Authorization": f"Bearer {os.environ['MYELA_API_KEY']}",
    },
)

if not res.ok:
    # Branch on error["code"] — never on error["message"].
    raise RuntimeError(res.json()["error"]["code"])
data = res.json()
```

## Response

| Field | Type | Description |
| --- | --- | --- |
| `claimed` | integer | Invoices of yours that were due and taken for collection in this pass, up to the batch limit. Call again if it comes back at the limit. |
| `collected` | integer | How many of those were charged successfully. A shortfall is not an error — a declined card is recorded against the invoice and retried on its own schedule; read Attempts for the reason. |
| `released` | integer | Invoices freed from a pass that stopped part-way and left them held. Normally 0. |

```json
{
  "claimed": 2,
  "collected": 1,
  "released": 0
}
```

Source: https://docs.merchantservicedepot.com/api-reference/collect-due-invoices-now-sandbox/
