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

# Bulk jobs

> Create customers, capture payments, or create and schedule invoices in batches of up to 500 rows, and resume the rows that didn't resolve.

A bulk job runs up to 500 rows through one action in a single request. Each row succeeds or fails on its own, and a row that succeeded is never rolled back because another one failed.

## Three actions

Bulk jobs cover three actions: creating customers, capturing payments you've already authorized, and creating and scheduling invoices. No route accepts card data or payment tokens.

| Route | Job type | Does |
| --- | --- | --- |
| `POST /v1/bulk_jobs/customers` | `customers.create` | Creates one customer per row. |
| `POST /v1/bulk_jobs/captures` | `payments.capture` | Captures one authorized payment per row. |
| `POST /v1/bulk_jobs/invoices` | `invoices.schedule` | Creates one invoice per row, then schedules it for collection. |

Whether each action is available varies by account. Check `GET /v1/capabilities` before you build on one. The Node SDK doesn't cover bulk jobs, so call these routes over HTTP.

## Create a job

Send an `Idempotency-Key` header and a body with one field, `items`, holding 1 to 500 rows. The header is required: without it the request is a `422`. Any other top-level field, or an unknown field in a customer row, is a `422` with `details.code` `UNKNOWN_FIELD`.

**Customers**

```bash title="terminal"
curl -X POST https://payments-api-sandbox.merchantservicedepot.com/v1/bulk_jobs/customers \
  -H "Authorization: Bearer myela_sk_test_…" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: import-2026-10-29-batch-1" \
  -d '{
    "items": [
      { "email": "grace@example.com", "name": "Grace Hopper", "phone": "+15555550124", "externalId": "crm_1001" },
      { "email": "alan@example.com" }
    ]
  }'
```

**Captures**

```bash title="terminal"
# Omit amount on a row to capture the full authorization
curl -X POST https://payments-api-sandbox.merchantservicedepot.com/v1/bulk_jobs/captures \
  -H "Authorization: Bearer myela_sk_test_…" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: captures-2026-10-29" \
  -d '{
    "items": [
      { "transactionId": "{id}", "amount": 2500 }
    ]
  }'
```

### Customer rows

| Field | Required | Means |
| --- | --- | --- |
| `email` | Yes | The format is checked per row when the job runs. |
| `name` | No | Up to 255 characters. Defaults to the part of the email before the @. |
| `phone` | No | Up to 32 characters. |
| `externalId` | No | Your own reference, 1 to 255 characters. |

### Capture rows

| Field | Required | Means |
| --- | --- | --- |
| `transactionId` | Yes | The Myela id of an authorized payment. |
| `amount` | No | Integer in minor units. Omit it for a full capture. |
| `amountTip` | No | The final tip included in an adjustable total, in minor units. |
| `idempotencyKey` | No | A key for this row, up to 255 characters. Defaults to the job id and row number. |

For how a single capture behaves, see [Capture, void, and refund](https://docs.merchantservicedepot.com/docs/payments/capture-void-refund/).

### Invoice rows

A row takes the `POST /v1/invoices` fields (`customerId`, `amount` or `items`, `currency`, `amountTax`, `amountDiscount`, `dueAt`, `paymentTerms`, `description`) plus the schedule fields `collectAt` and `paymentMethodId`, and an optional `idempotencyKey`. Unlike the single route, a row refuses unknown fields. Each row needs `collectAt` or `dueAt`, and no two rows in one request may share an `idempotencyKey`. Either problem is a `422` before anything is created.

A row is created and then scheduled by the same rules as the two single routes, so each fires `invoice.created` and `invoice.scheduled`. The row's `idempotencyKey` covers both steps: send the same row again, in this job or a later one, and you get its invoice back instead of a second one. Without it the job derives a key from the job id and row number, which only protects a resume of the same job.

A refused row is `failed`, and its `error.detailCode` carries the code the single route returns in `details.code`. A row refused after its invoice was created still names the draft invoice in `result`, so you can fix and schedule it or void it. A row stopped by a temporary problem is `unresolved`; resume the job to retry it. Where automatic collection isn't running, the create response adds a `warning` with code `INVOICE_SCHEDULER_DISABLED`, as a single schedule does. A key issued before this route existed lacks `bulkJobs.scheduleInvoices` until Myela adds it.

## Read the results

The job runs inside the request that creates it. The `201` response usually holds the finished job, with a `status`, counts in `totalItems`, `processedItems`, `succeededItems`, `failedItems`, and `unresolvedItems`, and one entry per row in `items`. Read it again later with `GET /v1/bulk_jobs/{id}`. If another request is already running the job, you get its current state without waiting.

| Job status | Means |
| --- | --- |
| `pending` | Created, not started. |
| `processing` | Rows are running. |
| `completed` | Every row succeeded. |
| `completed_with_errors` | Done, and at least one row failed or is unresolved. |

Each row entry has a 1-based `row` number, a `status`, and either a `result` or an `error`. On a capture row, `result.status` is the payment's status. A row's `error.code` is `item_failed` or `payment_outcome_unknown`. The message is generic, and the specific reason isn't published.

| Row status | Means |
| --- | --- |
| `pending` | Not run yet. |
| `processing` | Running now. |
| `succeeded` | Done. result.id holds the customer or payment id. |
| `failed` | Didn't go through. Resume never re-runs it. |
| `unresolved` | Capture and invoice rows. The outcome is unknown, or a temporary problem stopped the row. Reconcile, then resume. |

Shape checks happen when the request arrives: a missing or empty `email`, a field over its length limit, or an unknown field fails the whole request. Email format is checked when the row runs, so a malformed email fails only that row and leaves the rest alone.

## Idempotency keys

The `Idempotency-Key` names the job, and Myela doesn't compare the body. Send the same key to the same route again and you get the existing job back. A finished job returns as it is; an unfinished one runs again. Either way, the `items` you sent the second time are ignored. Using the same key on the other route is a `409` with `details.code` `IDEMPOTENCY_KEY_REUSED`.

Use one new key for each batch you mean to run. If you change the rows, change the key.

Capture rows also carry their own key. Leave `idempotencyKey` out and the row uses `{jobId}:{rowNumber}`. Resume re-runs a row through that same key. More in [Idempotency and retries](https://docs.merchantservicedepot.com/docs/platform/idempotency/).

## Resume unresolved rows

A capture row whose outcome is unknown ends as `unresolved`. Reconcile the payment first, then call `POST /v1/bulk_jobs/{id}/resume`. Resume runs those rows again through their original keys: a capture that went through ends as `succeeded`, and one that didn't ends as `failed` without another attempt at the provider.

```bash title="terminal"
# Read the job and its rows
curl https://payments-api-sandbox.merchantservicedepot.com/v1/bulk_jobs/{id} \
  -H "Authorization: Bearer myela_sk_test_…"

# Re-run unresolved rows (no body)
curl -X POST https://payments-api-sandbox.merchantservicedepot.com/v1/bulk_jobs/{id}/resume \
  -H "Authorization: Bearer myela_sk_test_…"
```

Resume picks up rows that are `unresolved`, still `pending`, or stuck in `processing`. It never re-runs a `failed` row; send those in a new job with a new key. If there's nothing to pick up, resume returns the job unchanged. When a resumed customer row finds an active customer with the same email, it uses that customer instead of creating a duplicate.

A job lives for seven days, shown in its `expiresAt`. Resuming after that is a `409` with `details.code` `BULK_JOB_EXPIRED`.

Source: https://docs.merchantservicedepot.com/docs/payments/bulk-jobs/
