Organizations / Crypto
Crypto Rate Locks for Members
Run the full manual rate-lock flow for a member partner: register the customer, quote, lock a contract, fund it, exercise it and receive the payout. Every call uses your organization admin keys plus X-Crebit-Acting-As-Partner-Id, and everything you create belongs to the member.
- Every
/api/v1/fx/…endpoint on this page accepts the acting-as header. Omit it and the call runs as your own partner. - Contracts, payouts and margin calls are the member's. They show in the member's partner portal and use the member's limits, chain entitlements and fees.
- Crebit sends outbound webhooks to the member's webhook endpoint. With member webhooks enabled, you also receive a copy on your own endpoint (see Outbound webhooks).
- Crypto rate locks don't need fiat approval. For the acting-as basics and member management, see Organizations.
- To add your own markup on a member's lock, see Crypto: Client spread.
Flow at a Glance
- Register the member's customer reference.
- Check which chains and settlement currencies the member can use.
- Create a quote (forward or option).
- Create the contract from the quote before it expires.
- Send the stablecoins to
funding_wallet_addressand notify Crebit with afunds_in_routewebhook. The contract becomesactive. - Poll status or listen for webhooks.
- Optionally preview the settlement payout.
- When the customer transacts inside the window, send
contract_exercised. Crebit pays out and settles the contract.
1. Customer Reference
Register the member's opaque id for its end customer. Returns 201 when created and 200 with the existing row when the id is already registered for the member.
curl -sS -X POST "https://lock-apis-sandbox.crebitpay.com/api/v1/fx/customer-references" \
-H "Content-Type: application/json" \
-H "X-Crebit-Key-Id: ADMIN_KEY_ID" \
-H "X-Crebit-Key-Secret: ADMIN_KEY_SECRET" \
-H "X-Crebit-Environment: sandbox" \
-H "X-Crebit-Acting-As-Partner-Id: 8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b" \
-d '{"customer_reference_id":"member-cust-0042"}'{
"id": "66666666-6666-4666-8666-666666666666",
"customer_reference_id": "member-cust-0042",
"created_at": "2026-09-28T14:00:00Z"
}Read it back by the same id:
curl -sS -X GET "https://lock-apis-sandbox.crebitpay.com/api/v1/fx/customer-references/member-cust-0042" \
-H "X-Crebit-Key-Id: ADMIN_KEY_ID" \
-H "X-Crebit-Key-Secret: ADMIN_KEY_SECRET" \
-H "X-Crebit-Environment: sandbox" \
-H "X-Crebit-Acting-As-Partner-Id: 8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b"{
"id": "66666666-6666-4666-8666-666666666666",
"customer_reference_id": "member-cust-0042",
"created_at": "2026-09-28T14:00:00Z"
}List all of the member's customer references, newest first (limit 1–100, default 25; cursor from next_cursor):
curl -sS -X GET "https://lock-apis-sandbox.crebitpay.com/api/v1/fx/customer-references?limit=25" \
-H "X-Crebit-Key-Id: ADMIN_KEY_ID" \
-H "X-Crebit-Key-Secret: ADMIN_KEY_SECRET" \
-H "X-Crebit-Environment: sandbox" \
-H "X-Crebit-Acting-As-Partner-Id: 8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b"{
"items": [
{
"id": "66666666-6666-4666-8666-666666666666",
"customer_reference_id": "member-cust-0042",
"created_at": "2026-09-28T14:00:00Z"
}
],
"next_cursor": null
}2. Supported Chains
Lists the chains and settlement currencies you can pass on quotes and webhooks. enabled reflects the member'schain entitlement (and, in production, whether Crebit's payout float covers the pair).
curl -sS -X GET "https://lock-apis-sandbox.crebitpay.com/api/v1/fx/supported-chains" \
-H "X-Crebit-Key-Id: ADMIN_KEY_ID" \
-H "X-Crebit-Key-Secret: ADMIN_KEY_SECRET" \
-H "X-Crebit-Environment: sandbox" \
-H "X-Crebit-Acting-As-Partner-Id: 8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b"{
"chains": [
{
"chain": "solana",
"settlement_currencies": [
"USDC",
"USDT"
],
"status": "live",
"address_format_hint": "base58 pubkey (~32–44 chars)",
"enabled": true
},
{
"chain": "tron",
"settlement_currencies": [
"USDT"
],
"status": "live",
"address_format_hint": "Base58Check address starting with T (~34 chars)",
"enabled": true
}
],
"funded_settlement_pairs": null
}3. Quote
Price a forward or an option for the member's customer. The quote is valid until expires_at.
| Forward | Option | |
|---|---|---|
| contract_type | forward | option |
| Customer obligation | Must transact in the window | May transact in the window |
| Upfront funding | Premium (upfront fee) + deposit | Premium only |
| deposit_amount | Set | null |
| At window end if not exercised | Auto-exercised at maturity when a payout destination is saved | Expires |
| Margin calls | Possible | Not applicable |
curl -sS -X POST "https://lock-apis-sandbox.crebitpay.com/api/v1/fx/quotes" \
-H "Content-Type: application/json" \
-H "X-Crebit-Key-Id: ADMIN_KEY_ID" \
-H "X-Crebit-Key-Secret: ADMIN_KEY_SECRET" \
-H "X-Crebit-Environment: sandbox" \
-H "X-Crebit-Acting-As-Partner-Id: 8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"customer_reference_id":"member-cust-0042","customer_name":"Member Customer Ltda","contract_type":"forward","direction":"USD_TO_BRL","notional_currency":"USD","notional_amount":"50000.00","strike_mode":"live_spot","window_start":"2026-11-02T00:00:00Z","window_end":"2026-11-09T00:00:00Z","chain":"solana","settlement_currency":"USDC","payout_wallet_address":"EndUserSettlementWa11et1111111111111111111","oracle":"redstone"}'{
"id": "22222222-2222-4222-8222-222222222222",
"status": "created",
"locked_rate": "5.4200",
"market_rate": "5.4180",
"cip_forward": null,
"strike_mode": "live_spot",
"target_strike": null,
"strike_advantage_bps": 0,
"provider_extra_spread": null,
"premium_amount": "565.00",
"deposit_amount": "5000.00",
"total_amount": "5565.00",
"amount_due": "5565.00",
"collateral_amount": "5000.00",
"upfront_fee": "565.00",
"pricing_tier": "ml_full",
"pricing_greeks": {
"delta": 0.42,
"gamma": 0.01
},
"confidence_score": null,
"window_start": "2026-11-02T00:00:00Z",
"window_end": "2026-11-09T00:00:00Z",
"chain": "solana",
"source_chain": null,
"settlement_currency": "USDC",
"payout_wallet_address": "EndUserSettlementWa11et1111111111111111111",
"oracle": "redstone",
"expires_at": "2026-09-28T14:16:30Z",
"created_at": "2026-09-28T14:15:00Z",
"on_behalf_of_partner_id": null,
"on_behalf_of_partner_name": null
}strike_mode:cip_fair(default),live_spotorcustom(withtarget_strike).provider_rate,market_rateandmarket_rate_timestampare optional inputs.direction: BRL_TO_USD, USD_TO_BRL, MXN_TO_USD, USD_TO_MXN, NGN_TO_USD, USD_TO_NGN.settlement_currency: USDC or USDT.
Read a quote back:
curl -sS -X GET "https://lock-apis-sandbox.crebitpay.com/api/v1/fx/quotes/22222222-2222-4222-8222-222222222222" \
-H "X-Crebit-Key-Id: ADMIN_KEY_ID" \
-H "X-Crebit-Key-Secret: ADMIN_KEY_SECRET" \
-H "X-Crebit-Environment: sandbox" \
-H "X-Crebit-Acting-As-Partner-Id: 8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b"{
"id": "22222222-2222-4222-8222-222222222222",
"status": "created",
"locked_rate": "5.4200",
"market_rate": "5.4180",
"cip_forward": null,
"strike_mode": "live_spot",
"target_strike": null,
"strike_advantage_bps": 0,
"provider_extra_spread": null,
"premium_amount": "565.00",
"deposit_amount": "5000.00",
"total_amount": "5565.00",
"amount_due": "5565.00",
"collateral_amount": "5000.00",
"upfront_fee": "565.00",
"pricing_tier": "ml_full",
"pricing_greeks": {
"delta": 0.42,
"gamma": 0.01
},
"confidence_score": null,
"window_start": "2026-11-02T00:00:00Z",
"window_end": "2026-11-09T00:00:00Z",
"chain": "solana",
"source_chain": null,
"settlement_currency": "USDC",
"payout_wallet_address": "EndUserSettlementWa11et1111111111111111111",
"oracle": "redstone",
"expires_at": "2026-09-28T14:16:30Z",
"created_at": "2026-09-28T14:15:00Z",
"on_behalf_of_partner_id": null,
"on_behalf_of_partner_name": null
}List the member's quotes, newest first. Filters: status (created, which includes accepted quotes, or failed, which includes expired ones), customer_reference_id, limit (1–100, default 25), cursor.
curl -sS -X GET "https://lock-apis-sandbox.crebitpay.com/api/v1/fx/quotes?customer_reference_id=member-cust-0042&limit=25" \
-H "X-Crebit-Key-Id: ADMIN_KEY_ID" \
-H "X-Crebit-Key-Secret: ADMIN_KEY_SECRET" \
-H "X-Crebit-Environment: sandbox" \
-H "X-Crebit-Acting-As-Partner-Id: 8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b"{
"items": [
{
"id": "22222222-2222-4222-8222-222222222222",
"status": "created",
"locked_rate": "5.4200",
"market_rate": "5.4180",
"cip_forward": null,
"strike_mode": "live_spot",
"target_strike": null,
"strike_advantage_bps": 0,
"provider_extra_spread": null,
"premium_amount": "565.00",
"deposit_amount": "5000.00",
"total_amount": "5565.00",
"amount_due": "5565.00",
"collateral_amount": "5000.00",
"upfront_fee": "565.00",
"pricing_tier": "ml_full",
"pricing_greeks": {
"delta": 0.42,
"gamma": 0.01
},
"confidence_score": null,
"window_start": "2026-11-02T00:00:00Z",
"window_end": "2026-11-09T00:00:00Z",
"chain": "solana",
"source_chain": null,
"settlement_currency": "USDC",
"payout_wallet_address": "EndUserSettlementWa11et1111111111111111111",
"oracle": "redstone",
"expires_at": "2026-09-28T14:16:30Z",
"created_at": "2026-09-28T14:15:00Z",
"on_behalf_of_partner_id": null,
"on_behalf_of_partner_name": null
}
],
"next_cursor": null
}4. Contract
Lock the quote into a contract. The quote must be created and not expired; it becomes accepted in the same step. The payout destination fields are optional here and can be set later (see Payout destination), but a forward needs one before maturity.
curl -sS -X POST "https://lock-apis-sandbox.crebitpay.com/api/v1/fx/contracts" \
-H "Content-Type: application/json" \
-H "X-Crebit-Key-Id: ADMIN_KEY_ID" \
-H "X-Crebit-Key-Secret: ADMIN_KEY_SECRET" \
-H "X-Crebit-Environment: sandbox" \
-H "X-Crebit-Acting-As-Partner-Id: 8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"quote_id":"22222222-2222-4222-8222-222222222222","partner_transaction_reference":"member-tx-9901","payout_wallet_address":"EndUserSettlementWa11et1111111111111111111","payout_currency":"USDC","payout_chain":"solana"}'{
"id": "33333333-3333-4333-8333-333333333333",
"crebit_contract_reference": "CREBIT-20260928-7F3A9C2B1D",
"locked_rate": "5.4200",
"provider_rate_at_lock": "5.4200",
"market_rate_at_lock": "5.4180",
"premium_amount": "565.00",
"deposit_amount": "5000.00",
"total_amount": "5565.00",
"window_start": "2026-11-02T00:00:00Z",
"window_end": "2026-11-09T00:00:00Z",
"chain": "solana",
"source_chain": null,
"settlement_currency": "USDC",
"funding_wallet_address": "CrebitFundingReceiver1111111111111111111111",
"payout_wallet_address": "EndUserSettlementWa11et1111111111111111111",
"payout_currency": "USDC",
"payout_chain": "solana",
"oracle": "redstone",
"created_at": "2026-09-28T14:16:00Z",
"max_transaction_amount": "50000.00",
"contract_type": "forward",
"direction": "USD_TO_BRL",
"notional_currency": "USD",
"on_behalf_of_partner_id": null,
"on_behalf_of_partner_name": null
}- The contract starts in
quote_created. Send premium (and deposit, for a forward) tofunding_wallet_address. partner_transaction_referenceis optional; Crebit assigns a UUID when omitted. It must be unique among the member's in-flight contracts.on_behalf_of_partner_idis only an audit label and unrelated to acting-as. Leave it out.
5. Fund the Contract (funds_in_route)
After sending stablecoins to funding_wallet_address, notify Crebit with an inbound webhook. Idempotency-Key is required: a replay with the same key and body returns the original result; the same key with a different body returns 409 IDEMPOTENCY_CONFLICT.
- Option: one webhook with
payment_type: "premium"activates it. - Forward: needs premium and deposit. Send two webhooks (
premium, thendeposit; the contract staysfunds_in_routein between) or a single transfer withpayment_type: "combined"for premium + deposit. payment_type,amount,currencyandchainmust be sent together. With atransaction_hash, Crebit verifies the transfer on chain.
curl -sS -X POST "https://lock-apis-sandbox.crebitpay.com/api/v1/fx/webhooks/inbound" \
-H "Content-Type: application/json" \
-H "X-Crebit-Key-Id: ADMIN_KEY_ID" \
-H "X-Crebit-Key-Secret: ADMIN_KEY_SECRET" \
-H "X-Crebit-Environment: sandbox" \
-H "X-Crebit-Acting-As-Partner-Id: 8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b" \
-H "X-Crebit-Timestamp: TIMESTAMP" \
-H "X-Crebit-Signature: t=TIMESTAMP,v1=HMAC_SHA256_HEX" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"event_type":"funds_in_route","fx_contract_id":"33333333-3333-4333-8333-333333333333","payment_type":"premium","amount":"565.00","currency":"USDC","chain":"solana","transaction_hash":"5h3kQ9xVb2mT8pLr4sNw7yZc1dFg6jHa","source_wallet_address":"MemberTreasuryWa11et11111111111111111111111"}'{
"webhook_event_id": "44444444-4444-4444-8444-444444444444",
"status": "processed"
}Single transfer for a forward (premium + deposit):
{
"event_type": "funds_in_route",
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"payment_type": "combined",
"amount": "5565.00",
"currency": "USDC",
"chain": "solana",
"transaction_hash": "5h3kQ9xVb2mT8pLr4sNw7yZc1dFg6jHa",
"source_wallet_address": "MemberTreasuryWa11et11111111111111111111111"
}funds_in_route and contract_exercised) sent on behalf of a member run as the member, so Crebit verifies X-Crebit-Signature and X-Crebit-Timestamp with the member'swebhook signing secret, not yours. In production the signature is mandatory, and today there is no way for an organization admin to obtain a member's signing secret through the API. Crebit is working on a fix. Until then, contact Crebit before you send inbound webhooks for a member in production so signing can be arranged. In sandbox, unsigned inbound webhooks are accepted. If the member has no active webhook endpoint in that environment, signed calls fail with 401 INVALID_SIGNATURE. See Signatures and retries for how the signature is computed.If Crebit rejects the event on a business rule (wrong amount, currency, chain, or status), it returns 400 INVALID_ARGUMENT and the contract may move to failed (see Retry a failed contract).
6. Track Status
Poll the lightweight status. The response carries an ETag; send it back as If-None-Match to get 304 when nothing changed.
curl -sS -X GET "https://lock-apis-sandbox.crebitpay.com/api/v1/fx/contracts/33333333-3333-4333-8333-333333333333/status" \
-H "X-Crebit-Key-Id: ADMIN_KEY_ID" \
-H "X-Crebit-Key-Secret: ADMIN_KEY_SECRET" \
-H "X-Crebit-Environment: sandbox" \
-H "X-Crebit-Acting-As-Partner-Id: 8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b"{
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"crebit_contract_reference": "CREBIT-20260928-7F3A9C2B1D",
"status": "active",
"partner_transaction_reference": "member-tx-9901",
"activated_at": "2026-09-28T14:35:08Z",
"exercised_at": null,
"settled_at": null,
"expired_at": null,
"failed_at": null,
"failure_reason": null,
"updated_at": "2026-09-28T14:35:08Z",
"open_margin_call": null
}Or poll by crebit_contract_reference. Same body and ETag behaviour:
curl -sS -X GET "https://lock-apis-sandbox.crebitpay.com/api/v1/fx/contracts/by-reference/CREBIT-20260928-7F3A9C2B1D" \
-H "X-Crebit-Key-Id: ADMIN_KEY_ID" \
-H "X-Crebit-Key-Secret: ADMIN_KEY_SECRET" \
-H "X-Crebit-Environment: sandbox" \
-H "X-Crebit-Acting-As-Partner-Id: 8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b"{
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"crebit_contract_reference": "CREBIT-20260928-7F3A9C2B1D",
"status": "active",
"partner_transaction_reference": "member-tx-9901",
"activated_at": "2026-09-28T14:35:08Z",
"exercised_at": null,
"settled_at": null,
"expired_at": null,
"failed_at": null,
"failure_reason": null,
"updated_at": "2026-09-28T14:35:08Z",
"open_margin_call": null
}Full contract detail (same body as create):
curl -sS -X GET "https://lock-apis-sandbox.crebitpay.com/api/v1/fx/contracts/33333333-3333-4333-8333-333333333333" \
-H "X-Crebit-Key-Id: ADMIN_KEY_ID" \
-H "X-Crebit-Key-Secret: ADMIN_KEY_SECRET" \
-H "X-Crebit-Environment: sandbox" \
-H "X-Crebit-Acting-As-Partner-Id: 8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b"{
"id": "33333333-3333-4333-8333-333333333333",
"crebit_contract_reference": "CREBIT-20260928-7F3A9C2B1D",
"locked_rate": "5.4200",
"provider_rate_at_lock": "5.4200",
"market_rate_at_lock": "5.4180",
"premium_amount": "565.00",
"deposit_amount": "5000.00",
"total_amount": "5565.00",
"window_start": "2026-11-02T00:00:00Z",
"window_end": "2026-11-09T00:00:00Z",
"chain": "solana",
"source_chain": null,
"settlement_currency": "USDC",
"funding_wallet_address": "CrebitFundingReceiver1111111111111111111111",
"payout_wallet_address": "EndUserSettlementWa11et1111111111111111111",
"payout_currency": "USDC",
"payout_chain": "solana",
"oracle": "redstone",
"created_at": "2026-09-28T14:16:00Z",
"max_transaction_amount": "50000.00",
"contract_type": "forward",
"direction": "USD_TO_BRL",
"notional_currency": "USD",
"on_behalf_of_partner_id": null,
"on_behalf_of_partner_name": null
}List the member's contracts, newest first. Filters: status, customer_reference_id, limit (1–100, default 25), cursor.
curl -sS -X GET "https://lock-apis-sandbox.crebitpay.com/api/v1/fx/contracts?status=active&limit=25" \
-H "X-Crebit-Key-Id: ADMIN_KEY_ID" \
-H "X-Crebit-Key-Secret: ADMIN_KEY_SECRET" \
-H "X-Crebit-Environment: sandbox" \
-H "X-Crebit-Acting-As-Partner-Id: 8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b"{
"items": [
{
"id": "33333333-3333-4333-8333-333333333333",
"crebit_contract_reference": "CREBIT-20260928-7F3A9C2B1D",
"locked_rate": "5.4200",
"provider_rate_at_lock": "5.4200",
"market_rate_at_lock": "5.4180",
"premium_amount": "565.00",
"deposit_amount": "5000.00",
"total_amount": "5565.00",
"window_start": "2026-11-02T00:00:00Z",
"window_end": "2026-11-09T00:00:00Z",
"chain": "solana",
"source_chain": null,
"settlement_currency": "USDC",
"funding_wallet_address": "CrebitFundingReceiver1111111111111111111111",
"payout_wallet_address": "EndUserSettlementWa11et1111111111111111111",
"payout_currency": "USDC",
"payout_chain": "solana",
"oracle": "redstone",
"created_at": "2026-09-28T14:16:00Z",
"max_transaction_amount": "50000.00",
"contract_type": "forward",
"direction": "USD_TO_BRL",
"notional_currency": "USD",
"on_behalf_of_partner_id": null,
"on_behalf_of_partner_name": null,
"status": "active",
"quote_id": "22222222-2222-4222-8222-222222222222",
"customer_reference_id": "member-cust-0042",
"partner_transaction_reference": "member-tx-9901",
"open_margin_call": null
}
],
"next_cursor": null
}Locks for one customer reference, newest first. Filters: status, limit (1–100, default 25), cursor. Same item shape as the contract list.
curl -sS -X GET "https://lock-apis-sandbox.crebitpay.com/api/v1/fx/customers/member-cust-0042/locks?limit=25" \
-H "X-Crebit-Key-Id: ADMIN_KEY_ID" \
-H "X-Crebit-Key-Secret: ADMIN_KEY_SECRET" \
-H "X-Crebit-Environment: sandbox" \
-H "X-Crebit-Acting-As-Partner-Id: 8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b"{
"items": [
{
"id": "33333333-3333-4333-8333-333333333333",
"crebit_contract_reference": "CREBIT-20260928-7F3A9C2B1D",
"locked_rate": "5.4200",
"provider_rate_at_lock": "5.4200",
"market_rate_at_lock": "5.4180",
"premium_amount": "565.00",
"deposit_amount": "5000.00",
"total_amount": "5565.00",
"window_start": "2026-11-02T00:00:00Z",
"window_end": "2026-11-09T00:00:00Z",
"chain": "solana",
"source_chain": null,
"settlement_currency": "USDC",
"funding_wallet_address": "CrebitFundingReceiver1111111111111111111111",
"payout_wallet_address": "EndUserSettlementWa11et1111111111111111111",
"payout_currency": "USDC",
"payout_chain": "solana",
"oracle": "redstone",
"created_at": "2026-09-28T14:16:00Z",
"max_transaction_amount": "50000.00",
"contract_type": "forward",
"direction": "USD_TO_BRL",
"notional_currency": "USD",
"on_behalf_of_partner_id": null,
"on_behalf_of_partner_name": null,
"status": "active",
"quote_id": "22222222-2222-4222-8222-222222222222",
"customer_reference_id": "member-cust-0042",
"partner_transaction_reference": "member-tx-9901",
"open_margin_call": null
}
],
"next_cursor": null
}Contract Lifecycle
| Status | Meaning | Next |
|---|---|---|
| quote_created | Contract locked, waiting for funding | funds_in_route, expired, failed |
| funds_in_route | Funding reported, not yet complete (e.g. forward premium only) | active, failed |
| active | Fully funded; execution window running | exercised, expired, failed, defaulted |
| exercised | Exercise accepted; payout in progress | settled, failed |
| settled | Payout done (terminal) | — |
| expired | Window ended without exercise (options, unfunded contracts) | settled (forward deposit forfeiture completion) |
| failed | Rejected or failed; can be recovered | quote_created, funds_in_route, active, exercised |
| defaulted | Forward closed after an unpaid margin call | deposit_forfeited |
| deposit_forfeited | Deposit kept after default (terminal) | — |
An open margin call does not change the status: the contract stays active and open_margin_call is set on status and list responses.
Payout Destination
Save or change where the settlement payout goes, any time before maturity while the contract is quote_created, funds_in_route or active. payout_currency and payout_chain default to the quote's settlement currency and chain. A forward without a saved destination is held at maturity instead of auto-exercising.
curl -sS -X PUT "https://lock-apis-sandbox.crebitpay.com/api/v1/fx/contracts/33333333-3333-4333-8333-333333333333/payout-destination" \
-H "Content-Type: application/json" \
-H "X-Crebit-Key-Id: ADMIN_KEY_ID" \
-H "X-Crebit-Key-Secret: ADMIN_KEY_SECRET" \
-H "X-Crebit-Environment: sandbox" \
-H "X-Crebit-Acting-As-Partner-Id: 8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b" \
-d '{"payout_wallet_address":"EndUserSettlementWa11et1111111111111111111","payout_currency":"USDC","payout_chain":"solana"}'{
"id": "33333333-3333-4333-8333-333333333333",
"crebit_contract_reference": "CREBIT-20260928-7F3A9C2B1D",
"locked_rate": "5.4200",
"provider_rate_at_lock": "5.4200",
"market_rate_at_lock": "5.4180",
"premium_amount": "565.00",
"deposit_amount": "5000.00",
"total_amount": "5565.00",
"window_start": "2026-11-02T00:00:00Z",
"window_end": "2026-11-09T00:00:00Z",
"chain": "solana",
"source_chain": null,
"settlement_currency": "USDC",
"funding_wallet_address": "CrebitFundingReceiver1111111111111111111111",
"payout_wallet_address": "EndUserSettlementWa11et1111111111111111111",
"payout_currency": "USDC",
"payout_chain": "solana",
"oracle": "redstone",
"created_at": "2026-09-28T14:16:00Z",
"max_transaction_amount": "50000.00",
"contract_type": "forward",
"direction": "USD_TO_BRL",
"notional_currency": "USD",
"on_behalf_of_partner_id": null,
"on_behalf_of_partner_name": null
}7. Settlement Preview
Read-only payout math using the same oracle and clamp logic as contract_exercised. Requires an active (or exercised / settled) contract; nothing changes.
curl -sS -X POST "https://lock-apis-sandbox.crebitpay.com/api/v1/fx/contracts/33333333-3333-4333-8333-333333333333/settlement-preview" \
-H "Content-Type: application/json" \
-H "X-Crebit-Key-Id: ADMIN_KEY_ID" \
-H "X-Crebit-Key-Secret: ADMIN_KEY_SECRET" \
-H "X-Crebit-Environment: sandbox" \
-H "X-Crebit-Acting-As-Partner-Id: 8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b" \
-d '{"live_execution_rate":"5.5100","transaction_amount":"50000.00","payout_currency":"USDC"}'{
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"payout_amount": "4183.30",
"payout_currency": "USDC",
"is_favorable": false,
"partner_live_execution_rate": "5.5100",
"oracle_live_execution_rate": "5.5080",
"oracle_source": "redstone",
"settlement_rate_used": "5.5100",
"oracle_clamp_applied": false,
"formula": "max(0, deposit + (transaction_amount * (locked_rate - live_rate) / live_rate))",
"calculation_version": "2026.05.1"
}8. Exercise (contract_exercised)
When the customer transacts inside the execution window, send contract_exercised. Crebit computes the FX delta against live_execution_rate (clamped by the oracle), pays out and settles the contract.
- Crebit checks the execution window against the time it receives the webhook (server clock), not
executed_at. transaction_amountdefaults to the full notional.payout_wallet_addressoverrides the saved destination; omit it to use the one on the contract.payout_currencyandchainare required.- Forwards that are still
activeat window end are exercised automatically at full notional with the Crebit oracle rate, if a payout destination is saved.
curl -sS -X POST "https://lock-apis-sandbox.crebitpay.com/api/v1/fx/webhooks/inbound" \
-H "Content-Type: application/json" \
-H "X-Crebit-Key-Id: ADMIN_KEY_ID" \
-H "X-Crebit-Key-Secret: ADMIN_KEY_SECRET" \
-H "X-Crebit-Environment: sandbox" \
-H "X-Crebit-Acting-As-Partner-Id: 8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b" \
-H "X-Crebit-Timestamp: TIMESTAMP" \
-H "X-Crebit-Signature: t=TIMESTAMP,v1=HMAC_SHA256_HEX" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"event_type":"contract_exercised","fx_contract_id":"33333333-3333-4333-8333-333333333333","executed_at":"2026-11-05T13:42:00Z","live_execution_rate":"5.5100","transaction_amount":"50000.00","payout_wallet_address":"EndUserSettlementWa11et1111111111111111111","payout_currency":"USDC","chain":"solana"}'{
"webhook_event_id": "44444444-4444-4444-8444-444444444444",
"status": "processed"
}Then expect payout_success and contract_settledon the member's webhook endpoint, or poll status until settled.
Payouts, Payments, Deposits
Payouts
Payout rows for the contract, oldest first. Status: pending, submitted, confirmed, failed, retrying. Failed payouts are retried by Crebit (see payout_failed.retry_planned); there is no partner endpoint to retry a payout.
curl -sS -X GET "https://lock-apis-sandbox.crebitpay.com/api/v1/fx/contracts/33333333-3333-4333-8333-333333333333/payouts" \
-H "X-Crebit-Key-Id: ADMIN_KEY_ID" \
-H "X-Crebit-Key-Secret: ADMIN_KEY_SECRET" \
-H "X-Crebit-Environment: sandbox" \
-H "X-Crebit-Acting-As-Partner-Id: 8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b"{
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"payouts": [
{
"id": "99999999-9999-4999-8999-999999999999",
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"amount": "4183.30",
"currency": "USDC",
"chain": "solana",
"status": "confirmed",
"transaction_hash": "3xPayoutTxSignature111111111111",
"payout_wallet_address": "EndUserSettlementWa11et1111111111111111111",
"failure_reason": null,
"created_at": "2026-11-05T13:42:30Z",
"submitted_at": "2026-11-05T13:42:45Z",
"confirmed_at": "2026-11-05T13:43:08Z",
"failed_at": null
}
]
}Payment Legs
Premium and deposit legs with status expected, funds_in_route, confirmed or failed.
curl -sS -X GET "https://lock-apis-sandbox.crebitpay.com/api/v1/fx/contracts/33333333-3333-4333-8333-333333333333/payments" \
-H "X-Crebit-Key-Id: ADMIN_KEY_ID" \
-H "X-Crebit-Key-Secret: ADMIN_KEY_SECRET" \
-H "X-Crebit-Environment: sandbox" \
-H "X-Crebit-Acting-As-Partner-Id: 8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b"{
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"contract_type": "forward",
"premium_amount": "565.00",
"deposit_amount": "5000.00",
"payments": [
{
"id": "77777777-7777-4777-8777-777777777771",
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"payment_type": "premium",
"amount": "565.00",
"currency": "USDC",
"chain": "solana",
"status": "confirmed",
"webhook_event_id": "44444444-4444-4444-8444-444444444444",
"wallet_address": "MemberTreasuryWa11et11111111111111111111111",
"transaction_hash": "5h3kQ9xVb2mT8pLr4sNw7yZc1dFg6jHa",
"created_at": "2026-09-28T14:16:00Z",
"confirmed_at": "2026-09-28T14:35:08Z"
},
{
"id": "77777777-7777-4777-8777-777777777772",
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"payment_type": "deposit",
"amount": "5000.00",
"currency": "USDC",
"chain": "solana",
"status": "confirmed",
"webhook_event_id": "44444444-4444-4444-8444-444444444445",
"wallet_address": "MemberTreasuryWa11et11111111111111111111111",
"transaction_hash": "4DepositTxSignature11111111111",
"created_at": "2026-09-28T14:16:00Z",
"confirmed_at": "2026-09-28T14:35:08Z"
}
]
}Deposit Movements (Forwards)
Deposit history: collected, released or forfeited. Options return an empty list.
curl -sS -X GET "https://lock-apis-sandbox.crebitpay.com/api/v1/fx/contracts/33333333-3333-4333-8333-333333333333/deposits" \
-H "X-Crebit-Key-Id: ADMIN_KEY_ID" \
-H "X-Crebit-Key-Secret: ADMIN_KEY_SECRET" \
-H "X-Crebit-Environment: sandbox" \
-H "X-Crebit-Acting-As-Partner-Id: 8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b"{
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"contract_type": "forward",
"deposit_amount": "5000.00",
"movements": [
{
"id": "88888888-8888-4888-8888-888888888888",
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"movement_type": "collected",
"amount": "5000.00",
"currency": "USDC",
"source": "deposit_payment",
"reason": null,
"contract_payment_id": "77777777-7777-4777-8777-777777777772",
"webhook_event_id": "44444444-4444-4444-8444-444444444445",
"payout_id": null,
"recorded_at": "2026-09-28T14:35:08Z"
}
]
}Retry a Failed Contract
Move a failed contract back into the lifecycle. Confirmed premium and deposit legs are kept. target_status is optional (quote_created, funds_in_route, active, exercised); when omitted Crebit picks a safe status. Returns the status body.
curl -sS -X POST "https://lock-apis-sandbox.crebitpay.com/api/v1/fx/contracts/33333333-3333-4333-8333-333333333333/retry" \
-H "Content-Type: application/json" \
-H "X-Crebit-Key-Id: ADMIN_KEY_ID" \
-H "X-Crebit-Key-Secret: ADMIN_KEY_SECRET" \
-H "X-Crebit-Environment: sandbox" \
-H "X-Crebit-Acting-As-Partner-Id: 8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b" \
-d '{"target_status":"active"}'{
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"crebit_contract_reference": "CREBIT-20260928-7F3A9C2B1D",
"status": "active",
"partner_transaction_reference": "member-tx-9901",
"activated_at": "2026-09-28T14:35:08Z",
"exercised_at": null,
"settled_at": null,
"expired_at": null,
"failed_at": null,
"failure_reason": null,
"updated_at": "2026-09-28T14:35:08Z",
"open_margin_call": null
}Margin Calls
Crebit can issue a margin call on an active forward when the rate moves against the lock. The member must send amount_due to funding_wallet_address on the given chain before due_at and report the transfer. If it stays unpaid after due_at, the contract goes defaulted then deposit_forfeited and the call becomes unpaid_closed. Margin call status: issued, paid, unpaid_closed.
List Margin Calls
curl -sS -X GET "https://lock-apis-sandbox.crebitpay.com/api/v1/fx/contracts/33333333-3333-4333-8333-333333333333/margin-calls" \
-H "X-Crebit-Key-Id: ADMIN_KEY_ID" \
-H "X-Crebit-Key-Secret: ADMIN_KEY_SECRET" \
-H "X-Crebit-Environment: sandbox" \
-H "X-Crebit-Acting-As-Partner-Id: 8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b"{
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"items": [
{
"margin_call_id": "abababab-1111-4222-8333-444444444444",
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"status": "issued",
"amount_due": "1200.00",
"currency": "USDC",
"chain": "solana",
"due_at": "2026-10-15T22:00:00Z",
"issued_at": "2026-10-14T14:00:00Z",
"paid_at": null,
"closed_at": null,
"transaction_hash": null,
"funding_wallet_address": "CrebitFundingReceiver1111111111111111111111",
"funding_deposit_event_id": null
}
]
}Get the Open Margin Call
Returns the issued call, or 404 margin_call_not_found when there is none.
curl -sS -X GET "https://lock-apis-sandbox.crebitpay.com/api/v1/fx/contracts/33333333-3333-4333-8333-333333333333/margin-calls/open" \
-H "X-Crebit-Key-Id: ADMIN_KEY_ID" \
-H "X-Crebit-Key-Secret: ADMIN_KEY_SECRET" \
-H "X-Crebit-Environment: sandbox" \
-H "X-Crebit-Acting-As-Partner-Id: 8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b"{
"margin_call_id": "abababab-1111-4222-8333-444444444444",
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"status": "issued",
"amount_due": "1200.00",
"currency": "USDC",
"chain": "solana",
"due_at": "2026-10-15T22:00:00Z",
"issued_at": "2026-10-14T14:00:00Z",
"paid_at": null,
"closed_at": null,
"transaction_hash": null,
"funding_wallet_address": "CrebitFundingReceiver1111111111111111111111",
"funding_deposit_event_id": null
}Report the Payment
After the on-chain transfer, report its hash. Crebit verifies the transfer. Idempotency-Key is optional and recommended. Reporting the same hash again returns already_paid: true; a different hash on a paid call returns 400 margin_call_already_paid.
curl -sS -X POST "https://lock-apis-sandbox.crebitpay.com/api/v1/fx/contracts/33333333-3333-4333-8333-333333333333/margin-calls/abababab-1111-4222-8333-444444444444/payment" \
-H "Content-Type: application/json" \
-H "X-Crebit-Key-Id: ADMIN_KEY_ID" \
-H "X-Crebit-Key-Secret: ADMIN_KEY_SECRET" \
-H "X-Crebit-Environment: sandbox" \
-H "X-Crebit-Acting-As-Partner-Id: 8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"transaction_hash":"2MarginTopUpTxSignature11111111","source_wallet_address":"MemberTreasuryWa11et11111111111111111111111"}'{
"margin_call_id": "abababab-1111-4222-8333-444444444444",
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"status": "paid",
"amount_due": "1200.00",
"currency": "USDC",
"chain": "solana",
"transaction_hash": "2MarginTopUpTxSignature11111111",
"funding_deposit_event_id": "cdcdcdcd-1111-4222-8333-444444444444",
"deposit_movement_id": "efefefef-1111-4222-8333-444444444444",
"already_paid": false,
"paid_at": "2026-10-14T18:05:00Z"
}Outbound Webhooks
Crebit POSTs these events for contracts you created as a member to the member'sactive webhook endpoint for that environment. You can't register or change a member's endpoint with acting-as: the member sets it in its partner portal, or Crebit configures it. If the member has no active endpoint, events are recorded but not delivered to the member; you can still read them in the webhook event log.
To receive these events yourself, enable member webhooks. Every event of every active member is then also delivered to the webhook endpoint on your own admin account, signed with your signing secret. The copy has the same body except subject, which is "relationship": "organisation_member"with the member's partner_id and partner_name. The examples below show the member's own delivery ("relationship": "self").
| event_type | When it fires |
|---|---|
| payout_success | A settlement payout is confirmed on chain (before contract_settled) |
| payout_failed | A payout attempt failed; retry_planned says whether Crebit retries |
| payout_transaction_hash_corrected | Crebit corrected the on-chain transaction hash of a confirmed payout; update any stored payout proof |
| contract_settled | Contract moved exercised → settled after payouts complete |
| contract_expired | Window passed without exercise; forwards include deposit_outcome (forfeited) |
| margin_call_issued | A margin call was issued on an active forward |
| margin_call_paid | The margin call payment was verified |
| margin_call_unpaid_closed | Unpaid after due_at; contract defaulted and deposit forfeited |
payout_success
{
"event_type": "payout_success",
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"payout_id": "99999999-9999-4999-8999-999999999999",
"amount": "4183.30",
"currency": "USDC",
"chain": "solana",
"transaction_hash": "3xPayoutTxSignature111111111111",
"status": "confirmed",
"timestamp": "2026-11-05T13:43:08Z",
"crebit_contract_reference": "CREBIT-20260928-7F3A9C2B1D",
"partner_transaction_reference": "member-tx-9901",
"payout_wallet_address": "EndUserSettlementWa11et1111111111111111111",
"transaction_explorer_url": "https://solscan.io/tx/3xPayoutTxSignature111111111111",
"settlement_rate_used": "5.5100",
"oracle_clamp_applied": false,
"subject": {
"relationship": "self",
"partner_id": "8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b",
"partner_name": "Member Co",
"organisation_id": null,
"organisation_name": null
}
}payout_failed
{
"event_type": "payout_failed",
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"payout_id": "99999999-9999-4999-8999-999999999999",
"reason": "destination_wallet_unreachable",
"crebit_contract_reference": "CREBIT-20260928-7F3A9C2B1D",
"partner_transaction_reference": "member-tx-9901",
"retry_planned": true,
"retry_count": 1,
"timestamp": "2026-11-05T13:44:05Z",
"subject": {
"relationship": "self",
"partner_id": "8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b",
"partner_name": "Member Co",
"organisation_id": null,
"organisation_name": null
}
}payout_transaction_hash_corrected
Sent at most once per payout, with the previous and corrected hash. transaction_explorer_url is omitted when not available.
{
"event_type": "payout_transaction_hash_corrected",
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"payout_id": "99999999-9999-4999-8999-999999999999",
"previous_transaction_hash": "3xPayoutTxSignature111111111111",
"transaction_hash": "3yCorrectedPayoutTxSignature11111",
"chain": "solana",
"currency": "USDC",
"operator_id": "ops-7",
"reason": "Explorer showed a different confirmed signature for this payout",
"transaction_explorer_url": "https://solscan.io/tx/3yCorrectedPayoutTxSignature11111",
"subject": {
"relationship": "self",
"partner_id": "8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b",
"partner_name": "Member Co",
"organisation_id": null,
"organisation_name": null
}
}contract_settled
{
"event_type": "contract_settled",
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"crebit_contract_reference": "CREBIT-20260928-7F3A9C2B1D",
"settled_at": "2026-11-05T13:43:12Z",
"settlement_status": "settled",
"partner_transaction_reference": "member-tx-9901",
"payout_id": "99999999-9999-4999-8999-999999999999",
"payout_amount": "4183.30",
"payout_currency": "USDC",
"chain": "solana",
"transaction_hash": "3xPayoutTxSignature111111111111",
"settlement_rate_used": "5.5100",
"oracle_clamp_applied": false,
"subject": {
"relationship": "self",
"partner_id": "8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b",
"partner_name": "Member Co",
"organisation_id": null,
"organisation_name": null
}
}contract_expired
Options omit deposit_outcome.
{
"event_id": "contract_expired:33333333-3333-4333-8333-333333333333",
"event_type": "contract_expired",
"delivered_at": "2026-11-09T00:01:30Z",
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"crebit_contract_reference": "CREBIT-20260928-7F3A9C2B1D",
"partner_transaction_reference": "member-tx-9901",
"contract": {
"contract_type": "forward",
"expired_at": "2026-11-09T00:00:00Z"
},
"deposit_outcome": {
"status": "forfeited",
"amount": "5000.00",
"currency": "USDC",
"chain": "solana",
"forfeited_at": "2026-11-09T00:00:00Z"
},
"subject": {
"relationship": "self",
"partner_id": "8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b",
"partner_name": "Member Co",
"organisation_id": null,
"organisation_name": null
}
}margin_call_issued
{
"event_type": "margin_call_issued",
"margin_call_id": "abababab-1111-4222-8333-444444444444",
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"crebit_contract_reference": "CREBIT-20260928-7F3A9C2B1D",
"status": "issued",
"amount_due": "1200.00",
"currency": "USDC",
"chain": "solana",
"issued_at": "2026-10-14T14:00:00Z",
"due_at": "2026-10-15T22:00:00Z",
"delivered_at": "2026-10-14T14:00:05Z",
"partner_transaction_reference": "member-tx-9901",
"subject": {
"relationship": "self",
"partner_id": "8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b",
"partner_name": "Member Co",
"organisation_id": null,
"organisation_name": null
}
}margin_call_paid
{
"event_type": "margin_call_paid",
"margin_call_id": "abababab-1111-4222-8333-444444444444",
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"crebit_contract_reference": "CREBIT-20260928-7F3A9C2B1D",
"status": "paid",
"amount_due": "1200.00",
"currency": "USDC",
"chain": "solana",
"issued_at": "2026-10-14T14:00:00Z",
"due_at": "2026-10-15T22:00:00Z",
"delivered_at": "2026-10-14T18:05:10Z",
"partner_transaction_reference": "member-tx-9901",
"subject": {
"relationship": "self",
"partner_id": "8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b",
"partner_name": "Member Co",
"organisation_id": null,
"organisation_name": null
},
"paid_at": "2026-10-14T18:05:00Z",
"transaction_hash": "2MarginTopUpTxSignature11111111"
}margin_call_unpaid_closed
{
"event_type": "margin_call_unpaid_closed",
"margin_call_id": "abababab-1111-4222-8333-444444444444",
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"crebit_contract_reference": "CREBIT-20260928-7F3A9C2B1D",
"status": "unpaid_closed",
"amount_due": "1200.00",
"currency": "USDC",
"chain": "solana",
"issued_at": "2026-10-14T14:00:00Z",
"due_at": "2026-10-15T22:00:00Z",
"delivered_at": "2026-10-15T22:01:00Z",
"partner_transaction_reference": "member-tx-9901",
"subject": {
"relationship": "self",
"partner_id": "8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b",
"partner_name": "Member Co",
"organisation_id": null,
"organisation_name": null
},
"closed_at": "2026-10-15T22:00:40Z",
"contract_status": "deposit_forfeited",
"deposit_forfeited": true
}Optional fields (partner_transaction_reference, transaction_explorer_url, payout proof on contract_settled, margin call paid_at / closed_at / transaction_hash) are omitted when not set.
Signatures and Retries
Outbound (Crebit to Member)
| Header | Value |
|---|---|
| X-Crebit-Signature | t=<unix seconds>,v1=<hex HMAC-SHA256> |
| X-Crebit-Timestamp | Same unix timestamp as t |
| X-Crebit-Event-Id | Webhook event id (stable across retries) |
| X-Crebit-Idempotency-Key | e.g. payout_success:<payout_id>; dedupe on this. Copies sent to you use org-member:{organisation_id}:{original key} |
| X-Crebit-Subject-Relationship | self or organisation_member (not signed; mirrors subject.relationship) |
| X-Crebit-Subject-Partner-Id | Partner the event belongs to (not signed; mirrors subject.partner_id) |
The signature is HMAC-SHA256 over {timestamp}.{raw_body} keyed with the receiving endpoint's signing secret: the member's for its own deliveries, yours for copies sent to you. Verify against the raw bytes and reject timestamps older than 5 minutes.
import crypto from "node:crypto";
// rawBody: the exact request body bytes (do not re-serialize the JSON).
export function verifyCrebitWebhook(rawBody, signatureHeader, signingSecret) {
const match = /^t=(\d+),v1=([0-9a-f]{64})$/i.exec(signatureHeader ?? "");
if (!match) return false;
const [, timestamp, received] = match;
if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false;
const expected = crypto
.createHmac("sha256", signingSecret)
.update(`${timestamp}.${rawBody}`)
.digest("hex");
return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(received.toLowerCase()));
}- Reply with any 2xx within 15 seconds. Other responses and timeouts are retried with exponential backoff (30 s doubling, capped at 1 hour, with jitter) up to 8 attempts, then marked
failed. Crebit can re-queue failed events. - Deliveries can repeat: make your handler idempotent.
Inbound (You to Crebit)
Sign POST /api/v1/fx/webhooks/inbound the same way with the member's signing secret: HMAC-SHA256 over {timestamp}.{canonical_json}, where the canonical JSON is the payload with keys sorted, no whitespace and null fields left out. Send X-Crebit-Signature: t=<timestamp>,v1=<hex> and X-Crebit-Timestamp: <timestamp> (unix seconds, 5-minute tolerance). Required in production; in sandbox, verified whenever you send the headers.
Webhook Event Log
Incoming and outgoing webhook events for the member, with delivery status and payload. Filters: direction (incoming | outgoing), fx_contract_id, limit, cursor.
curl -sS -X GET "https://lock-apis-sandbox.crebitpay.com/api/v1/fx/webhook-events?direction=outgoing&fx_contract_id=33333333-3333-4333-8333-333333333333" \
-H "X-Crebit-Key-Id: ADMIN_KEY_ID" \
-H "X-Crebit-Key-Secret: ADMIN_KEY_SECRET" \
-H "X-Crebit-Environment: sandbox" \
-H "X-Crebit-Acting-As-Partner-Id: 8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b"{
"items": [
{
"id": "55555555-5555-4555-8555-555555555556",
"partner_id": "8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b",
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"direction": "outgoing",
"event_type": "payout_success",
"idempotency_key": "payout_success:99999999-9999-4999-8999-999999999999",
"status": "processed",
"retry_count": 0,
"last_error": null,
"payload": {
"event_type": "payout_success",
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"payout_id": "99999999-9999-4999-8999-999999999999",
"amount": "4183.30",
"currency": "USDC",
"chain": "solana",
"transaction_hash": "3xPayoutTxSignature111111111111",
"status": "confirmed",
"timestamp": "2026-11-05T13:43:08Z",
"crebit_contract_reference": "CREBIT-20260928-7F3A9C2B1D",
"partner_transaction_reference": "member-tx-9901",
"payout_wallet_address": "EndUserSettlementWa11et1111111111111111111",
"transaction_explorer_url": "https://solscan.io/tx/3xPayoutTxSignature111111111111",
"settlement_rate_used": "5.5100",
"oracle_clamp_applied": false,
"subject": {
"relationship": "self",
"partner_id": "8f3c2a1e-4b5d-4e6f-9a7b-1c2d3e4f5a6b",
"partner_name": "Member Co",
"organisation_id": null,
"organisation_name": null
}
},
"created_at": "2026-11-05T13:43:08Z",
"processed_at": "2026-11-05T13:43:09Z"
}
],
"next_cursor": null
}Errors
Errors use { code, message, details }. Acting-as errors (acting_as_not_allowed, acting_as_self) are listed on Organizations.
| Status | code | When |
|---|---|---|
| 422 | validation_error | Request body failed validation |
| 400 | bad_request | Invalid cursor or customer_reference_id length |
| 400 | invalid_cursor | Invalid cursor on GET /api/v1/fx/webhook-events |
| 400 | invalid_idempotency_key | Idempotency-Key missing (inbound webhooks) or malformed |
| 409 | idempotency_mismatch | Same Idempotency-Key reused with a different body (quotes, contracts, margin-call payment) |
| 409 | idempotency_in_progress | A request with the same Idempotency-Key is still running |
| 404 | not_found | Quote, contract or customer reference not found for the member |
| 409 | quote_expired | Contract create after the quote expired |
| 409 | quote_already_used | Quote already turned into a contract |
| 409 | quote_not_eligible | Quote is not in created status |
| 409 | partner_transaction_reference_already_used | Reference used by another in-flight contract of the member |
| 400 | payout_wallet_missing | Payout destination required but not set |
| 409 | payout_destination_not_editable | Contract status no longer allows changing the payout destination |
| 409 | execution_window_closed | Action after the execution window closed |
| 400 | invalid_contract_status | Settlement preview on a contract that is not active, exercised or settled |
| 409 | not_failed / not_recoverable / invalid_recovery_target | Retry on a contract that is not failed or cannot resume to the target |
| 400 | INVALID_ARGUMENT | Inbound webhook rejected on a business rule |
| 404 | NOT_FOUND | Inbound webhook for a contract the member doesn't own |
| 409 | IDEMPOTENCY_CONFLICT | Inbound webhook Idempotency-Key reused with a different body |
| 401 | INVALID_SIGNATURE | Inbound webhook signature missing, invalid or stale |
| 404 | margin_call_not_found | No open margin call, or unknown margin_call_id |
| 400 | margin_call_already_paid | Margin call already paid with a different transaction |
| 400 | margin_call_not_issued | Margin call is not in issued status |
| 400 | margin_call_contract_not_active | Contract is no longer active |
| 400 | funding_tx_* (e.g. funding_tx_invalid, funding_tx_amount_mismatch, funding_tx_recipient_mismatch, funding_tx_reused) | Reported margin-call transaction failed on-chain verification or was already used |
| 503 | oracle_unavailable / live_spot_pricer_disabled | Pricing source temporarily unavailable |