Skip to main content

Custody gateway API

Set up the custody gateway add-on, walk a deposit and a withdrawal through its routes, bind a client wallet and reinstate a suspended payout address.

The custody gateway routes live under /api/v2/addons/custody-gateways in the custodyOps operation group of the Platform API. This guide covers add-on setup, then walks through deposit and withdrawal flows in order. See Deposit and withdrawal stages for every stage and transition rule, and Custody gateway for the conceptual model.

Before you call

  • Licensed module: These routes belong to the “Self-custody” licensed module, controlled by features.custodyOps (on by default). If disabled for the deployment, the routes return 404. If disabled for an organisation, reads continue and writes return 403 platform.module.DISABLED (DALP-20531).
  • Authentication and step-up: Writes authenticated with a Console session include walletVerification when a wallet factor is set. Programmatic writes authenticated with X-Api-Key omit walletVerification. Clearing a client flag and setting up or rotating signer wallets send no on-chain transaction but still require wallet verification on session calls. Adding an operator note requires neither.
  • Async settlement and idempotency: On-chain writes return 202 with a status URL to poll, or 200 when Prefer: wait=N settles in time. Send Idempotency-Key so retries never duplicate writes. See Idempotency and async settlement.
  • Roles: The deposit, withdrawal and unsupported-transfer routes and the pause, unpause and close route admit a caller whose wallets hold a gateway role (Manager, Screener or Keeper) or are registered to the gateway's client identity. An organisation owner or platform administrator who holds no gateway role gets 404. Each transition checks the wallet that signs it for the role its contract call requires and otherwise returns 403 GATEWAY_ROLE_REQUIRED naming that role. On a gateway with a screener override, only the override wallet counts as screener. The client signs with any wallet registered to its identity. The bound client wallet only drives GET /gateways/mine.

Set up the add-on

The write routes below need the gateway Manager role on the wallet that signs the write, not an organisation role. The signer routes are the exception, and Set up the keeper and screener lists their roles. Two writes admit one more caller: a Screener removes a gateway's approved source (on a gateway with a screener override, only the override wallet), and the gateway's client binds its client wallet from a wallet registered to its identity. Any other caller, an organisation owner or platform administrator included, gets 403 GATEWAY_ROLE_REQUIRED naming the roles the write accepts, and nothing is queued. The reads depend on the roles your wallets hold on chain, not on your organisation role:

  • Factory, coins, profiles and settings: Any wallet of yours that holds a system role, a token role, a gateway role or the add-on's permission role can read them, including the settings of a gateway that the next bullet hides. Other callers, investors included, get 403 ADMIN_ACCESS_REQUIRED (DALP-0032). The factory response lists the gateway roles of all your wallets in callerRoles and the roles of the wallet you act with in executorRoles, which is the wallet every write signs with. Each field is left out when its role lookup fails. A role in callerRoles but not in executorRoles sits on another wallet of yours: the Console keeps the write buttons off and asks you to act with the wallet that holds it.
  • Gateways: A wallet with the manager or keeper role can read every gateway of your organisation's system. A wallet with only the screener role reads every gateway without a screener override. Other callers see only the gateways where one of their identities is the client, or where one of their wallets is the screener override. The list returns an empty page and a single gateway returns 404 for anything else.

In the Console, use Set up the custody gateway. Reads come from indexed chain data and can lag briefly after a write. If no custody gateway add-on is deployed on the network, routes return 404 GATEWAY_ADDON_NOT_DEPLOYED.

