Skip to main content

Purpose

This guide pays one vendor with the API, from start to finish. Each step is one request you can copy.

Before you start

  • You need a merchant API key (mk_live_…).
  • Automated Payouts must be off. If it is on, payout requests return 409 AUTOMATED_PAYOUTS_ACTIVE. Turn it off in Settings > Payouts > Automated Payouts > Disable Automated Payouts.
  • Set these shell variables:

Step 1. Authenticate

Send the token in the x-access-token header on every request below. Reference: Authenticate.

Step 2. Create a payout adjustment (optional)

Skip this step if you only pay order line items.
Save data._id as ADJ_ID. Reference: Create a payout adjustment.

Step 3. List pending payouts

Each vendor shows its unpaid total. Reference: List pending payouts.

Step 4. List the vendor’s pending items

Collect the lineItemIds and adjustmentIds to pay. Reference: List a vendor’s pending items.

Step 5. Preview the payout

200 OK
Fix any vendor with a non-null issue before you pay. Reference: Preview a payout.

Step 6. Create the payout

Send the same body with a new Idempotency-Key.
  • Same key, same body, while the run is still processing: 409 IDEMPOTENCY_IN_PROGRESS. Poll details.transactionId.
  • Same key, same body, after the run finishes: 200 with replay: true and the current status. status moves from processing to completed once the background job finishes, usually 30 to 60 seconds after the first call. transactionId, dryRun, vendors and totalPayout match the first response. Nothing is paid twice.
  • Same key, different body: 422 IDEMPOTENCY_KEY_REUSED. Use a new key.
Read status from the response you get. For the latest status, call GET /payouts/make-payment/{id}.
The first response is 202 Accepted with data.transactionId and status: "processing". Save transactionId as TXN_ID. A replay after the run finishes looks like this:
200 OK
Reference: Create a payout.

Step 7. Poll the payout

Poll every 2–5 seconds until status is completed or failed.
200 OK
Reference: Get a payout.

Step 8. Check the transaction list

Your payout is listed once, with payoutMethod, comment and its batches. markAsPaid has marked only.
Reference: List payout transactions.

Step 9. If a batch failed

If a batch has status: "failed", do one of these: Both need an Idempotency-Key and return a transactionId you poll as in step 7.

Status values

Next step

Create a payout has every field and error in full.