diff --git a/src/pages/docs/api/webhooks-guide.mdx b/src/pages/docs/api/webhooks-guide.mdx new file mode 100644 index 000000000..33fd860a7 --- /dev/null +++ b/src/pages/docs/api/webhooks-guide.mdx @@ -0,0 +1,355 @@ +--- +title: "Tempo webhooks" +seoTitle: "Tempo Webhooks: Verification, Retries, and Replay | Tempo Docs" +description: "Receive signed Tempo webhook events for Routes and onchain activity, verify HMAC-SHA256 signatures, handle retries and auto-disable, and replay past deliveries." +--- + +import { Card, Cards } from 'vocs' + +# Tempo webhooks + +Receive signed HTTPS callbacks for [Tempo Routes](/docs/routes) lifecycle changes and onchain events instead of polling API endpoints. + +## Subscribe to webhook events + +Create a webhook subscription in [Tempo Console](https://tempo.com/console) or via `POST /v1/webhooks`. Authenticate every webhook management request with an API key in the `tempo-api-key` header; pay-per-request [MPP](/docs/api/authentication#mpp-paying-per-request) isn't supported for webhook management. + +| Operation | Required scopes | +| --- | --- | +| Create, update, delete, ping, or replay deliveries | `webhooks:write` | +| List subscriptions or read delivery logs | `webhooks:read` | +| Subscribe to Routes events (`routes:transfer.updated`, `routes:deposit.updated`) | `webhooks:write` and `routes:read` | + +Destination URLs must use `https://`, omit embedded credentials, and resolve to a public host. Tempo rejects loopback, private, link-local, and metadata addresses. + +When you create a subscription, Tempo returns its signing secret (`whsec_…`) once in the response. Store it in your secret manager immediately; later reads never expose it. + +### Supported event types + +Each subscription listens to one event type and accepts an optional `filters` object to narrow matches (see the [Webhooks API reference](/docs/api/webhooks) for per-event filter schemas): + +| Event type | Trigger | +| --- | --- | +| `routes:transfer.updated` | Emitted when a Routes transfer is created (`awaiting-source`, `version: 1`) and on each status or data change (incrementing `version`). Filterable by `id` or `status`. | +| `routes:deposit.updated` | Emitted when a Routes deposit changes state after initial detection (starting at the first transition after `detected`). Filterable by `depositAddressId` (the `rda_…` address ID), `recipient`, or `status`. | +| `token:transfer` | Emitted when a [TIP-20](/docs/protocol/tip20/overview) stablecoin transfer occurs onchain. | +| `transaction:included` | Emitted when a transaction is included in a block. | +| `log:emitted` | Emitted when a contract emits an event log matching your filter criteria. | +| `block:created` | Emitted when a new block is added to the chain. | +| `ping` | Synthetic test delivery triggered by `POST /v1/webhooks/{id}/ping`. | + +Set `chainId` on the subscription to the EVM chain you want to monitor (such as `4217` for Tempo Mainnet). For `routes:transfer.updated`, `chainId` matches the transfer's EVM destination chain (transfers delivering to non-EVM chains don't emit transfer webhooks). For `routes:deposit.updated`, `chainId` matches either the deposit's EVM source or EVM destination chain. + +## Webhook headers and payload + +Tempo delivers each event as an HTTP `POST` with `content-type: application/json`, a JSON envelope body, and three headers: + +| Header | Format | Purpose | +| --- | --- | --- | +| `tempo-event-id` | `evt_<64 hex>` | Event ID. For real events, stays identical across automatic retries and manual replays—use it for idempotency and deduplication. Each `ping` generates a fresh ID. | +| `tempo-event-type` | Event type string | Mirrors the envelope's `type` field (`routes:transfer.updated`, `routes:deposit.updated`, `ping`, or an onchain event type). | +| `tempo-signature` | `t=,v1=` | Unix seconds timestamp and lowercase hex HMAC-SHA256 signature of the raw body. | + +The JSON envelope wraps the event payload in `data`. IDs carry type prefixes: `evt_` for events, `wh_` for subscriptions, `whd_` for delivery attempts, `rtr_` for Routes transfers, and `rdp_` for Routes deposits: + +```json +{ + "chainId": 4217, + "createdAt": "2026-10-14T00:00:00.000Z", + "data": { + "id": "rtr_001785729600000_2ZPE2gvateYEQ0dQslgvkhjx", + "status": "completed", + "updatedAt": "2026-10-14T00:00:00.000Z", + "version": 3 + }, + "id": "evt_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", + "subscriptionId": "wh_001785729600000_2ZPE2gvateYEQ0dQslgvkhjx", + "type": "routes:transfer.updated" +} +``` + +`data` carries the same resource fields as the corresponding read endpoint, such as `GET /v1/routes/transfers/{id}` or `GET /v1/routes/deposits/{id}`. If you set optional `context` fields (`title`, `description`, or `metadata`) when creating or updating the subscription, Tempo echoes `context` on every envelope. + +### Ordering and reconciliation + +Webhook delivery is at-least-once and not strictly ordered. Build every handler to be idempotent: + +- **Deduplicate on `tempo-event-id`.** Store processed event IDs so automatic retries and manual replays don't double-apply state changes. +- **Ignore stale Routes updates.** Treat each event as a state snapshot. For `routes:transfer.updated`, compare `data.version` and skip any event whose version isn't strictly greater than your stored version. For `routes:deposit.updated`, which has no `version` field, compare `data.updatedAt` and ignore older timestamps or any non-terminal update after a deposit reached a terminal state (`completed` or `refunded`). +- **Credit only on `completed`.** Routes transfers move through `awaiting-source` and `processing`, and deposits move through `detected`, `bridging`, and `settling`, before reaching terminal states (`completed`, `refunded`, or `expired` for transfers). Credit a customer balance only when `data.status` is `completed`, after reconciling the delivered `data.destinationAmount` and `data.destinationTransactionHashes` against your payment record. + +## Verify webhook signatures + +Always verify `tempo-signature` before trusting or processing a webhook body. Read the raw, unparsed HTTP request body bytes from your web framework before running any JSON parser, because re-serializing JSON can alter whitespace or key order. + +1. Parse `t` (the Unix timestamp string in seconds) and `v1` (the 64-character lowercase hex digest) from `tempo-signature` (`t=,v1=`). +2. Check `t` against your server clock and reject deliveries outside a **±300-second (5-minute)** replay window. +3. Build the signed payload by concatenating the literal `t` string, a `.` separator, and the exact raw UTF-8 request body bytes: `.`. +4. Compute HMAC-SHA256 over the signed payload using the **full `whsec_…` secret string as UTF-8 bytes**. +5. Compare the lowercase hex digest with `v1` in constant time. + +:::warning +Use the full `whsec_…` secret string verbatim as UTF-8 bytes. Don't strip the `whsec_` prefix, and don't base64-decode the secret. Verify against the exact raw request bytes before parsing JSON. +::: + +### Verification examples + +::::code-group + +```ts [TypeScript (Node)] +import { createHmac, timingSafeEqual } from 'node:crypto' + +export function verifyTempoWebhook( + rawBody: Buffer | string, + signatureHeader: string, + secret: string, + toleranceSeconds = 300, +): boolean { + let rawTimestamp: string | undefined + let signature: string | undefined + + for (const part of signatureHeader.split(',')) { + const separator = part.indexOf('=') + if (separator === -1) continue + const key = part.slice(0, separator).trim() + const value = part.slice(separator + 1).trim() + if (key === 't' && value) rawTimestamp = value + else if (key === 'v1' && value) signature = value + } + + if (!rawTimestamp || !/^\d+$/.test(rawTimestamp) || !signature) return false + + const timestamp = Number(rawTimestamp) + if (!Number.isSafeInteger(timestamp)) return false + + const now = Math.floor(Date.now() / 1000) + if (Math.abs(now - timestamp) > toleranceSeconds) return false + + const bodyBytes = typeof rawBody === 'string' ? Buffer.from(rawBody, 'utf8') : rawBody + const payload = Buffer.concat([Buffer.from(`${rawTimestamp}.`, 'utf8'), bodyBytes]) + const expected = createHmac('sha256', Buffer.from(secret, 'utf8')) + .update(payload) + .digest('hex') + + const received = Buffer.from(signature, 'utf8') + const wanted = Buffer.from(expected, 'utf8') + return received.length === wanted.length && timingSafeEqual(received, wanted) +} +``` + +```python [Python] +import hashlib +import hmac +import time + + +def verify_tempo_webhook( + raw_body: bytes, + signature_header: str, + secret: str, + tolerance_seconds: int = 300, +) -> bool: + raw_timestamp = None + signature = None + + for part in signature_header.split(","): + if "=" not in part: + continue + key, value = part.split("=", 1) + key, value = key.strip(), value.strip() + if key == "t" and value: + raw_timestamp = value + elif key == "v1" and value: + signature = value + + if ( + not raw_timestamp + or not raw_timestamp.isascii() + or not raw_timestamp.isdigit() + or not signature + ): + return False + + if abs(int(time.time()) - int(raw_timestamp)) > tolerance_seconds: + return False + + signed_payload = f"{raw_timestamp}.".encode("utf-8") + raw_body + expected = hmac.new( + secret.encode("utf-8"), + signed_payload, + hashlib.sha256, + ).hexdigest() + + return hmac.compare_digest(expected.encode("utf-8"), signature.encode("utf-8")) +``` + +```go [Go] +package webhooks + +import ( + "crypto/hmac" + "crypto/sha256" + "encoding/hex" + "strconv" + "strings" + "time" +) + +func VerifyTempoWebhook(rawBody []byte, signatureHeader, secret string, toleranceSeconds int64) bool { + var rawTimestamp string + var signature string + + for _, part := range strings.Split(signatureHeader, ",") { + key, value, ok := strings.Cut(part, "=") + if !ok { + continue + } + key, value = strings.TrimSpace(key), strings.TrimSpace(value) + switch key { + case "t": + rawTimestamp = value + case "v1": + signature = value + } + } + + if rawTimestamp == "" || signature == "" { + return false + } + + timestamp, err := strconv.ParseInt(rawTimestamp, 10, 64) + if err != nil { + return false + } + + diff := time.Now().Unix() - timestamp + if diff < 0 { + diff = -diff + } + if diff > toleranceSeconds { + return false + } + + mac := hmac.New(sha256.New, []byte(secret)) + mac.Write([]byte(rawTimestamp)) + mac.Write([]byte(".")) + mac.Write(rawBody) + expected := hex.EncodeToString(mac.Sum(nil)) + + return hmac.Equal([]byte(expected), []byte(signature)) +} +``` + +:::: + +### Canonical test vector + +Use these inputs to unit-test your verifier (pinning the verifier clock within 300 seconds of `1767225600`): + +| Field | Value | +| --- | --- | +| Secret | `whsec_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef` | +| Timestamp (`t`) | `1767225600` | +| Raw body | `{"chainId":4217,"createdAt":"2026-01-01T00:00:00.000Z","data":{"ping":true},"id":"evt_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef","subscriptionId":"wh_001767225600000_example","type":"ping"}` | +| Expected `v1` | `6c193a322e1529f596e83e5fe255a34454f89165d874d099c25366fcc4b6032b` | +| `tempo-signature` | `t=1767225600,v1=6c193a322e1529f596e83e5fe255a34454f89165d874d099c25366fcc4b6032b` | + +### Rotate signing secrets + +Tempo emits a single `v1` signature per delivery and doesn't offer an in-place secret-rotation endpoint. For zero-downtime rotation: + +1. Create a second overlapping webhook subscription for the same events and store its new `whsec_…` secret. +2. Update your handler to verify incoming `tempo-signature` headers against both the current and new secrets, accepting a request if either matches. Both subscriptions deliver matching events with the same `tempo-event-id`, so deduplicating on `tempo-event-id` prevents double processing during cutover. +3. Confirm deliveries succeed on the new subscription, then delete the old subscription with `DELETE /v1/webhooks/{id}`. + +### Test an endpoint with ping + +Send a synthetic signed event with `POST /v1/webhooks/{id}/ping` (requires `webhooks:write`): + +```bash [Terminal] +curl -X POST 'https://api.tempo.xyz/v1/webhooks//ping' \ + -H "tempo-api-key: $TEMPO_API_KEY" +``` + +Tempo sends a signed `ping` event whose `data` is `{"ping":true}` and returns the HTTP status and timing immediately. Each ping creates a fresh random `evt_…` ID (so repeated pings aren't deduplicated), appears in your delivery log, and **never modifies the subscription's failure counter (`failureCount`) or `status`**. + +## Retries and failure handling + +Return any `2xx` HTTP status within **10 seconds** to acknowledge delivery. Enqueue heavy processing asynchronously so your endpoint responds quickly. + +Tempo classifies failed attempts into retryable and non-retryable outcomes: + +- **Retryable failures.** Network or transport errors, 10-second timeouts, HTTP `408`, HTTP `429`, and `5xx` responses. +- **Non-retryable failures (0 automatic retries).** All other `4xx` responses (including `400`, `401`, `403`, and `404`), `3xx` redirects (Tempo rejects redirects without following them for SSRF protection), and blocked-URL rejections. + +### Retry backoff schedule + +Retryable failures retry up to **30 total attempts** (1 initial attempt plus up to 29 retries over about 25 hours) using exponential backoff capped at one hour: + +| Failed attempt | Delay before next attempt | +| --- | --- | +| 1 | `5s` | +| 2 | `25s` | +| 3 | `125s` (~2 minutes) | +| 4 | `625s` (~10 minutes) | +| 5 | `3125s` (~52 minutes) | +| 6 through 29 | `3600s` (1 hour) | +| 30 | None — delivery is marked failed and automatic retries stop | + +## Auto-disable and recovery + +A subscription's `status` is `active`, `paused`, or `disabled`. Tempo tracks net delivery failures in `failureCount`: each failed delivery attempt (whether retryable or non-retryable) adds `1`, and each successful delivery subtracts `1` (floored at `0`). Synthetic `ping` deliveries don't change `failureCount`. + +When `failureCount` reaches **20**, Tempo automatically sets `status` to `disabled` and stops sending new deliveries. + +After fixing your endpoint, re-enable the subscription in Tempo Console or via `PATCH /v1/webhooks/{id}` (`webhooks:write`): + +```bash [Terminal] +curl -X PATCH 'https://api.tempo.xyz/v1/webhooks/' \ + -H "tempo-api-key: $TEMPO_API_KEY" \ + -H 'Content-Type: application/json' \ + -d '{"status":"active"}' +``` + +## Replay past deliveries + +Tempo retains each delivery attempt row and its original signed envelope for **7 days** from when that attempt was recorded. You can replay any retained delivery (failed or succeeded): + +1. List recent attempts with `GET /v1/webhooks/{id}/deliveries` (`webhooks:read`) or open the delivery log in Tempo Console, and copy the delivery's `id` (`whd_…`). +2. Replay that delivery inline with `POST /v1/webhooks/{id}/deliveries/{deliveryId}/retry` (`webhooks:write`) or from Tempo Console: + +```bash [Terminal] +curl -X POST 'https://api.tempo.xyz/v1/webhooks//deliveries//retry' \ + -H "tempo-api-key: $TEMPO_API_KEY" +``` + +Manual replay sends the exact original envelope with the same `tempo-event-id` and a fresh signature timestamp `t`. Replays execute once inline (they don't trigger automatic retry loops) and update `failureCount` like a normal delivery. + +## Related + + + + + + + diff --git a/src/pages/docs/routes/delivery.mdx b/src/pages/docs/routes/delivery.mdx index 9ee8a74f6..eda662d02 100644 --- a/src/pages/docs/routes/delivery.mdx +++ b/src/pages/docs/routes/delivery.mdx @@ -7,21 +7,27 @@ ogImage: /og/2026-q4/og_2026-q4_docs_routes-delivery_title-f5_v02.png # Track delivery -A successful source-chain transaction starts a route. The route completes when the destination receives funds or the refund lands. Keep the Routes object ID with your payment record and follow its status. +A successful source-chain transaction starts a [Tempo Routes](/docs/routes) transfer or deposit. The route completes when the destination receives funds or a refund lands at your source-chain refund address. Keep the Routes transfer ID (`rtr_…`) or deposit ID (`rdp_…`) with your payment record and follow its status. ## Read the status -Read status with a key that has `routes:read`: +Read status with a Tempo API key that has the `routes:read` scope: | Flow | Read | Request builder | | --- | --- | --- | | Deposit address | `GET /v1/routes/deposits?depositAddress=…`, then `GET /v1/routes/deposits/{id}` for each deposit | [Track deposits](/docs/routes/deposits#track-deposits) | | Transfer | `GET /v1/routes/transfers/{id}`, after you register the source transaction hashes | [Confirm the transfer](/docs/routes/transfers#confirm-the-transfer) | -An `active` deposit address can receive deposits. Each deposit has its own status. +An `active` deposit address can receive deposits. Each incoming deposit gets its own `rdp_…` record and status. + +## Receive webhook updates + +Subscribe to signed webhooks instead of polling status endpoints. Tempo POSTs `routes:transfer.updated` and `routes:deposit.updated` events to your HTTPS endpoint whenever a transfer or deposit changes state, carrying the resource object in `data`. + +Delivery is at-least-once and not strictly ordered. Deduplicate on the `tempo-event-id` header, ignore stale updates where `data.version` isn't higher (transfers) or `data.updatedAt` isn't later (deposits), and credit balances only when `data.status` is `completed`. Follow the [Tempo webhooks guide](/docs/api/webhooks-guide) for signature verification, retry schedules, and replay. @@ -33,26 +39,26 @@ An `active` deposit address can receive deposits. Each deposit has its own statu | --- | --- | --- | | `awaiting-source` | Transfers | Source funding has not been registered. | | `detected`, `bridging`, `settling` | Deposits | Funds are moving through delivery. Keep the deposit pending. | -| `processing` | Transfers | Keep the payment pending. | -| `completed` | Both | Reconcile the delivered amount and destination transaction references. | -| `action-required` | Both | Inspect `statusReason` and the endpoint's instructions. | -| `expired` | Transfers | Inspect source funding before starting a replacement. | -| `refunding` | Both | Keep the refund pending. | -| `refunded` | Both | Reconcile the refund amount and transaction references. | +| `processing` | Transfers | Source funds were verified and delivery is in progress. Keep the payment pending. | +| `completed` | Both | Reconcile `destinationAmount` and `destinationTransactionHashes`, then credit the recipient. | +| `action-required` | Both | Inspect `statusReason` and follow the endpoint's recovery instructions. | +| `expired` | Transfers | The quote window elapsed before funding. Inspect source transactions before starting a replacement. | +| `refunding` | Both | A refund to the source-chain refund address is in progress. Keep the refund pending. | +| `refunded` | Both | Reconcile `refundAmount` and `refundTransactionHashes` before updating the balance. | -Use the full [transfer](/docs/api/routes/transfers) or [deposit](/docs/api/routes/deposit-addresses) reference for the lifecycle and response fields. Do not automatically send the payment again when it is pending or being refunded. +Use the full [transfer](/docs/api/routes/transfers) or [deposit](/docs/api/routes/deposit-addresses) reference for the lifecycle and response fields. Don't automatically send a replacement payment while a transfer or deposit is pending or refunding. ## Track refunds -Keep `refunding` separate from `refunded`. Reconcile the returned refund amount and transaction references before updating the customer's balance. +Keep `refunding` separate from `refunded`. Reconcile the returned `refundAmount` and `refundTransactionHashes` against your source-chain refund address before updating the customer's balance. ## Retry without duplicates -If a create request gets no response, the object may still exist. Retry with the same [idempotency key](/docs/routes/api-setup#set-idempotency-keys) and unchanged inputs to receive the original result before creating a replacement. +If a transfer or deposit-address create request gets no response, the object may still exist. Retry with the same `idempotency-key` header ([idempotency keys](/docs/routes/api-setup#set-idempotency-keys)) and unchanged inputs to receive the original result before creating a replacement. ## Use funds after delivery -After the destination account receives stablecoins, it can [send a payment](/docs/guide/payments/send-a-payment), [deposit into Earn](/docs/earn/integrate), or [deposit into a Zone](/docs/zones/deposit). Each is a separate operation. Direct Routes transfers into a vault or Zone are not implemented; their endpoints return HTTP `501`. +Once a route reaches `completed` and the destination account holds the delivered stablecoins, your application can [send a payment](/docs/guide/payments/send-a-payment), [deposit into an Earn vault](/docs/earn/integrate), or [deposit into a private Zone](/docs/zones/deposit). Each is a separate operation; direct Routes transfers into a vault or Zone aren't implemented and return HTTP `501`. diff --git a/src/pages/docs/routes/quotes.mdx b/src/pages/docs/routes/quotes.mdx index 6620359c2..f5c55d3fa 100644 --- a/src/pages/docs/routes/quotes.mdx +++ b/src/pages/docs/routes/quotes.mdx @@ -1,54 +1,82 @@ --- title: "Quotes and fees" seoTitle: "Quotes and fees | Tempo Docs" -description: "Choose the fixed amount, read destination amounts, fees, and expiry, and offer 1:1 delivery before a transfer or deposit." +description: "Understand dynamic Routes pricing, compare binding transfer quotes with indicative deposit estimates, show payment terms, and offer 1:1 delivery." ogImage: /og/2026-q4/og_2026-q4_docs_routes-quotes_title-f5_v02.png --- # Quotes and fees -Quote the payment before requesting a signature or showing deposit instructions. The route directory lists possible paths; the quote gives terms for the selected amount and recipient. +Quote a [Tempo Routes](/docs/routes) payment before requesting a wallet signature or showing deposit instructions. The [route directory](/docs/routes/networks) (`GET /v1/routes`) lists supported network and token pairs; a live quote returns current amounts, minimums, and fees for a specific transfer amount and recipient. ## Request a quote -Each flow starts with a quote request that needs `routes:read`: +Routes supports two flows: **deposit addresses** (a reusable source-chain address that senders fund from any wallet) and **transfers** (source-chain calls signed by your user's wallet or backend signer). Each flow starts with a quote request authenticated with an API key carrying the `routes:read` scope: | Flow | Endpoint | Request builder | | --- | --- | --- | | Deposit address | `GET /v1/routes/deposit-addresses/quote` | [Quote the deposit](/docs/routes/deposits#quote-the-deposit) | | Transfer | `GET /v1/routes/transfers/quote` | [Get a quote](/docs/routes/transfers#get-a-quote) | +Both quote endpoints return `sourceAmount` (amount sent), `destinationAmount` (expected amount received after route deductions), `destinationAmountMin` (guaranteed minimum received, when binding), `fees[]` (any fees charged separately from the routed amount), and `quote.expiresAt` (when the quote stops being valid, when applicable). + +## How Routes pricing works + +Routes pricing is quote-based and dynamic. There isn't a static global fee schedule across routes or networks. + +Total cost depends on the route, transfer size, and live market conditions at quote time, and reflects up to three components: + +- **Variable route and liquidity cost.** Scales with transfer size and route liquidity. +- **Network settlement and withdrawal cost.** Reflects chain-specific delivery costs and can appear as a flat per-transfer component on some networks. +- **Live exchange rate.** Applies to cross-asset pairs, such as USDT to USDC or [FX routes](/docs/routes/fx), based on market pricing at quote time. + +Always fetch a fresh quote for the user's amount and pair instead of publishing a fixed fee table. + +### Binding and indicative quotes + +Transfer quotes and deposit-address quotes carry different price guarantees: + +- **Transfers are binding once created.** `GET /v1/routes/transfers/quote` returns a non-zero `destinationAmountMin` and `quote.expiresAt`. When you create the transfer before `quote.expiresAt`, `destinationAmountMin` is the guaranteed minimum the recipient receives. +- **Deposit-address quotes are indicative.** Unless the route uses a [1:1 subsidy](#offer-11-delivery), deposits are repriced when funds arrive onchain. `destinationAmountMin` is `0` (or omitted) when there is no binding floor, so treat the quoted `destinationAmount` as an estimate. + ## Choose which amount to fix -For a transfer, choose which side the `mode` parameter fixes: +For a transfer, choose which side the `mode` parameter fixes. Pass `amount` in integer token base units (the token's smallest unit, such as `1000000` for `1.00` of a 6-decimal stablecoin): | Your application specifies | Amount mode | `amount` uses | | --- | --- | --- | | How much to send | `exactSource` | Source token base units | | How much the recipient should receive | `exactDestination` | Destination token base units | -Review the returned amounts and minimum destination amount before continuing. +Review the returned `sourceAmount`, `destinationAmount`, and `destinationAmountMin` before creating the transfer. -For a deposit address, quote the source chain, source token, destination token, and amount. Check the [endpoint reference](/docs/api/routes/deposit-addresses) for the supported parameters. +For a deposit address, pass the source chain, source token, destination token, and `amount` (along with `recipient` and `refundAddress`). Check the [Deposit addresses API reference](/docs/api/routes/deposit-addresses) for every query parameter. ## Show the payment terms -Show the source asset and amount, destination asset and amount, minimum destination amount where returned, and fees. Show the network next to each asset, since the same symbol exists on several networks. +Display the live quote's `sourceAmount` and `destinationAmount`, with the network name next to each asset because the same symbol exists on several networks. -`destinationAmount` already includes route deductions. The `fees` array lists only separately charged fees, so an empty array can still come with deductions. +- **Binding transfers.** Show `destinationAmountMin` as the guaranteed minimum received and refresh the quote if `quote.expiresAt` passes before transfer creation. +- **Unsubsidized deposits.** Label `destinationAmount` as an estimate, because unsubsidized deposits reprice when funds arrive onchain. +- **Fees.** Display any entries in `fees[]` separately. `destinationAmount` already reflects route deductions (such as routing and liquidity costs), while `fees[]` lists only fees charged separately from the routed amount—so `fees[]` can be empty even when deductions apply. -A quote doesn't create or reserve a transfer. Check the terms returned when you create the transfer before asking the signer to sign. +A quote doesn't reserve liquidity or create a transfer. Transfer creation locks the executable terms and returns the updated amounts alongside the unsigned calls; verify those returned terms before asking the user's wallet or backend signer to sign. ## Offer 1:1 delivery -Where your organization is approved for subsidies, send `subsidize: true` on the quote and the create request. Tempo then guarantees normalized 1:1 delivery: the recipient receives the amount sent, and `destinationAmountRequired` shows that guaranteed amount. Transfers support this for `exactSource` only. +To give end users deterministic 1:1 delivery, send `subsidize: true` on both the quote and the create request. Route costs are then covered—either organization-paid or Tempo-paid, depending on the subsidy policy Tempo configured for your organization—rather than deducted from what the recipient receives. + +When subsidies apply, Tempo guarantees 1:1 delivery normalized for any decimal difference between source and destination tokens (for example, 6-decimal to 6-decimal delivers the exact unit amount). The response's `destinationAmountRequired` field shows that guaranteed 1:1 amount, matching `destinationAmount` and `destinationAmountMin`. + +- **Transfers.** Support `subsidize: true` with `mode: exactSource` only (not `exactDestination`). +- **Deposit addresses.** Support `subsidize: true` on eligible routes, giving subsidized deposits a guaranteed 1:1 delivery floor rather than an unsubsidized estimate. -The route directory's `subsidies` field shows which funding methods accept a subsidy on each route. Without approval, the API rejects the request with a `routes_subsidy_*` error code. [Try a route](/docs/routes/test) with your key to see whether a subsidy applies. +Check the `subsidies` field on each entry in the [route directory](/docs/routes/networks) (`GET /v1/routes`) to see which funding methods accept subsidies on that route. Without organization subsidy approval—or if a request exceeds configured subsidy limits—the API rejects the request with a `routes_subsidy_*` error (such as `routes_subsidy_not_enabled`, `routes_subsidy_limit_exceeded`, or `routes_subsidy_budget_exhausted`). [Try a route](/docs/routes/test) with your key to check whether a subsidy applies. ## Refresh expired quotes Read `quote.expiresAt` when it is returned. If the quote expires before submission, request a new one and show any changed terms to the user. -Continue with [Accept deposits](/docs/routes/deposits) or [Make a transfer](/docs/routes/transfers). +Continue with [Accept deposits](/docs/routes/deposits), [Make a transfer](/docs/routes/transfers), or [Track delivery](/docs/routes/delivery). diff --git a/vocs.config.ts b/vocs.config.ts index 0fd5f4eca..09f3c7f70 100644 --- a/vocs.config.ts +++ b/vocs.config.ts @@ -387,6 +387,7 @@ export default defineConfig({ hide: ['MCP', 'Apps', 'Routes Access Requests', 'Zone Delegations'], // Each guide sits inside the endpoint group it explains. groupItems: { + Webhooks: [{ text: 'Guide', link: '/docs/api/webhooks-guide' }], 'JSON-RPC': [{ text: 'Guide', link: '/docs/api/json-rpc' }], Indexer: [{ text: 'Guide', link: '/docs/api/indexer-api' }], 'API keys': [{ text: 'Guide', link: '/docs/api/console/api-keys' }],