Step
Route
What it does
Read factory and inventory
GET /api/v2/addons/custody-gateways/factory, /tokens, /profiles, /gateways, /gateways/{gatewayAddress}
Returns the factory, fee account, pause switch, access manager, enabled coins, profiles, and gateway details.
Enable a coin
POST /api/v2/addons/custody-gateways/tokens
Enables a coin with its custody receipt. defaults must include non-zero freeze-expiry and paused-exit-after. Invalid or duplicate settings return 422, an already enabled coin returns 409, and a coin with Booked movements attached returns 422 GATEWAY_COIN_HAS_BOOKED_MOVEMENTS. Receipt decimals must match the coin and bind the own-custody-gateway rule to this factory. Under the default rule the route returns 422 GATEWAY_APPROVAL_REQUIRED until a second gateway manager approves. Set the treasury after enablement.
Set a coin's treasury
PUT /api/v2/addons/custody-gateways/tokens/{tokenAddress}/treasury
Sets the wallet or vault the gateway pays pooled withdrawals of an enabled coin from. A wallet approves the gateway factory to spend the coin. Needs checker approval like a settings change. A coin that is not enabled answers 422 GATEWAY_WRITE_REFUSED.
Clear a coin's treasury
POST /api/v2/addons/custody-gateways/tokens/{tokenAddress}/treasury/transitions
Removes the coin's treasury with transition: clear, so pooled withdrawals wait for funding again. One manager clears it with no checker approval. A coin that is not enabled answers 422 GATEWAY_WRITE_REFUSED.
Set the fee account
PUT /api/v2/addons/custody-gateways/factory/fee-account
Sets the account every gateway of the add-on pays its fees to. Needs checker approval like a settings change. The factory read returns the current value as feeAccount.
Pause or resume all gateways
POST /api/v2/addons/custody-gateways/factory/transitions
With pause, one manager pauses every gateway of the add-on at once, with no checker approval. With unpause, the pause lifts once the checkers approve. A gateway paused on its own stays paused. The factory read returns the switch as addonPaused.
Manage profiles
POST /api/v2/addons/custody-gateways/profiles, POST /api/v2/addons/custody-gateways/profiles/{profileId}/transitions
Creates a profile from a name and required verification topic. Send {"transition": "remove"} to remove an unused profile (in-use profiles return 409).
Provision signers
GET /api/v2/addons/custody-gateways/signers, POST /api/v2/addons/custody-gateways/signers, PATCH /api/v2/addons/custody-gateways/signers/{role}, POST /api/v2/addons/custody-gateways/signers/{role}/transitions
Provisions or rotates keeper and screener wallets ({"transition": "rotate"}) and sets low-balance thresholds. See Set up the keeper and screener.
Create a gateway
POST /api/v2/addons/custody-gateways/gateways
Creates a gateway for a client identity under a profile. Returns 409 if the client identity already has a gateway.
Update settings
PATCH /api/v2/addons/custody-gateways/tokens/{tokenAddress}/settings, /profiles/{profileId}/settings, /gateways/{gatewayAddress}/settings
Updates up to 20 settings at one level (null clears the override). Enabling wait-for-custody requires coins-go-to to resolve to a Fireblocks custody wallet at that level and every level below it.
Read settings
GET /api/v2/addons/custody-gateways/tokens/{tokenAddress}/settings, /profiles/{profileId}/settings?token=, /gateways/{gatewayAddress}/settings?token=
Returns every setting with its value and source: addon for the coin default, profile or gateway. Pass the coin's address in token. The coin read returns only coin defaults. The profile read merges the profile with them: for the five stricter-value settings a looser profile value gives way to the coin default, with source addon, and time limits stay within the coin default. An unknown profile or gateway returns 404. A setting without a value, including a time limit with no coin default, has null as both value and source. A coin that is not enabled returns 200 with every value null.
Move profile or bind wallet
PATCH /api/v2/addons/custody-gateways/gateways/{gatewayAddress}, /gateways/{gatewayAddress}/client-wallet
Moves a gateway to another profile, or binds its client wallet (returns 422 if the wallet does not belong to the client identity).
Manage lists and funding sources
POST /api/v2/addons/custody-gateways/gateways/{gatewayAddress}/approved-sources, /approved-payouts, /tokens/{tokenAddress}/funding-sources
Adds approved source, payout, or withdrawal-funding addresses. Their /{address}/transitions (or /{sourceAddress}/transitions) routes remove, suspend, or reinstate entries.

