Concepts
Five concepts every Crebit Lock integration depends on. Read these once, then refer back to the schemas on API endpoints.
Lock Window
The lock window is the time range during which your customer may execute at the locked rate. Two ISO-8601 UTC datetimes define it:
window_start, the first moment the customer is allowed to transact at the locked rate.window_end, the last moment the customer is allowed to transact at the locked rate.
The customer may transact at any moment in [window_start, window_end]. The locked rate is identical at every moment in the window , only the moment the customer picks varies. You set both fields on the quote; the contract inherits them and they're immutable for the life of the lock. Short windows span 1–24 hours; long windows may extend up to 180 days (by window_end calendar date).
How Long Can a Window Be?
Two pricing buckets apply:
- Short locks, span between
window_startandwindow_endis 1–24 hours. - Long locks,
window_endcalendar date is 1–180 days ahead of the quote date.
In all cases, window_end must be strictly after window_start. Out-of-range durations return duration_out_of_range.
| Use case | Typical window |
|---|---|
| Customer wants to transact within hours | Short · 1–6 hours (minimum 1h) |
| Customer expects to transact in the next day or two | Short · 24–72 hours |
| Customer expects to transact within the week | Short · 5–7 days |
| B2B treasury hedging a known upcoming wire | Medium · 2–4 weeks |
| Quarterly settlement, longer-tenor hedging | Long · 30–180 days |
| Maximum allowed | Up to 180 days (window_end calendar date) |
Longer windows cost more premium because the customer holds more optionality (more days to pick a favourable market move).
Fields & Rules
Lock window
Every quote defines a calendar window during which the customer can execute the locked rate. Always send window_start and window_end:
| Field | Type | Description |
|---|---|---|
| window_start | Datetime (ISO-8601 UTC, e.g. 2026-08-04T13:00:00Z) | First moment the customer may execute the locked rate. Must be strictly before window_end. |
| window_end | Datetime (ISO-8601 UTC, e.g. 2026-08-11T13:00:00Z) | Last moment the customer may execute. Must be STRICTLY AFTER window_start (equal values return validation_error). Pricing accepts short windows (1–24 hours between start and end) or long windows (window_end calendar date up to 180 days ahead); out-of-range values return duration_out_of_range. |
- Both window_start and window_end are required on every quote.
- window_end must be STRICTLY AFTER window_start; equal values are rejected with validation_error.
- Short locks: span between window_start and window_end is 1–24 hours (inclusive).
- Long locks: window_end calendar date must be 1–180 days ahead of the quote date.
- The customer may execute at any moment within [window_start, window_end]; the locked rate is identical at every moment in the window.
- Window length affects pricing — longer windows cost more premium (the customer holds more optionality).
- Both contract_type values (forward, option) accept the same window fields.
window_start and window_end. Long windows may extend up to 180 days (by window_end calendar date). window_end must be strictly after window_start; equal values return validation_error. Out-of-range durations return duration_out_of_range.Concrete Examples
| Scenario | window_start | window_end | Window length |
|---|---|---|---|
| Short lock (minimum span) | 2026-08-04T09:00:00Z | 2026-08-04T10:00:00Z | 1 hour |
| 3-hour intra-day window | 2026-08-04T09:00:00Z | 2026-08-04T12:00:00Z | 3 hours |
| 48-hour window | 2026-08-04T13:00:00Z | 2026-08-06T13:00:00Z | 48 hours |
| One-week forward | 2026-08-04T00:00:00Z | 2026-08-11T00:00:00Z | 7 days |
| 30-day option | 2026-09-01T00:00:00Z | 2026-10-01T00:00:00Z | 30 days |
| Quarterly hedge | 2026-08-04T00:00:00Z | 2026-11-04T00:00:00Z | 92 days |
| Maximum window | 2026-08-04T00:00:00Z | 2027-02-01T00:00:00Z | 180 days |
validation_error,window_endequal to or beforewindow_start.duration_out_of_range, window span or execution date outside the 1–24 hour (short) or 1–180 day (long) pricing limits.
Currencies in a Quote
Every quote has two currency-related decisions: which FX pair (and which side of it the customer is fixing) and which stablecoin Crebit settles in with you.
Supported Directions
Supported FX corridors match the lock API direction enum — six values across three corridors (BRL/USD, MXN/USD, and NGN/USD, both directions each):
BRL_TO_USD · USD_TO_BRL · MXN_TO_USD · USD_TO_MXN · NGN_TO_USD · USD_TO_NGN
direction only fixes the FX pair AND which side the trade flows from. Which side of the pair the customer is fixing their amounton, the amount they're sending or the amount they want to receive, is set independently via notional_currency below.
The Three Fields You Send for the Currency Setup
| Field | What it is | Example |
|---|---|---|
| direction | Which corridor the customer is hedging, and which way the trade flows. One of the SUPPORTED_DIRECTIONS values above. | BRL_TO_USD — Brazilian exporter selling BRL to receive USD. NGN_TO_USD — Nigerian exporter selling NGN to receive USD stablecoin. |
| notional_currency | Which side of the pair the notional_amount is denominated in. EITHER leg of direction is valid — the customer might be locking the amount they're sending OR the amount they want to receive. Must match a currency in direction (USD, BRL, MXN, or NGN). | For direction=USD_TO_BRL: USD (lock 50,000 USD-worth) or BRL (lock 250,000 BRL-worth). For direction=USD_TO_NGN: USD (lock 50,000 USD-worth) or NGN (lock 79,000,000 NGN-worth). Either leg of direction is valid. |
| settlement_currency | Margin token — stablecoin Crebit and the partner settle in. Partner sends the upfront fee in this stablecoin to funding_wallet_address; Crebit pays out any FX delta in this stablecoin too. USDC or USDT; your choice selects the live oracle pair (e.g. BRL/USDC vs BRL/USDT, NGN/USDT). The end customer never sees stablecoins. | USDC · USDT |
Supported Chains
Call GET /api/v1/fx/supported-chains for the authoritative catalog. Book a chain only when enabledis true (partner entitlement, and in production funded payout-hot inventory). Summary:
| chain | status | settlement_currencies | Notes |
|---|---|---|---|
| live | Fast settlement. Primary production rail. | ||
| live | Tron address (starts with T). USDT payouts. | ||
| planned | EVM. Schema reserved for future launch. | ||
| planned | EVM L2. Schema reserved for future launch. |
Margin Tokens (settlement_currency)
The API field is settlement_currency; the Crebit dashboard calls it margin token. Your choice fixes which stablecoin you fund with and which live oracle pair prices the rate.
| Corridor | marginToken | Live oracle pair |
|---|---|---|
| stablecoin | Available on |
|---|---|
Rules
- One stablecoin per contract -
settlement_currencycovers both the partner funding leg and the customer payout leg. - Webhook values should match the contract — send the same
chainandsettlement_currencylocked at quote time onfunds_in_routeandcontract_exercised. Business-rule rejections on inbound webhooks return400 INVALID_ARGUMENT(seemessagefor detail). - Pricing reflects on-chain settlement cost, Ethereum quotes are higher than Polygon all else equal.
Strike, Spot, and Market Rate
Every quote response carries three rates that a partner often confuses. Knowing the difference lets you message your customer accurately, and tells you whether a CIP-fair forward gives them a strike better than today's market (which happens more often than people think).
Three Rates That Matter
| Field | What it is | Source |
|---|---|---|
| provider_rate | Your live retail FX rate at quote time, what you'd quote the customer with no protection. | You send it on the request. |
| market_rate | The benchmark mid-market FX rate from an independent reference (your data feed or CoinGecko stablecoin pair). | You send it on the request (required unless strike_mode=live_spot). |
| locked_rate | THE STRIKE, the rate the customer actually locks at. For forwards, the CIP-fair forward rate; for options, the option strike. | Crebit returns it. |
Three Strike Modes
On every quote you choose strike_mode. Omit it and Crebit defaults to cip_fair.
| strike_mode | What Crebit does | Use when |
|---|---|---|
| cip_fair (default) | Derives the CIP-fair forward strike from market_rate + the currency-pair interest-rate differential. When that strike is better than spot for the customer, Crebit funds the difference, paying out the extra settlement_currency (USDC or USDT) on-chain at exercise so the customer actually receives the better-than-spot rate. | Most quotes. For high-interest-rate corridors (e.g. USD→BRL), the CIP-fair strike sits above spot and Crebit covers the gap in stablecoin, a real selling point for your customer. |
| live_spot | Sets locked_rate from live_spot_pricer TWAP at quote time. Omit provider_rate, market_rate, and market_rate_timestamp on the request. | Customer wants to lock at today's live spot. Common for short windows where forward points are minimal anyway. |
| custom | Uses the target_strike value you send. Required field when mode=custom. | Customer specified an exact rate (e.g. ATM/OTM option strike, or matching an external quote). |
How CIP-Fair Works
Covered interest parity (CIP) says a forward FX rate equals spot adjusted by the interest-rate differential between the two currencies, so the no-arbitrage forward is F = S × (1 + r_quote × t) / (1 + r_notional × t). Crebit applies this from market_rate for the length of the lock window.
notional_currency leg (e.g. USD→BRL where BRL rates ≫ USD rates), the CIP-fair forward sits above spot - meaning your customer gets more BRL per USD on the forward than on the live spot today. Use strike_advantage_bps (below) to message how much better.| Response field | Tells you |
|---|---|
| strike_mode | Echoes request: cip_fair · live_spot · custom. |
| target_strike | if strike_mode=custom, the exact target_strike value you sent. |
| strike_advantage_bps | Non-negative basis points (magnitude vs market_rate). Signed customer-perspective semantics planned. |
| premium_amount | All-in premium (option) or quoted fee (forward), in settlement_currency. |
| deposit_amount | Security deposit (forwards only; null for options). |
| total_amount | The total amount due to Crebit. Adds premium_amount and deposit_amount. |
| amount_due | crebit-pricer total stablecoin due now (premium + deposit for forwards). |
| collateral_amount | Forward refundable collateral from crebit-pricer (forwards only). |
| upfront_fee | Forward non-refundable platform fee from crebit-pricer (omitted for options). |
Quote Economics (crebit-pricer)
Every successful quote response includes economics from crebit-pricer alongside the legacy summary fields:
| Field | What it is | Relationship |
|---|---|---|
| premium_amount | All-in premium (option) or quoted fee component (forward). | Partner-facing summary; aligns with crebit-pricer premium. |
| deposit_amount | Security deposit (forwards only). | Typically matches collateral_amount. |
| total_amount | premium_amount + deposit_amount. | Quick total before locking. |
| amount_due | Total stablecoin due now to activate the lock. | Authoritative funding total from crebit-pricer. |
| collateral_amount | Refundable forward collateral. | Released on exercise; forfeited on forward expiry without exercise. |
| upfront_fee | Non-refundable forward platform fee. | Omitted for options — use premium_amount and amount_due only. |
| pricing_tier / pricing_greeks | crebit-pricer audit metadata. | Optional; useful for ML validation and support tickets. |
strike_advantage_bps Explained
A non-negative integer: the magnitude (in basis points) by which locked_rate differs from market_rate. Use it alongside strike_mode and locked_rate to message the quote. Direction-aware signed semantics (positive = customer wins) are planned; today the API returns abs(locked_rate − market_rate) in bps.
| Example value | Interpretation | Customer messaging |
|---|---|---|
| 220 | Strike is 2.20% away from mid-market (magnitude). | "Your locked rate differs from today's mid-market by 220 bps." |
| 30 | Small difference from market. | "Your locked rate is 30 bps from today's spot." |
| 0 | At market (typical for live_spot mode). | "Lock at today's rate." |
Which Mode to Pick
| Scenario | contract_type | strike_mode | Why |
|---|---|---|---|
| Standard forward booking, customer trusts your platform's pricing | forward | cip_fair | Default. Customer usually gets a strike above spot on high-rate corridors. |
| Short window (< 24h) where forward points are negligible | forward | live_spot | Simpler to communicate, "lock today's spot", and indistinguishable from CIP on tiny windows. |
| Forward priced to match a specific invoice / external quote | forward | custom | Send target_strike = the external rate. |
| ATM option, classic vol play | option | live_spot | Strike = market_rate gives a symmetric ATM option. |
| OTM option, cheap insurance | option | custom | Send target_strike past spot in the customer's unfavored direction. Lower premium. |
| ITM option, high-conviction directional bet | option | custom | Send target_strike past spot in the customer's favored direction. Higher premium. |
Crebit prices to whatever mode + strike you specify. Aggressive strikes flow through to a higher premium_amount.
Settlement Preview
POST /api/v1/fx/contracts/{contract_id}/settlement-preview lets you preview the FX delta Crebit would pay out if the customer exercises at a given live_execution_rate. It uses the same settlement engine as the contract_exercised inbound webhook but does not trigger a payout.
| Field | Meaning |
|---|---|
| is_favorable | True when locked_rate vs live_execution_rate means Crebit owes the customer a payout. |
| payout_amount | Stablecoin amount Crebit would transfer. Options: zero when unfavorable. Forwards: max(0, deposit + FX delta). |
| oracle_clamp_applied | True when your live_execution_rate was adjusted toward an independent oracle bound before computing payout. |
| settlement_rate_used | Effective rate used in the formula after any oracle clamp. |
| formula / calculation_version | Audit trail for support — describes the math and engine version. |
contract_exercised. Only contract_exercised actually moves money on-chain.Forward vs Option
contract_type picks one of two shapes: forward or option. It's orthogonal to strike_mode, you can combine forwards or options with any of the three strike modes.
| forward | option | |
|---|---|---|
| Upfront cash flow | Premium plus a security deposit (typically 5-10% of notional) | Non-refundable premium |
| Nature of the upfront | Collateral against the obligation, not a fee | Cost of buying the optionality |
| Customer obligation | Obligated to transact within the window | Right but not obligation |
| If customer DOES exercise | Deposit released back to partner as part of the payout_success / contract_settled flow | Customer pays nothing more; Crebit pays the FX delta if owed |
| If customer doesn't exercise | Deposit FORFEITED, Crebit keeps it to cover the hedge cost (contract_expired webhook signals this) | Premium was already kept by Crebit; nothing else happens |
| Pricing driver | Time-value over the window | Volatility + time + how aggressive the strike is |
| Best for | Known upcoming transactions, treasury hedging | Optional exposure, FX insurance, uncertain timing |
The two dimensions combine cleanly. Six common combinations:
| cip_fair | live_spot | custom | |
|---|---|---|---|
| forward | Default booking. Strike sits above/below spot depending on rate differential. | Lock at today's spot. Thin premium for delivery certainty. | Forward priced to a specific external rate (e.g. invoice match). |
| option | Option struck at the forward fair. Premium = pure vol. | Classic ATM option struck at today's spot. | ATM / OTM / ITM option, partner picks the strike for the customer's risk appetite. |
Forward Maturity
For forward contracts at window_end:
- With a saved payout destination (
PUT /fx/contracts/{id}/payout-destinationor at quote/contract create), Crebit force-exercises at the oracle rate and settles. - Without a payout wallet, the contract stays
active— expiry does not forfeit the deposit. - After the window closes, partner
contract_exercisedis rejected withexecution_window_closed.
Also set oracle on quote create (BRL/MXN: redstone or binance; NGN: stable_coordinates or crebit_ngn; CHF: chainlink) to pick the settlement price feed used at exercise and maturity.
Idempotency
Send Idempotency-Key (UUID recommended) on every write. Same key + same body returns the original response within TTL, so retries are safe.
POST /api/v1/fx/quotes, recommended.POST /api/v1/fx/contracts, recommended.POST /api/v1/fx/webhooks/inbound, required (8–128 ASCII printable chars). Reusing a key with a different body returns409 IDEMPOTENCY_CONFLICT.- On
POST /fx/quotesandPOST /fx/contracts, the same conflict returns409 idempotency_mismatch(lowercase). - Outbound webhooks (Crebit → you): use the
event_idfield as your idempotency key. Crebit may retry the same delivery if your endpoint returns a non-2xx within 10s.
Errors
All errors return a JSON envelope:
{
"code": "validation_error",
"message": "window_end must be after window_start",
"details": {}
}Common code values on quote/contract APIs (lowercase snake_case):
| code | Meaning |
|---|---|
| validation_error | Request body failed schema or business-rule validation. See message + details. |
| not_found | Unknown customer_reference_id, quote_id, or contract for your partner. |
| market_rate_stale | Sent market_rate is older than PRICING_MARKET_RATE_MAX_AGE_SECONDS (~5 min). |
| market_rate_unavailable | Benchmark rate could not be validated for pricing. |
| notional_limit_exceeded | Requested notional is above your account's per-quote ceiling. |
| provider_spread_exceeded | provider_rate is too far from market_rate (bps cap). |
| duration_out_of_range | Lock window span or execution date is outside pricing limits (short 1–24h, long 1–180d). |
| chain_settlement_pair_unsupported | Invalid chain + settlement_currency combo (e.g. USDC on Tron). |
| payout_wallet_missing | Exercise or settlement attempted without a payout destination. |
| payout_destination_incomplete | Payout destination fields are partially set. |
| payout_destination_not_editable | PUT payout-destination rejected for this contract state. |
| execution_window_closed | contract_exercised sent after window_end. |
| binance_oracle_unavailable | Binance oracle selected but rate fetch failed. |
| funding_tx_not_found | Solana funding tx verification could not find the transaction. |
| quote_not_eligible | Quote status is not created when POST /fx/contracts. |
| quote_expired | Quote is past expires_at. |
| quote_already_used | A contract already exists for this quote_id. |
| partner_transaction_reference_already_used | The same partner_transaction_reference is already on another in-flight contract for your partner. |
| idempotency_mismatch | Same Idempotency-Key on POST /fx/quotes or /fx/contracts with a different body (409). |
| idempotency_in_progress | Concurrent request with the same Idempotency-Key still processing (409). |
Inbound webhook errors (POST /fx/webhooks/inbound) use uppercase code values:
| code | HTTP | Meaning |
|---|---|---|
| INVALID_ARGUMENT | 400 | Business rule rejected the payload (window, status, rate, amount, etc.). See message. |
| NOT_FOUND | 404 | fx_contract_id unknown for your partner. |
| IDEMPOTENCY_CONFLICT | 409 | Same Idempotency-Key with a different webhook body. |
| INVALID_SIGNATURE | 401 | Webhook signature verification failed. |