Send a payout
Send funds to a bank account with POST /v1/transactions/payout.
POST /v1/transactions/payout sends money to a recipient's bank account by ACH. Send amount as a positive number. dhango records the payout as a negative amount, because money is leaving the account.
Payouts run on Third Party Sender, and on the Fake processor for testing. Stripe, Adyen, Nacha Direct Debit, and the legacy gateways cannot originate payouts.
Choose the destination
Send exactly one of ach, tokenId, or payeeAccountKey:
ach, withbankAccountHolder,routingNumber, andaccountNumbertokenIdfor a saved bank account. It must be an active ACH token, and a token for any other payment method is rejected.payeeAccountKeyfor an in-system payee, which uses that account's deposit bank
With ach or tokenId, also send payee, the recipient's name, which can differ from the bank account holder. With payeeAccountKey, leave payee out, because dhango uses the name on that account. The payee account must be active and on the same platform as the account paying out.
Other fields
currencyis required.platformFeeis optional. Leave it out and dhango calculates the fee from the account pricing. As a platform paying out for a merchant, you can send aplatformFeegreater than 0 to override the calculation for this one payout.sendReceiptrequests an email receipt. Leave it null to use the account setting.emailAddress,comments,metadata, andpaidInvoicesare optional. See the Transactions reference.
Third Party Sender rules
- The currency must be USD, as on every Third Party Sender transaction.
- When you send
achwith abankAccountTypeofPersonalCheckingorPersonalSavings, dhango validates the account number first and rejects the payout if validation fails. Payouts to atokenIdskip this check. - To an outside recipient (
achortokenId), the events arePayout, thenBatch, when the account paying out is debited, thenProcess, when the credit is sent to the recipient's bank. dhango sends that credit about 3 banking days after the debit, once the debit has cleared. - To an in-system payee (
payeeAccountKey), the events arePayout, thenBatch, and the payee is credited in a batch like any other merchant funding. There is noProcessevent.
On the Fake processor, a payout succeeds and goes straight into a batch.
Returns
A payout can be returned by the recipient's bank, and dhango applies the return from the Third Party Sender return file. If the payout was already batched, dhango creates a new linked transaction with event type Return and sends a TransactionEvent for it. If the payout was not batched yet, dhango marks the original payout returned and sends a TransactionEvent with event type Return.
Responses and retries
A successful call returns 201 with the transaction, and dhango sends a TransactionEvent webhook with event type Payout. If you repeat the request with the same Idempotency-Key and the same body, you get the same transaction back, with the Idempotent-Replayed response header set to true.
| Status | Meaning |
|---|---|
| 400 | The payout was not created. |
| 403 with a body | The paying account is not active. This also applies when you replay an Idempotency-Key from a request made while the account was active. Once the account is active again, the replay returns the transaction. |
| 403 with no body | The credential does not have permission. |
| 409 | A request with this key is still in progress, or its outcome is not known yet. Retry later with the same key. |
| 422 | This key was already used with a different body. |
| 503 | Idempotency checks are unavailable, and the request was not processed. Retry later with the same key. |
To reconcile payouts, use GET /v1/transactions/{id} and the BatchAdd and BatchUpdate webhooks.
curl -s -u "$DHANGO_KEY:$DHANGO_SECRET" \ -H "Content-Type: application/json" \ -H "accountKey: $ACCOUNT_KEY" \ -H "Idempotency-Key: 9a8b7c6d-5e4f-3210-abcd-ef1234567890" \ -d '{"payee":"Northwind","amount":100.00,"tokenId":"tok_bank"}' \ https://api.dhangodemo.com/v1/transactions/payoutawait fetch("https://api.dhangodemo.com/v1/transactions/payout", { method: "POST", headers: { Authorization: "Basic " + Buffer.from(process.env.DHANGO_KEY + ":" + process.env.DHANGO_SECRET).toString("base64"), "Content-Type": "application/json", accountKey: process.env.ACCOUNT_KEY, "Idempotency-Key": crypto.randomUUID() }, body: JSON.stringify({ payee: "Northwind", amount: 100, tokenId: "tok_bank" })});import os, json, urllib.requestauth = os.environ["DHANGO_KEY"] + ":" + os.environ["DHANGO_SECRET"]request = urllib.request.Request( "https://api.dhangodemo.com/v1/transactions/payout", data=json.dumps({"payee": "Northwind", "amount": 100, "tokenId": "tok_bank"}).encode(), headers={ "Authorization": "Basic " + __import__("base64").b64encode(auth.encode()).decode(), "Content-Type": "application/json", "accountKey": os.environ["ACCOUNT_KEY"], "Idempotency-Key": "9a8b7c6d-5e4f-3210-abcd-ef1234567890", }, method="POST",)payout = json.load(urllib.request.urlopen(request))