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
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.data._id as ADJ_ID. Reference: Create a payout adjustment.
Step 3. List pending payouts
Step 4. List the vendor’s pending items
lineItemIds and adjustmentIds to pay. Reference: List a vendor’s pending items.
Step 5. Preview the payout
200 OK
issue before you pay. Reference: Preview a payout.
Step 6. Create the payout
Send the same body with a newIdempotency-Key.
- Same key, same body, while the run is still processing:
409 IDEMPOTENCY_IN_PROGRESS. Polldetails.transactionId. - Same key, same body, after the run finishes:
200withreplay: trueand the currentstatus.statusmoves fromprocessingtocompletedonce the background job finishes, usually 30 to 60 seconds after the first call.transactionId,dryRun,vendorsandtotalPayoutmatch the first response. Nothing is paid twice. - Same key, different body:
422 IDEMPOTENCY_KEY_REUSED. Use a new key.
status from the response you get. For the latest status, call GET /payouts/make-payment/{id}.
202 Accepted with data.transactionId and status: "processing". Save transactionId as TXN_ID.
A replay after the run finishes looks like this:
200 OK
Step 7. Poll the payout
Poll every 2–5 seconds untilstatus is completed or failed.
200 OK
Step 8. Check the transaction list
payoutMethod, comment and its batches. markAsPaid has marked only.
Step 9. If a batch failed
If a batch hasstatus: "failed", do one of these:
- Retry it: Retry a payout batch.
- Or, if you paid the vendor another way, record it: Mark a batch as paid.
Idempotency-Key and return a transactionId you poll as in step 7.