### Create Session Response Example (OpenAPI) Source: https://docs.daimo.com/api-reference/create-session Example of a successful response when creating a deposit session. Includes session details and a client secret. ```yaml session: sessionId: a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4 status: requires_payment_method destination: type: evm address: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045' chainId: 8453 chainName: Base tokenAddress: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' tokenSymbol: USDC amountUnits: '10.00' display: title: Deposit to Acme verb: Deposit paymentMethod: null metadata: null clientSecret: d7a8f3b2e1c94a6db8f0e2a7c3d5b9f1 createdAt: 1700000000 expiresAt: 1700003600 ``` -------------------------------- ### Install Daimo SDK Source: https://docs.daimo.com/guides/modal Install the Daimo SDK using npm. Ensure you have React version 18 or higher as a peer dependency. ```bash npm install @daimo/sdk ``` -------------------------------- ### Solana Payment Method Request Example Source: https://docs.daimo.com/api-reference/create-payment-method This example demonstrates the structure for a Solana payment method request, requiring the user's wallet address, the input token mint, and the amount in USD. ```json { "type": "solana", "walletAddress": "user_solana_address", "inputTokenMint": "solana_token_mint_address", "amountUsd": 10 } ``` -------------------------------- ### Setup DaimoSDKProvider Source: https://docs.daimo.com/guides/modal Wrap your application with DaimoSDKProvider and import the necessary CSS theme file. This is required for the Daimo components to function correctly. ```tsx import { DaimoSDKProvider } from "@daimo/sdk/web"; import "@daimo/sdk/web/theme.css"; function App() { return {/* your app */}; } ``` -------------------------------- ### Create Payment Method Response Example (EVM) Source: https://docs.daimo.com/api-reference/create-payment-method This example shows a successful response when an EVM payment method is created. It includes session details, destination information (like receiver address and chain details), and payment method specifics. ```json { "session": { "sessionId": "a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4", "status": "waiting_payment", "destination": { "type": "evm", "address": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", "chainId": 8453, "chainName": "Base", "tokenAddress": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "tokenSymbol": "USDC", "amountUnits": "10.00" }, "display": { "title": "Deposit to Acme", "verb": "Deposit" }, "paymentMethod": { "type": "evm", "receiverAddress": "0x1234567890abcdef1234567890abcdef12345678", "createdAt": 1700000000 }, "createdAt": 1700000000, "expiresAt": 1700003600 } } ``` -------------------------------- ### Tron Payment Method Request Example Source: https://docs.daimo.com/api-reference/create-payment-method This example shows how to specify a Tron payment method in the request, including the required amount in USD. ```json { "type": "tron", "amountUsd": 10 } ``` -------------------------------- ### Create Session Request Example (OpenAPI) Source: https://docs.daimo.com/api-reference/create-session Example of a request body to create an EVM deposit session. Specifies destination details and display information. ```yaml openapi: 3.1.0 info: title: Daimo API version: 1.0.0 description: Create deposit sessions, manage payment methods, and check session status. servers: - url: https://api.daimo.com security: [] paths: /v1/sessions: post: summary: Create session description: >- Creates a new deposit session. Returns the session object including a client secret for client-side operations. requestBody: content: application/json: schema: $ref: '#/components/schemas/CreateSessionRequest' example: destination: type: evm address: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045' chainId: 8453 tokenAddress: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' amountUnits: '10.00' display: title: Deposit to Acme verb: Deposit responses: '201': description: Session created content: application/json: schema: $ref: '#/components/schemas/CreateSessionResponse' example: session: sessionId: a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4 status: requires_payment_method destination: type: evm address: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045' chainId: 8453 chainName: Base tokenAddress: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' tokenSymbol: USDC amountUnits: '10.00' display: title: Deposit to Acme verb: Deposit paymentMethod: null metadata: null clientSecret: d7a8f3b2e1c94a6db8f0e2a7c3d5b9f1 createdAt: 1700000000 expiresAt: 1700003600 '400': description: Invalid request content: application/json: schema: $ref: '#/components/schemas/V1ErrorResponse' '401': description: Invalid or missing API key content: application/json: schema: $ref: '#/components/schemas/V1ErrorResponse' security: - BearerAuth: [] components: schemas: CreateSessionRequest: type: object properties: destination: oneOf: - type: object properties: type: type: string enum: - evm description: Always "evm" address: type: string pattern: ^0x[0-9a-fA-F]{40}$ description: Checksummed destination address chainId: type: number description: Destination chain ID (e.g. 8453 for Base) example: 8453 tokenAddress: type: string pattern: ^0x[0-9a-fA-F]{40}$ description: Checksummed destination token address example: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' amountUnits: type: string description: >- Fixed deposit amount in token units (e.g. "10.00" for $10 USDC) example: '10.00' calldata: type: string pattern: ^0x[0-9a-fA-F]*$ description: >- Hex-encoded calldata for a contract call on the destination address required: - type - address - chainId - tokenAddress - type: object properties: type: type: string enum: - solana description: Always "solana" address: type: string pattern: ^[1-9A-HJ-NP-Za-km-z]{32,44}$ description: Base58 destination address tokenAddress: type: string pattern: ^[1-9A-HJ-NP-Za-km-z]{32,44}$ description: Destination token mint (base58). USDC only. example: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v amountUnits: type: string description: >- Fixed deposit amount in token units (e.g. "10.00" for $10 USDC) example: '10.00' required: - type - address - tokenAddress display: type: object ``` -------------------------------- ### Create Payment Method Request Example (EVM) Source: https://docs.daimo.com/api-reference/create-payment-method This example demonstrates the request body for creating an EVM payment method for a session. It includes the session's client secret and specifies the payment method type as 'evm'. ```json { "clientSecret": "d7a8f3b2e1c94a6db8f0e2a7c3d5b9f1", "paymentMethod": { "type": "evm" } } ``` -------------------------------- ### Exchange Payment Method Request Example Source: https://docs.daimo.com/api-reference/create-payment-method This example shows the request body for an exchange payment method, specifying the exchange ID. ```json { "type": "exchange", "exchangeId": "exchange_id" } ``` -------------------------------- ### Example Custom Theme CSS Source: https://docs.daimo.com/guides/sessions This CSS file defines custom properties to theme Daimo modals and webviews. Host this file on a publicly accessible URL and link it in your integration. ```css :root { --daimo-bg: #f5f0eb; --daimo-surface: #ffffff; --daimo-surface-secondary: #faf7f4; --daimo-accent: #e85d04; --daimo-text: #1a1a1a; --daimo-text-secondary: #6b6b6b; --daimo-border: #e0dcd7; --daimo-radius-lg: 16px; } ``` -------------------------------- ### Create Fiat Payment Method (TypeScript SDK) Source: https://docs.daimo.com/guides/fiat This TypeScript SDK example demonstrates how to create a fiat payment method. Ensure you have the session ID and client secret. ```typescript const result = await daimo.sessions.paymentMethods.create(sessionId, { clientSecret: "SESSION_CLIENT_SECRET", paymentMethod: { type: "fiat", fiatMethod: "interac" }, }); ``` -------------------------------- ### Create a Session with Specific Payment Options Source: https://docs.daimo.com/advanced/sessions Example of creating a new session using the Daimo API. This snippet shows how to set the destination details, including the EVM chain, token, and amount, along with display preferences like title, verb, and specific payment options (Coinbase, Binance). ```bash curl -X POST https://api.daimo.com/v1/sessions \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "destination": { "type": "evm", "address": "0xYourAddress", "chainId": 8453, "tokenAddress": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "amountUnits": "10.00" }, "display": { "title": "Deposit USDC", "verb": "Deposit", "paymentOptions": ["Coinbase", "Binance"] } }' ``` -------------------------------- ### Fiat Payment Method Configuration Source: https://docs.daimo.com/guides/custom-integration Example configuration for a fiat payment method, including the hosted URL and payment method type. Store the hosted URL for client-side use. ```json { "fiat": { "hostedUrl": "https://daimo.com/webview?session=...&cs=...", "fiatMethod": "interac" } } ``` -------------------------------- ### Example Session Succeeded Event Payload Source: https://docs.daimo.com/guides/webhooks This is an example of a JSON payload for a 'session.succeeded' event. It includes details about the session, its status, and associated data. ```json { "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "type": "session.succeeded", "createdAt": 1700000000, "data": { "session": { "sessionId": "abcdef1234567890abcdef1234567890", "status": "succeeded", "destination": { "type": "evm", "address": "0x...", "chainId": 8453, "chainName": "Base", "tokenAddress": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "tokenSymbol": "USDC", "amountUnits": "10.00", "delivery": { "txHash": "0x...", "receivedUnits": "10.00" } }, "display": { "title": "Deposit to Acme", "verb": "Deposit" }, "paymentMethod": { "type": "evm", "receiverAddress": "0x...", "createdAt": 1700000000 }, "metadata": { "myUserId": "user_123" }, "createdAt": 1700000000, "expiresAt": 1700003600 } } } ``` -------------------------------- ### Solana Destination Configuration Source: https://docs.daimo.com/guides/custom-integration Example JSON configuration for a Solana destination in a deposit session. This is used when delivering to Solana, specifically for USDC, by setting the 'type' to 'solana' and providing the correct token address and base58 wallet address. ```json "destination": { "type": "solana", "address": "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU", "tokenAddress": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "amountUnits": "10.00" } ``` -------------------------------- ### Create Payment Method Session Source: https://docs.daimo.com/api-reference/create-payment-method Initiates a payment session to create a new payment method. This endpoint is used to start the process of setting up a payment method, returning necessary details for the client-side SDK or redirect. ```APIDOC ## POST /sessions ### Description Creates a new payment session. This is the first step in the payment method creation flow, providing the client with the necessary information to proceed with the payment. ### Method POST ### Endpoint /sessions ### Request Body - **onrampSessionClientSecret** (string) - Required - Stripe OnrampSession client secret scoped to this onramp session. This is not the Stripe API secret key. - **publishableKey** (string) - Required - Stripe publishable key for the onramp SDK. - **redirectUrl** (string) - Required - Stripe-hosted onramp URL. ### Response #### Success Response (200) - **session** (object) - Required - Contains Stripe-specific response data. - **onrampSessionClientSecret** (string) - Required - Stripe OnrampSession client secret scoped to this onramp session. - **publishableKey** (string) - Required - Stripe publishable key for the onramp SDK. - **redirectUrl** (string) - Required - Stripe-hosted onramp URL. #### Error Response (4xx/5xx) - **error** (object) - Required - Details about the error. - **type** (string) - Required - Error category (e.g., `validation_error`). - **code** (string) - Required - Machine-readable error code (e.g., `invalid_parameter`). - **message** (string) - Required - Human-readable description of the error. - **param** (string) - Optional - Parameter that caused the error. ``` -------------------------------- ### Create Session with Prefilled Amount Source: https://docs.daimo.com/advanced/sessions Use this to lock the deposit to an exact amount, skipping user amount selection. The user proceeds directly to the payment flow. ```bash curl -X POST https://api.daimo.com/v1/sessions \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "destination": { "type": "evm", "address": "0xYourAddress", "chainId": 8453, "tokenAddress": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "amountUnits": "25.00" }, "display": { "title": "Deposit to Acme", "verb": "Deposit" } }' ``` -------------------------------- ### Embed WebView with Dynamic Height Source: https://docs.daimo.com/guides/webview Example of how to use the `layout=embed` parameter and handle `contentHeightChanged` events in React Native to fit the WebView to its content. ```tsx const [height, setHeight] = useState(480); const handleMessage = (event: { nativeEvent: { data: string } }) => { const msg = JSON.parse(event.nativeEvent.data); if (msg.type === "contentHeightChanged") { setHeight(msg.payload.height); } }; return ( ); ``` -------------------------------- ### Load WebView in React Native Source: https://docs.daimo.com/guides/webview Integrate the Daimo payment UI into a React Native application using the 'react-native-webview' component. This example shows how to handle messages from the WebView. ```tsx import { WebView } from "react-native-webview"; function PaymentWebView({ sessionId, clientSecret, }: { sessionId: string; clientSecret: string; }) { const uri = `https://daimo.com/webview?session=${sessionId}&cs=${clientSecret}`; const handleMessage = (event: { nativeEvent: { data: string } }) => { const msg = JSON.parse(event.nativeEvent.data); switch (msg.type) { case "ready": console.log("Payment UI loaded"); break; case "contentHeightChanged": console.log("Payment UI height", msg.payload.height); break; case "paymentStarted": console.log("Payment initiated"); break; case "paymentCompleted": console.log("Payment succeeded"); break; } }; return ( ); } ``` -------------------------------- ### Create Session with Contract Call Source: https://docs.daimo.com/advanced/sessions Use this to execute an arbitrary contract call with deposited funds. Ensure a `refundAddress` is provided for error handling if the contract call reverts. ```bash curl -X POST https://api.daimo.com/v1/sessions \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "destination": { "type": "evm", "address": "0xYourContract", "chainId": 8453, "tokenAddress": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "amountUnits": "100.00", "calldata": "0x..." }, "display": { "title": "Stake USDC", "verb": "Stake" }, "refundAddress": "0xYourRefundAddress" }' ``` -------------------------------- ### Configure Payment Options with Nested Arrays Source: https://docs.daimo.com/advanced/sessions Demonstrates how to specify payment options using nested arrays to control the display order of exchanges and wallets. This is useful for prioritizing certain payment methods or wallet providers. ```json { "paymentOptions": ["AllExchanges", ["MetaMask", "Trust", "Phantom"]] } ``` -------------------------------- ### Get Session Information Source: https://docs.daimo.com/api-reference/create-payment-method Retrieves the current status and details of a payment session using its ID. This is useful for polling the session status or displaying relevant information to the user. ```APIDOC ## GET /sessions/{sessionId} ### Description Retrieves the public information for a given payment session ID. ### Method GET ### Endpoint /sessions/{sessionId} ### Parameters #### Path Parameters - **sessionId** (string) - Required - 32-character hex session ID. ### Response #### Success Response (200) - **sessionId** (string) - Required - Session ID. - **status** (string) - Required - Current session status (e.g., `requires_payment_method`, `waiting_payment`, `processing`, `succeeded`, `bounced`, `expired`). - **destination** (object) - Required - Details about the destination. - **display** (object) - Required - Display information for the payment modal. - **title** (string) - Required - Title shown in the payment modal. - **verb** (string) - Required - One-word verb for CTAs (e.g., `Deposit`). - **themeCssUrl** (string) - Optional - Custom theme CSS URL. - **paymentMethod** (object or null) - Optional - Details about the payment method used or created. - **createdAt** (number) - Required - Unix timestamp (seconds) when the session was created. - **expiresAt** (number) - Required - Unix timestamp (seconds) when the session expires. #### Error Response (4xx/5xx) - **error** (object) - Required - Details about the error. - **type** (string) - Required - Error category (e.g., `validation_error`). - **code** (string) - Required - Machine-readable error code (e.g., `invalid_parameter`). - **message** (string) - Required - Human-readable description of the error. - **param** (string) - Optional - Parameter that caused the error. ``` -------------------------------- ### Fiat Payment Method (Basic) Source: https://docs.daimo.com/guides/sessions Initiate a hosted fiat deposit. The response includes a fiat method and creation timestamp. ```json { "type": "fiat", "fiatMethod": "interac", "createdAt": 1700000000 } ``` -------------------------------- ### Create a Session (cURL) Source: https://docs.daimo.com/guides/custom-integration Use this cURL command to create a new deposit session on your server. Ensure your API key is kept secret and not exposed to the client. ```bash curl -X POST https://api.daimo.com/v1/sessions \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "destination": { "type": "evm", "address": "0xYourAddress", "chainId": 8453, "tokenAddress": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "amountUnits": "10.00" }, "display": { "title": "Deposit to Acme", "verb": "Deposit", "paymentOptions": ["AllFiat"] } }' ``` -------------------------------- ### Create webhook endpoint Source: https://docs.daimo.com/api-reference/create-webhook-endpoint Creates a new webhook endpoint. The response includes the full HMAC signing secret, which is only shown during creation. Refer to the webhook verification guide for more details on verifying signatures. ```APIDOC ## POST /v1/webhooks ### Description Creates a new webhook endpoint. The response includes the full HMAC signing secret (shown only on creation). See [webhook verification](https://docs.daimo.com/guides/webhooks#verify-signatures) for more information. ### Method POST ### Endpoint /v1/webhooks ### Parameters #### Request Body - **url** (string) - Required - HTTPS URL that will receive POST requests - **events** (array) - Optional - Event types to subscribe to. Defaults to ["*"] - Items: (string) - Enum: "*", "session.processing", "session.succeeded", "session.bounced" - **description** (string) - Optional - Human-readable label for this endpoint ### Request Example { "url": "https://example.com/webhooks/daimo", "events": ["session.succeeded"], "description": "My first webhook" } ### Response #### Success Response (201) - **webhook** (object) - Description of the created webhook - **id** (string) - Webhook endpoint ID - **url** (string) - Delivery URL - **events** (array) - Subscribed event types (["*"] for all) - Items: (string) - Enum: "*", "session.processing", "session.succeeded", "session.bounced" - **description** (string) - Human-readable label - **secret** (string) - HMAC signing secret (full on create, redacted on list/get) - **createdAt** (number) - Unix timestamp (seconds) #### Response Example { "webhook": { "id": "we_12345", "url": "https://example.com/webhooks/daimo", "events": ["session.succeeded"], "description": "My first webhook", "secret": "whsec_abcdef1234567890", "createdAt": 1700000000 } } #### Error Response (400, 401) - **error** (object) - **type** (string) - Error category - **code** (string) - Machine-readable error code - **message** (string) - Human-readable description - **param** (string) - Parameter that caused the error ``` -------------------------------- ### Retrieve Webhook Endpoint (OpenAPI) Source: https://docs.daimo.com/api-reference/retrieve-webhook-endpoint This OpenAPI definition describes the GET request to retrieve a webhook endpoint by its ID. It includes parameters, responses for success and errors, and component schemas for request and response bodies. ```yaml openapi: 3.1.0 info: title: Daimo API version: 1.0.0 description: Create deposit sessions, manage payment methods, and check session status. servers: - url: https://api.daimo.com security: [] paths: /v1/webhooks/{webhookId}: get: summary: Retrieve webhook endpoint description: Retrieves a single webhook endpoint by ID. Secret is redacted. parameters: - $ref: '#/components/parameters/WebhookId' responses: '200': description: Webhook endpoint content: application/json: schema: $ref: '#/components/schemas/RetrieveWebhookResponse' '404': description: Webhook not found content: application/json: schema: $ref: '#/components/schemas/V1ErrorResponse' security: - BearerAuth: [] components: parameters: WebhookId: schema: $ref: '#/components/schemas/WebhookId' required: true name: webhookId in: path schemas: RetrieveWebhookResponse: type: object properties: webhook: $ref: '#/components/schemas/Webhook' required: - webhook V1ErrorResponse: type: object properties: error: type: object properties: type: type: string description: Error category example: validation_error code: type: string description: Machine-readable error code example: invalid_parameter message: type: string description: Human-readable description example: invalid session create request param: type: string description: Parameter that caused the error example: body required: - type - code - message required: - error WebhookId: type: string description: Webhook endpoint ID example: 02ab4563-07ee-4373-8472-9c7dc1027409 Webhook: type: object properties: id: type: string description: Webhook endpoint ID url: type: string format: uri description: Delivery URL events: type: array items: type: string enum: - '*' - session.processing - session.succeeded - session.bounced description: Webhook event type (or * for all events) example: session.succeeded description: Subscribed event types (["*"] for all) description: type: - string - 'null' description: Human-readable label secret: type: string description: HMAC signing secret (full on create, redacted on list/get) createdAt: type: number description: Unix timestamp (seconds) example: 1700000000 required: - id - url - events - description - secret - createdAt securitySchemes: BearerAuth: type: http scheme: bearer description: API key passed as a Bearer token ``` -------------------------------- ### EVM Deposit Source: https://docs.daimo.com/guides/custom-integration Use this snippet to initiate an EVM deposit. It transitions the session to 'waiting_payment' and provides a receiver address for the user to send tokens to. ```bash curl -X POST https://api.daimo.com/v1/sessions/{sessionId}/paymentMethods \ -H "Content-Type: application/json" \ -d '{ "clientSecret": "SESSION_CLIENT_SECRET", "paymentMethod": { "type": "evm" } }' ``` ```typescript import { createDaimoClient } from "@daimo/sdk/client"; const daimo = createDaimoClient({ baseUrl: "https://api.daimo.com" }); const result = await daimo.sessions.paymentMethods.create(sessionId, { clientSecret: "SESSION_CLIENT_SECRET", paymentMethod: { type: "evm" }, }); ``` -------------------------------- ### Create a Session (TypeScript/fetch) Source: https://docs.daimo.com/guides/custom-integration This TypeScript code snippet demonstrates creating a deposit session using the fetch API. It includes necessary headers and a JSON body for the request. The Daimo API key should be stored securely as an environment variable. ```typescript const response = await fetch("https://api.daimo.com/v1/sessions", { method: "POST", headers: { Authorization: `Bearer ${process.env.DAIMO_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ destination: { type: "evm", address: "0xYourAddress", chainId: 8453, tokenAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", amountUnits: "10.00", }, display: { title: "Deposit to Acme", verb: "Deposit", paymentOptions: ["AllFiat"], }, }), }); const { session } = await response.json(); ``` -------------------------------- ### Handle Incoming Webhooks Source: https://docs.daimo.com/guides/webhooks Set up an HTTP server to listen for POST requests on the webhook endpoint. This handler verifies the signature and processes different event types. ```typescript import { createServer } from "node:http"; import * as crypto from "crypto"; const WEBHOOK_SECRET = process.env.DAIMO_WEBHOOK_SECRET!; const server = createServer((req, res) => { if (req.method === "POST" && req.url === "/webhooks/daimo") { let body = ""; req.on("data", (chunk) => (body += chunk)); req.on("end", () => { const signature = req.headers["daimo-signature"] as string; if (!verifyWebhookSignature(WEBHOOK_SECRET, signature, body)) { res.writeHead(400).end("invalid signature"); return; } const event = JSON.parse(body); switch (event.type) { case "session.succeeded": // Handle successful delivery break; case "session.bounced": // Handle failed delivery break; } res.writeHead(200).end(); }); } }); server.listen(4242); ``` -------------------------------- ### List Webhook Endpoints OpenAPI Specification Source: https://docs.daimo.com/api-reference/list-webhook-endpoints This OpenAPI specification defines the GET /v1/webhooks endpoint. It outlines the request, response schemas, and authentication methods for listing webhook endpoints. Use this to understand the API contract for retrieving webhook configurations. ```yaml openapi: 3.1.0 info: title: Daimo API version: 1.0.0 description: Create deposit sessions, manage payment methods, and check session status. servers: - url: https://api.daimo.com security: [] paths: /v1/webhooks: get: summary: List webhook endpoints description: >- Lists all active webhook endpoints for the authenticated organization. Secrets are redacted. responses: '200': description: Webhook endpoints content: application/json: schema: $ref: '#/components/schemas/ListWebhooksResponse' '401': description: Invalid or missing API key content: application/json: schema: $ref: '#/components/schemas/V1ErrorResponse' security: - BearerAuth: [] components: schemas: ListWebhooksResponse: type: object properties: webhooks: type: array items: $ref: '#/components/schemas/Webhook' required: - webhooks V1ErrorResponse: type: object properties: error: type: object properties: type: type: string description: Error category example: validation_error code: type: string description: Machine-readable error code example: invalid_parameter message: type: string description: Human-readable description example: invalid session create request param: type: string description: Parameter that caused the error example: body required: - type - code - message required: - error Webhook: type: object properties: id: type: string description: Webhook endpoint ID url: type: string format: uri description: Delivery URL events: type: array items: type: string enum: - '*' - session.processing - session.succeeded - session.bounced description: Webhook event type (or * for all events) example: session.succeeded description: Subscribed event types (["*"] for all) description: type: - string - 'null' description: Human-readable label secret: type: string description: HMAC signing secret (full on create, redacted on list/get) createdAt: type: number description: Unix timestamp (seconds) example: 1700000000 required: - id - url - events - description - secret - createdAt securitySchemes: BearerAuth: type: http scheme: bearer description: API key passed as a Bearer token ``` -------------------------------- ### Handle Incoming Webhook Events (Node.js) Source: https://docs.daimo.com/guides/webhooks Set up a basic Node.js HTTP server to receive and process incoming webhook events. Remember to implement signature verification for production environments. ```typescript import { createServer } from "node:http"; const server = createServer((req, res) => { if (req.method === "POST" && req.url === "/webhooks/daimo") { let body = ""; req.on("data", (chunk) => (body += chunk)); req.on("end", () => { const event = JSON.parse(body); // TODO: verify signature (see below) switch (event.type) { case "session.succeeded": // Handle successful delivery break; case "session.bounced": // Handle failed delivery break; } res.writeHead(200).end(); }); } }); server.listen(4242); ``` -------------------------------- ### Construct WebView URL Source: https://docs.daimo.com/guides/webview Construct the WebView URL using the sessionId and clientSecret obtained from the session creation response. ```text https://daimo.com/webview?session={sessionId}&cs={clientSecret} ``` -------------------------------- ### POST /v1/sessions/{sessionId}/paymentMethods Source: https://docs.daimo.com/api-reference/create-payment-method Sets the payment method for a session. Transitions the session from requires_payment_method to waiting_payment and returns payment data for the selected method. EVM and Tron return receiver addresses, Solana returns a serialized transaction to sign, exchanges return a hosted payment URL plus waiting copy, and fiat returns a hosted URL. ```APIDOC ## POST /v1/sessions/{sessionId}/paymentMethods ### Description Sets the payment method for a session. Transitions the session from requires_payment_method to waiting_payment and returns payment data for the selected method. EVM and Tron return receiver addresses, Solana returns a serialized transaction to sign, exchanges return a hosted payment URL plus waiting copy, and fiat returns a hosted URL. ### Method POST ### Endpoint /v1/sessions/{sessionId}/paymentMethods ### Parameters #### Path Parameters - **sessionId** (string) - Required - The ID of the session. #### Request Body - **clientSecret** (string) - Required - Per-session client secret - **paymentMethod** (object) - Required - Details of the payment method. - **type** (string) - Required - The type of payment method (e.g., evm, tron, solana, exchange, fiat). - **amountUsd** (number) - Optional - Deposit amount in USD (for Tron, Solana, fiat). - **walletAddress** (string) - Optional - User's Solana wallet address (for Solana). - **inputTokenMint** (string) - Optional - Solana token mint address to pay with (for Solana). - **exchangeId** (string) - Optional - The ID of the exchange (for exchange). ### Request Example ```json { "clientSecret": "d7a8f3b2e1c94a6db8f0e2a7c3d5b9f1", "paymentMethod": { "type": "evm" } } ``` ### Response #### Success Response (201) - **session** (object) - Details of the session. - **sessionId** (string) - The ID of the session. - **status** (string) - The current status of the session (e.g., waiting_payment). - **destination** (object) - Details about the deposit destination. - **type** (string) - The type of destination (e.g., evm). - **address** (string) - The destination address. - **chainId** (number) - The chain ID. - **chainName** (string) - The name of the chain. - **tokenAddress** (string) - The token address. - **tokenSymbol** (string) - The token symbol. - **amountUnits** (string) - The amount in units. - **display** (object) - Display information for the user. - **title** (string) - The title to display. - **verb** (string) - The action verb (e.g., Deposit). - **paymentMethod** (object) - Details about the payment method used. - **type** (string) - The type of payment method. - **receiverAddress** (string) - The receiver address for the payment. - **createdAt** (number) - Timestamp when the payment method was created. - **createdAt** (number) - Timestamp when the session was created. - **expiresAt** (number) - Timestamp when the session expires. #### Response Example ```json { "session": { "sessionId": "a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4", "status": "waiting_payment", "destination": { "type": "evm", "address": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", "chainId": 8453, "chainName": "Base", "tokenAddress": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "tokenSymbol": "USDC", "amountUnits": "10.00" }, "display": { "title": "Deposit to Acme", "verb": "Deposit" }, "paymentMethod": { "type": "evm", "receiverAddress": "0x1234567890abcdef1234567890abcdef12345678", "createdAt": 1700000000 }, "createdAt": 1700000000, "expiresAt": 1700003600 } } ``` ### Error Handling - **400** - Invalid request - **401** - Invalid client secret - **404** - Session not found ``` -------------------------------- ### Create Session (Server-Side) Source: https://docs.daimo.com/quickstart Create a session on your server using your API key. The response contains a clientSecret to be used on the frontend. Never expose your API key to the client. ```typescript // In your API route handler: const response = await fetch("https://api.daimo.com/v1/sessions", { method: "POST", headers: { Authorization: `Bearer ${process.env.DAIMO_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ destination: { type: "evm", address: "0xYourAddress", chainId: 8453, // Base tokenAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC amountUnits: "10.00", // $10 USDC }, display: { title: "Deposit to Acme", verb: "Deposit", }, }), }); const { session } = await response.json(); // Return session.clientSecret and session.sessionId to the frontend ``` -------------------------------- ### Create Session with All Fiat Payment Options Source: https://docs.daimo.com/guides/fiat Use the `AllFiat` option in `display.paymentOptions` to allow users to choose from all available fiat rails. This snippet demonstrates creating a Daimo session with fiat deposit capabilities. ```typescript await fetch("https://api.daimo.com/v1/sessions", { method: "POST", headers: { Authorization: `Bearer ${process.env.DAIMO_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ destination: { type: "evm", address: "0xYourAddress", chainId: 8453, tokenAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", amountUnits: "25.00", }, display: { title: "Deposit to Acme", verb: "Deposit", paymentOptions: ["AllFiat"], }, }), }); ``` -------------------------------- ### Deposit to Hyperliquid via Daimo SDK Source: https://docs.daimo.com/advanced/hyperliquid Use this snippet to initiate a deposit to a Hyperliquid account. Ensure you have your API key and the correct recipient address. The `destinationDex` parameter determines whether funds are deposited to Perps or Spot. ```typescript import { hyperEvmUSDC } from "@daimo/sdk/common"; import { encodeFunctionData } from "viem"; const HYPERCORE_DEPOSIT_ADAPTER = "0x3Df610B9168472EfC3CD37ed5005c0e78946c308"; const calldata = encodeFunctionData({ abi: [ { name: "deposit", type: "function", inputs: [ { name: "recipient", type: "address" }, { name: "destinationDex", type: "uint32" }, ], outputs: [], stateMutability: "nonpayable", }, ], functionName: "deposit", args: [ "0xRecipientAddress", // Hypercore recipient 0, // 0 = perps, 0xFFFFFFFF = spot ], }); const res = await fetch("https://api.daimo.com/v1/sessions", { method: "POST", headers: { "Content-Type": "application/json", Authorization: "Bearer YOUR_API_KEY", }, body: JSON.stringify({ destination: { type: "evm", address: HYPERCORE_DEPOSIT_ADAPTER, chainId: hyperEvmUSDC.chainId, tokenAddress: hyperEvmUSDC.token, amountUnits: "10", calldata, }, display: { title: "Deposit to Hyperliquid", verb: "Deposit" } }), }); ```