Before queueing any write, the platform simulates the call from the signing wallet. If the add-on checker requires multi-manager approval, the route returns 422 GATEWAY_APPROVAL_REQUIRED with the calls to propose and their hashes, queueing nothing. The route checks wallet verification after that simulation, so a write the checker holds returns GATEWAY_APPROVAL_REQUIRED even with no walletVerification. Send the code only when you propose the held calls or when the route answers WALLET_VERIFICATION_REQUIRED. The signer set-up and rotate routes check wallet verification first.

After the required gateway managers approve those calls on Approvals, the proposer resends the original request. See Approvals through the add-on checker. A contract revert returns 422 GATEWAY_WRITE_REFUSED with data.revert, and enabling wait-for-custody on an incompatible receipt returns 422 GATEWAY_CANNOT_WAIT_FOR_CUSTODY.

Bind the client wallet

A newly created gateway has no bound client wallet because a client identity can hold several wallets. Until one is bound, client routes return 404. A gateway manager can bind it from the gateway's Overview tab in the Console (Create a client gateway), or through this route. Bind a wallet owned by the gateway's client identity:

curl -sS -X PATCH "$DALP_API_URL/api/v2/addons/custody-gateways/gateways/$GATEWAY/client-wallet" \
  -H "X-Api-Key: $DALP_API_KEY" \
  -H "Idempotency-Key: bind-wallet-001" \
  -H "Content-Type: application/json" \
  -d '{
    "clientWallet": "0x71C7656EC7ab88b098defB751B7401B5f6d8976F"
  }'

The response returns {"clientWallet": "0x71C7656EC7ab88b098defB751B7401B5f6d8976F"}. Once bound, GET /api/v2/addons/custody-gateways/gateways/mine returns the gateway and its deposit address to the client. Its paused is true while the gateway or the whole add-on is paused. Every mint verifies again that the bound wallet belongs to the client identity.

Walk a deposit

  1. The client calls GET /api/v2/addons/custody-gateways/gateways/mine and transfers coins to the gateway address, or records a deposit with POST /api/v2/addons/custody-gateways/gateways/{gatewayAddress}/deposits using {"token": "0x...", "amount": "1000000"}. An unsupported coin returns 422 GATEWAY_WRITE_REFUSED with data.revert set to CustodyGatewayTokenNotEnabled.
  2. List deposits with GET /api/v2/addons/custody-gateways/gateways/{gatewayAddress}/deposits or read one with GET /api/v2/addons/custody-gateways/gateways/{gatewayAddress}/deposits/{depositId}. New deposits start at Quarantined.
  3. The screener transitions the deposit with POST /api/v2/addons/custody-gateways/gateways/{gatewayAddress}/deposits/{depositId}/transitions:
curl -sS -X POST "$DALP_API_URL/api/v2/addons/custody-gateways/gateways/$GATEWAY/deposits/$DEPOSIT_ID/transitions" \
  -H "X-Api-Key: $DALP_API_KEY" \
  -H "Idempotency-Key: deposit-clear-001" \
  -H "Content-Type: application/json" \
  -d '{
    "transition": "clear"
  }'
  1. A Screener sends confirm-sender, clear and refuse. A Manager or Screener sends flag and unfreeze. A Manager sends renew-freeze, report, return, custody-returned and recover (which also takes "to"). A Keeper sends retry. The client sends pull-back and exit.
  2. Read GET /api/v2/addons/custody-gateways/gateways/{gatewayAddress}/deposits/{depositId}/screening for screening details, and post operator notes to POST /api/v2/addons/custody-gateways/gateways/{gatewayAddress}/deposits/{depositId}/notes.

Walk a withdrawal

  1. The client reads the fee with GET /api/v2/addons/custody-gateways/gateways/{gatewayAddress}/withdrawal-fee-quotes, then creates a withdrawal with POST /api/v2/addons/custody-gateways/gateways/{gatewayAddress}/withdrawals using {"receiptToken": "0x...", "shares": "1000000", "payout": "0x..."}. The payout address must be on the approved payout list. An unknown receipt token returns 422 GATEWAY_RECEIPT_TOKEN_NOT_ENABLED.
  2. List and read withdrawals with GET /api/v2/addons/custody-gateways/gateways/{gatewayAddress}/withdrawals and GET /api/v2/addons/custody-gateways/gateways/{gatewayAddress}/withdrawals/{requestId}. Read screening results at GET /api/v2/addons/custody-gateways/gateways/{gatewayAddress}/withdrawals/{requestId}/screening.
  3. Transition the request with POST /api/v2/addons/custody-gateways/gateways/{gatewayAddress}/withdrawals/{requestId}/transitions:
curl -sS -X POST "$DALP_API_URL/api/v2/addons/custody-gateways/gateways/$GATEWAY/withdrawals/$REQUEST_ID/transitions" \
  -H "X-Api-Key: $DALP_API_KEY" \
  -H "Idempotency-Key: withdrawal-collect-001" \
  -H "Content-Type: application/json" \
  -d '{
    "transition": "collect"
  }'
  1. A Screener sends clear. A Manager or Screener sends reject, flag and unfreeze. A Manager sends approve, renew-freeze, report, return and unfulfil. The client sends cancel, exit and set-payout (which also takes "payout"), and the client or a Keeper sends collect. If the client's organisation account status blocks withdrawals, clear, approve, collect, and exit on a claimable request return 422 custodyOps.withdrawal.PARTICIPANT_RESTRICTED, while unwinding transitions still work.
  2. Clients configure payout preferences with PATCH /api/v2/addons/custody-gateways/gateways/{gatewayAddress}/auto-claim ({"enabled": true}) and PATCH /api/v2/addons/custody-gateways/gateways/{gatewayAddress}/default-payout ({"payout": "0x..."}).

Reinstate a payout address

A client flag suspends the gateway's approved payout addresses, and clearing the flag does not reinstate them. After review, a gateway manager reinstates an address via its transitions route:

curl -sS -X POST "$DALP_API_URL/api/v2/addons/custody-gateways/gateways/$GATEWAY/approved-payouts/$ADDRESS/transitions" \
  -H "X-Api-Key: $DALP_API_KEY" \
  -H "Idempotency-Key: payout-reinstate-001" \
  -H "Content-Type: application/json" \
  -d '{
    "transition": "reinstate"
  }'

The other transitions on this route are remove and suspend. List addresses with GET /api/v2/addons/custody-gateways/gateways/{gatewayAddress}/approved-payouts and add one with POST /api/v2/addons/custody-gateways/gateways/{gatewayAddress}/approved-payouts.

Set up the keeper and screener

The keeper and screener sign automatic gateway calls from wallets provisioned through your custody provider. POST /api/v2/addons/custody-gateways/signers provisions a role's wallet and grants its role in one write:

curl -sS -X POST "$DALP_API_URL/api/v2/addons/custody-gateways/signers" \
  -H "Cookie: $DALP_SESSION_COOKIE" \
  -H "Idempotency-Key: signer-keeper-001" \
  -H "Content-Type: application/json" \
  -d '{
    "role": "keeper",
    "providerConfigurationId": "019c4d2e-7a10-7b3c-9e21-5f8a6b4c3d2e",
    "walletVerification": {
      "verificationType": "PINCODE",
      "secretVerificationCode": "482913"
    }
  }'
  • Console session only: Signer setup and rotation require a Console-issued session and reject API keys with 403 WALLET_ROLE_ADMINISTRATION_NEEDS_CONSOLE_SIGN_IN (DALP-200384).
  • Role grant response: The response includes grant. When grant.status is "queued", follow grant.statusUrl. When "settled", grant.transactionHash holds the transaction hash. null means the wallet already exists past pending and nothing was sent.
  • Rotation: POST /api/v2/addons/custody-gateways/signers/{role}/transitions with {"transition": "rotate"} mints and grants the next wallet. The previous wallet keeps its role until revoked via POST /api/v2/addons/custody-gateways/role-members/{role}/{account}/transitions.
  • Required roles: GET /api/v2/addons/custody-gateways/signers requires the gateway permission manager role on the system or the add-on manager role. Setup and rotation require the gateway permission manager role (checked before key minting). PATCH /api/v2/addons/custody-gateways/signers/{role} requires the add-on manager role. Other callers receive 403 ADMIN_ACCESS_REQUIRED (DALP-0032) with data.reason set to custody-gateway-signers-read, custody-gateway-signer-provision, or custody-gateway-signer-threshold.
  • Access manager refusal: If the access manager still refuses the role grant, setup and rotation return 422 GATEWAY_PERMISSION_MANAGER_REQUIRED (DALP-9830).

Grant and revoke gateway roles

GET /api/v2/addons/custody-gateways/role-members lists who holds the manager, keeper and screener roles on the add-on's access manager. A row's blocked is true when the system's role block list blocks the wallet: it keeps the role but cannot use it until it is unblocked. POST /api/v2/addons/custody-gateways/role-members grants one role to a wallet, and POST …/role-members/{role}/{account}/transitions with {"transition": "revoke"} revokes it. Both writes need a Console-issued session and a wallet step-up.

Access comes from the indexed roles of your wallets, not your organisation role:

  • List: answers when one of your wallets holds the add-on's permission role or a gateway role. Other callers, an owner or platform administrator included, get 403 ADMIN_ACCESS_REQUIRED (DALP-0032).
  • Grant and revoke: the wallet you act with must hold the add-on's permission role, the same wallet the access manager checks. Otherwise the write returns 422 GATEWAY_PERMISSION_MANAGER_REQUIRED (DALP-9830) and queues nothing.
  • Before the first grant: a new add-on has no access manager. A caller whose wallet holds Gateway permission manager (custodyGatewayPermissionManager) on the system gets an empty list, and its first grant creates the access manager in the same write. Every other caller's list, and every revoke, returns 404 GATEWAY_ADDON_NOT_DEPLOYED.

Read review work and lists

Access to these reads comes from the indexed gateway roles of your wallets, not your organisation role.

  • Review queue, screening, client flag and notes: GET …/gateways/{gatewayAddress}/review-queue, …/deposits/{depositId}/screening, …/withdrawals/{requestId}/screening and …/client-flag answer a wallet with the gateway manager, keeper or screener role, and the gateway's screener override. The gateway's client gets an empty review queue and 404 on the others. POST …/deposits/{depositId}/notes needs the manager or screener role and returns 403 GATEWAY_ROLE_REQUIRED otherwise. On a gateway with a screener override, only the override wallet counts as its screener, though a manager still qualifies.
  • Lists: GET …/approved-sources, …/approved-payouts, …/whitelist-entries and …/tokens/{tokenAddress}/funding-sources answer the same role holders and the gateway's client wallet.
  • Everyone else: An owner or platform administrator without a gateway role gets 404 GATEWAY_NOT_FOUND, the same as for a gateway that is not indexed.

Other routes

Route
Use
GET /api/v2/addons/custody-gateways/clients/{identityAddress}
Read the name and wallets of the client behind an identity held by your organisation or by a member's acting participant. A gateway manager can read any such identity. A keeper or screener can read only the client identity of a gateway, and other callers only their own identity. Anything else returns 404.
GET /api/v2/addons/custody-gateways/gateways/{gatewayAddress}/client-flag, POST /api/v2/addons/custody-gateways/gateways/{gatewayAddress}/client-flag/transitions
Read a client's flag and clear it.
GET /api/v2/addons/custody-gateways/gateways/{gatewayAddress}/unsupported, POST /api/v2/addons/custody-gateways/gateways/{gatewayAddress}/unsupported/{recordKey}/transitions
Inspect and resolve coins the gateway does not accept. A Screener sends confirm-sender, and a Manager sends ignore, return, enable and recover.
POST /api/v2/addons/custody-gateways/gateways/{gatewayAddress}/transitions
Pause, unpause, or close a gateway with pause, unpause, or close.

Was this page helpful?