{
  "openapi": "3.1.0",
  "info": {
    "title": "Cadmos Pay payment links API",
    "version": "1.0.0",
    "summary": "Create payment links from your own system and learn when they are paid.",
    "description": "A payment link is a checkout page on cadmospay.com. Your customer pays it in USDC or USDT from any supported network, or in cash with Whish; Cadmos settles every payment to your Cadmos Pay business wallet, less the Gateway Fee.\n\nCadmos sets up your access by hand: it gives you an identity id, and you give it the address of a signing key you generated (an Ethereum key that holds no funds) and, if you want webhooks, an https URL.\n\nThis file is the contract. Fields are added over time: ignore the ones you do not know. Fields are never removed or renamed without a new major version."
  },
  "servers": [
    {
      "url": "https://api.cadmospay.com",
      "description": "Payment links"
    }
  ],
  "tags": [
    {
      "name": "Sign in",
      "description": "A 15-minute access token, obtained by signing a challenge with your key. There is no refresh token: sign a new challenge."
    },
    {
      "name": "Payment links"
    },
    {
      "name": "Settlements",
      "description": "Each payment, once it is credited to your wallet. Also sent to your webhook."
    }
  ],
  "security": [
    {
      "accessToken": []
    }
  ],
  "paths": {
    "/v1/external-auth/challenge": {
      "servers": [
        {
          "url": "https://auth.cadmos.finance"
        }
      ],
      "post": {
        "tags": ["Sign in"],
        "operationId": "createChallenge",
        "summary": "Get a challenge to sign",
        "description": "Answers a sign-in message that expires in two minutes. Sign it unchanged with EIP-191 (`signMessage`) using your key. Check before signing that it names `auth.cadmos.finance`, your identity and the audience `cadmos-pay-be`.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChallengeRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The challenge.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Challenge"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/SignInInvalid"
          },
          "401": {
            "$ref": "#/components/responses/SignInRefused"
          },
          "503": {
            "$ref": "#/components/responses/SignInUnavailable"
          }
        }
      }
    },
    "/v1/external-auth/token": {
      "servers": [
        {
          "url": "https://auth.cadmos.finance"
        }
      ],
      "post": {
        "tags": ["Sign in"],
        "operationId": "createToken",
        "summary": "Exchange the signed challenge for an access token",
        "description": "A challenge is used once. Send the token as `Authorization: Bearer <accessToken>` to api.cadmospay.com only.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TokenRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The access token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Token"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/SignInInvalid"
          },
          "401": {
            "$ref": "#/components/responses/SignInRefused"
          },
          "503": {
            "$ref": "#/components/responses/SignInUnavailable"
          }
        }
      }
    },
    "/v1/external-auth/webhook-signers": {
      "servers": [
        {
          "url": "https://auth.cadmos.finance"
        }
      ],
      "get": {
        "tags": ["Settlements"],
        "operationId": "listWebhookSigners",
        "summary": "Addresses that sign webhooks",
        "description": "Cache the list. When a signature recovers to an address you do not know, read it again once: during a key rotation it holds two addresses.",
        "security": [],
        "responses": {
          "200": {
            "description": "The signer addresses.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookSigners"
                }
              }
            }
          },
          "503": {
            "$ref": "#/components/responses/SignInUnavailable"
          }
        }
      }
    },
    "/machine/v1/gateway/links": {
      "post": {
        "tags": ["Payment links"],
        "operationId": "createLink",
        "summary": "Create a payment link",
        "description": "The link belongs to your business wallet. Send the `checkoutUrl` to your customer.\n\nAlways send a `requestId`: it becomes the link's `uuid`, so retrying a create that timed out returns the same link instead of a second one. Limits: 30 creates a minute and 500 a day.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateLinkRequest"
              },
              "examples": {
                "fixedAmount": {
                  "summary": "An order of $100",
                  "value": {
                    "description": "Order #42",
                    "externalReference": "order-42",
                    "requestId": "0b6f5a8e-1c2d-4e3f-9a8b-7c6d5e4f3a2b",
                    "amountUsd": "100.00",
                    "localMethods": ["whish"]
                  }
                },
                "openAmount": {
                  "summary": "The payer chooses what to send",
                  "value": {
                    "description": "Donation",
                    "externalReference": "donation-7",
                    "requestId": "5d4c3b2a-1f0e-4d9c-8b7a-6f5e4d3c2b1a"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The link, ready to pay.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedLink"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "`GATEWAY_LINK_NOT_FOUND`: another business already used this `requestId`. Send a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "`GATEWAY_REQUEST_CONFLICT`: this `requestId` was used with another description, reference or amount. `GATEWAY_LINK_VOID`: its link was voided. Send a new `requestId` for a new link.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "5XX": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      },
      "get": {
        "tags": ["Payment links"],
        "operationId": "readLink",
        "summary": "Read a payment link",
        "description": "What the link received, and on a link with an amount whether it is paid. A webhook is one payment: read the link to learn whether the order is paid. Limit: 120 reads a minute, shared with the settlements list.",
        "parameters": [
          {
            "name": "uuid",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
            },
            "description": "The link's uuid."
          }
        ],
        "responses": {
          "200": {
            "description": "The link.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Link"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "`GATEWAY_LINK_NOT_FOUND`: no link of yours has this uuid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "5XX": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/machine/v1/gateway/settlements": {
      "get": {
        "tags": ["Settlements"],
        "operationId": "listSettlements",
        "summary": "List settlements",
        "description": "Your settlements, oldest first, 100 a page; follow `cursor=<next>` until `next` is `null`. Send `since` or `cursor`, never both; neither starts from the beginning.\n\nThis is the catch-up for webhooks. To resume, ask `since` the time of your last sync minus a few minutes and drop the `id`s you already have: a settlement can be recorded slightly after one stamped later. It also lists payments to the links you made in the app (`externalReference: null`).",
        "parameters": [
          {
            "name": "since",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "ISO 8601 time with a `Z`, inclusive."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^\\d{13}\\.\\d{1,10}$"
            },
            "description": "The `next` of the previous page."
          }
        ],
        "responses": {
          "200": {
            "description": "One page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SettlementPage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "5XX": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    }
  },
  "webhooks": {
    "settlement": {
      "post": {
        "tags": ["Settlements"],
        "operationId": "settlementWebhook",
        "summary": "A payment was credited to your wallet",
        "description": "One `POST` to your webhook URL per settled payment, with `User-Agent: Cadmos-Webhooks/1`. The body is one settlement, as in the list.\n\nVerify the signature against the exact bytes received, and refuse a timestamp more than 300 seconds from your clock:\n\n```js\nconst { createHash } = require('crypto');\nconst { verifyMessage } = require('ethers');\n\n// rawBody: the exact bytes received. signers: the addresses from GET /v1/external-auth/webhook-signers.\nfunction verifyCadmosWebhook(rawBody, headers, signers) {\n  const timestamp = headers['x-cadmos-timestamp'];\n  if (!/^\\d+$/.test(timestamp) || Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false;\n  try {\n    const digest = createHash('sha256').update(rawBody).digest('hex');\n    const message = `${timestamp}.${JSON.parse(rawBody).id}.${digest}`;\n    return signers.includes(verifyMessage(message, headers['x-cadmos-signature']));\n  } catch {\n    return false;\n  }\n}\n```\n\nDelivery is at least once: answer 2xx only after storing the payment, and drop an `id` you already have. Any other answer, a redirect (never followed) or no answer within 10 seconds is retried: 1 minute later, doubling up to 1 hour, until 3 days after the settlement. The settlements list has everything a webhook missed.",
        "security": [],
        "parameters": [
          {
            "name": "X-Cadmos-Timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^\\d+$"
            },
            "description": "Unix seconds when this attempt was sent."
          },
          {
            "name": "X-Cadmos-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^0x[0-9a-fA-F]{130}$"
            },
            "description": "EIP-191 signature over `<X-Cadmos-Timestamp>.<id>.<sha256 hex of the body>`."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Settlement"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Stored. Any other answer is retried."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "accessToken": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "The `accessToken` from `POST /v1/external-auth/token`, valid 15 minutes."
      }
    },
    "responses": {
      "Unauthenticated": {
        "description": "No token, or a token that is expired or not for this route: sign in again.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Forbidden": {
        "description": "Your identity is not allowed this route, or has no business wallet.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Invalid": {
        "description": "The request does not match this contract: `VALIDATION_ERROR` lists each field and the rule it broke. An amount outside $0.50 to $1,000,000 is refused here too.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "Over a limit. Wait and retry.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unavailable": {
        "description": "A Cadmos service failed or did not answer (`{ \"message\": \"Service Error\" }`). Retry; retry a create with the same `requestId`.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "SignInInvalid": {
        "description": "Malformed request.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "SignInRefused": {
        "description": "Unknown or disabled identity or address, wrong signature, or a challenge already used or expired.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "SignInUnavailable": {
        "description": "Sign-in is unavailable. Retry later.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "Uuid": {
        "type": "string",
        "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
      },
      "Address": {
        "type": "string",
        "pattern": "^0x[0-9a-fA-F]{40}$",
        "description": "An Ethereum address."
      },
      "Dollars": {
        "type": "string",
        "pattern": "^\\d+\\.\\d{2}$",
        "description": "Dollars and cents as a decimal string.",
        "examples": ["100.00"]
      },
      "Atomic": {
        "type": "string",
        "pattern": "^\\d+$",
        "description": "An integer string of 6-decimal units: `\"100000000\"` is 100.000000.",
        "examples": ["100000000"]
      },
      "Error": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          },
          "code": {
            "type": "string",
            "description": "A stable code where one is named in this file, such as `GATEWAY_REQUEST_CONFLICT`."
          },
          "violations": {
            "type": "array",
            "description": "With `code: VALIDATION_ERROR`: each field (`<unknown>` for a field this contract does not have) and the rule it broke.",
            "items": {
              "type": "object",
              "properties": {
                "field": {
                  "type": "string"
                },
                "code": {
                  "type": "string"
                }
              },
              "required": ["field", "code"]
            }
          }
        },
        "examples": [
          {
            "code": "GATEWAY_LINK_NOT_FOUND"
          },
          {
            "message": "Invalid request",
            "code": "VALIDATION_ERROR",
            "violations": [
              {
                "field": "amountUsd",
                "code": "string.pattern.base"
              }
            ]
          }
        ]
      },
      "ChallengeRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": ["identityId", "address"],
        "properties": {
          "identityId": {
            "$ref": "#/components/schemas/Uuid",
            "description": "The identity id Cadmos gave you."
          },
          "address": {
            "$ref": "#/components/schemas/Address",
            "description": "Your signing key's address, as registered with Cadmos."
          }
        }
      },
      "Challenge": {
        "type": "object",
        "required": ["challengeId", "identityId", "message", "expiresAt"],
        "properties": {
          "challengeId": {
            "type": "string",
            "format": "uuid"
          },
          "identityId": {
            "type": "string",
            "format": "uuid"
          },
          "message": {
            "type": "string",
            "maxLength": 2000,
            "description": "The sign-in message (SIWE). Sign it unchanged."
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "TokenRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": ["challengeId", "message", "signature"],
        "properties": {
          "challengeId": {
            "type": "string",
            "format": "uuid"
          },
          "message": {
            "type": "string",
            "maxLength": 2000,
            "description": "The challenge's message, unchanged."
          },
          "signature": {
            "type": "string",
            "pattern": "^0x[0-9a-fA-F]{130}$",
            "description": "Your EIP-191 signature of the message."
          }
        }
      },
      "Token": {
        "type": "object",
        "required": ["accessToken", "tokenType", "expiresIn", "identityId"],
        "properties": {
          "accessToken": {
            "type": "string"
          },
          "tokenType": {
            "type": "string",
            "enum": ["Bearer"]
          },
          "expiresIn": {
            "type": "integer",
            "description": "Seconds: 900."
          },
          "identityId": {
            "type": "string",
            "format": "uuid"
          }
        }
      },
      "WebhookSigners": {
        "type": "object",
        "required": ["addresses"],
        "properties": {
          "addresses": {
            "type": "array",
            "minItems": 1,
            "maxItems": 2,
            "items": {
              "$ref": "#/components/schemas/Address"
            },
            "description": "The current signer, then the previous one during a rotation."
          }
        }
      },
      "CreateLinkRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": ["description", "externalReference"],
        "properties": {
          "description": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200,
            "description": "Shown to the payer. Trimmed."
          },
          "externalReference": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120,
            "description": "Your own reference, such as an order number. Returned with every settlement. Trimmed."
          },
          "requestId": {
            "$ref": "#/components/schemas/Uuid",
            "description": "A UUID v4 you choose; it becomes the link's `uuid`. Reuse it to retry the same create."
          },
          "localMethods": {
            "type": "array",
            "maxItems": 5,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "pattern": "^[a-z0-9_-]{2,40}$"
            },
            "description": "Cash methods the link should also accept, such as `whish`. The ones your account may not offer are left out and listed in `refusedLocalMethods`. Absent: crypto only."
          },
          "amountUsd": {
            "type": "string",
            "pattern": "^\\d{1,7}(\\.\\d{1,2})?$",
            "description": "The price in dollars, from 0.50 to 1000000, as a decimal string (`\"100\"`, `\"99.5\"`), never a JSON number. The Gateway Fee is yours: it comes out of what is counted and the payer never sees it. Absent: the payer chooses what to send."
          }
        }
      },
      "CreatedLink": {
        "type": "object",
        "required": [
          "uuid",
          "status",
          "token",
          "checkoutUrl",
          "receiverAddress",
          "externalReference",
          "localMethods",
          "refusedLocalMethods",
          "paymentReference",
          "amountUsd",
          "countedUsd",
          "leftUsd",
          "paid"
        ],
        "properties": {
          "uuid": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": ["active"]
          },
          "token": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{43}$",
            "description": "The checkout secret inside `checkoutUrl`."
          },
          "checkoutUrl": {
            "type": "string",
            "format": "uri",
            "description": "The page to send your customer."
          },
          "receiverAddress": {
            "$ref": "#/components/schemas/Address",
            "description": "The link's own receiving address on Arbitrum."
          },
          "externalReference": {
            "type": ["string", "null"]
          },
          "localMethods": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The cash methods the link accepts."
          },
          "refusedLocalMethods": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The cash methods you asked for that the link does not accept."
          },
          "paymentReference": {
            "type": ["string", "null"],
            "description": "The code a cash payer gives, when the link accepts a cash method."
          },
          "amountUsd": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Dollars"
              },
              {
                "type": "null"
              }
            ],
            "description": "The price, or `null` for an open amount."
          },
          "countedUsd": {
            "$ref": "#/components/schemas/Dollars",
            "description": "What the link's settled payments count for, before the Gateway Fee."
          },
          "leftUsd": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Dollars"
              },
              {
                "type": "null"
              }
            ],
            "description": "What is still due; `\"0.00\"` once paid; `null` for an open amount."
          },
          "paid": {
            "type": "boolean",
            "description": "True once what is left is within min($0.49, max($0.02, 0.1 % of the amount)): a bridged payment can land a few cents under. Always false for an open amount."
          }
        }
      },
      "Link": {
        "type": "object",
        "required": [
          "uuid",
          "kind",
          "description",
          "externalReference",
          "status",
          "receiverAddress",
          "checkoutUrl",
          "createdAt",
          "receipts",
          "localMethods",
          "paymentReference",
          "amountUsd",
          "countedUsd",
          "leftUsd",
          "paid"
        ],
        "properties": {
          "uuid": {
            "type": "string",
            "format": "uuid"
          },
          "kind": {
            "type": "string",
            "enum": ["order", "remittance"],
            "description": "Links you create here are `order`. A `remittance` link is one client's reusable link, made in the app."
          },
          "description": {
            "type": "string"
          },
          "externalReference": {
            "type": ["string", "null"]
          },
          "status": {
            "type": "string",
            "enum": ["active", "void"]
          },
          "receiverAddress": {
            "$ref": "#/components/schemas/Address"
          },
          "checkoutUrl": {
            "type": "string",
            "format": "uri"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "receipts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Receipt"
            }
          },
          "localMethods": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "paymentReference": {
            "type": ["string", "null"]
          },
          "amountUsd": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Dollars"
              },
              {
                "type": "null"
              }
            ]
          },
          "countedUsd": {
            "$ref": "#/components/schemas/Dollars"
          },
          "leftUsd": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Dollars"
              },
              {
                "type": "null"
              }
            ]
          },
          "paid": {
            "type": "boolean"
          }
        }
      },
      "Receipt": {
        "type": "object",
        "description": "One payment the link received, settled or not yet.",
        "required": [
          "asset",
          "txHash",
          "logIndex",
          "grossAtomic",
          "feeShares",
          "netShares",
          "feeAtomic",
          "netValueAtomic",
          "appliedRateBps",
          "state",
          "settlementTxHash",
          "createdAt"
        ],
        "properties": {
          "asset": {
            "type": "string",
            "enum": ["USDC", "USDT", "CUSD"],
            "description": "`CUSD` for a cash payment."
          },
          "txHash": {
            "type": "string",
            "description": "The transaction that paid the link's receiving address."
          },
          "logIndex": {
            "type": "integer"
          },
          "grossAtomic": {
            "$ref": "#/components/schemas/Atomic"
          },
          "feeShares": {
            "type": ["string", "null"]
          },
          "netShares": {
            "type": ["string", "null"]
          },
          "feeAtomic": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Atomic"
              },
              {
                "type": "null"
              }
            ],
            "description": "The Gateway Fee, once settled."
          },
          "netValueAtomic": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Atomic"
              },
              {
                "type": "null"
              }
            ],
            "description": "What your wallet was credited, once settled."
          },
          "appliedRateBps": {
            "type": ["integer", "null"],
            "description": "The Gateway Fee rate applied, in basis points."
          },
          "state": {
            "type": "string",
            "enum": ["pending", "settled"]
          },
          "settlementTxHash": {
            "type": ["string", "null"]
          },
          "createdAt": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "method": {
            "type": "string",
            "enum": ["whish"],
            "description": "Only on a cash payment."
          },
          "paidUsd": {
            "type": "string",
            "description": "Only on a cash payment: what the payer paid, their cash-in fee included."
          },
          "cashInFeeUsd": {
            "type": "string",
            "description": "Only on a cash payment: the cash-in fee."
          }
        }
      },
      "SettlementPage": {
        "type": "object",
        "required": ["items", "next"],
        "properties": {
          "items": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/Settlement"
            }
          },
          "next": {
            "type": ["string", "null"],
            "pattern": "^\\d{13}\\.\\d{1,10}$",
            "description": "The cursor of the next page, or `null` on the last page."
          }
        }
      },
      "Settlement": {
        "type": "object",
        "description": "One payment credited to your wallet.",
        "required": [
          "id",
          "linkUuid",
          "externalReference",
          "asset",
          "gross",
          "gatewayFee",
          "appliedRateBps",
          "netCusd",
          "settledAt",
          "settlement",
          "whishCashIn",
          "destination"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^0x[0-9a-fA-F]{64}$",
            "description": "The payment's on-chain transfer id. Unique: drop one you already have."
          },
          "linkUuid": {
            "type": "string",
            "format": "uuid",
            "description": "Ignore a link you do not know: it was made in the app."
          },
          "externalReference": {
            "type": ["string", "null"],
            "description": "Your reference, `null` for a link made in the app."
          },
          "asset": {
            "type": "string",
            "enum": ["USDC", "USDT", "CUSD"],
            "description": "What arrived: `CUSD` for a cash payment."
          },
          "gross": {
            "$ref": "#/components/schemas/Atomic"
          },
          "gatewayFee": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Atomic"
              },
              {
                "type": "null"
              }
            ]
          },
          "appliedRateBps": {
            "type": ["integer", "null"]
          },
          "netCusd": {
            "$ref": "#/components/schemas/Atomic",
            "description": "What your wallet was credited."
          },
          "settledAt": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "settlement": {
            "type": "object",
            "required": ["chain", "txHash"],
            "properties": {
              "chain": {
                "type": "string",
                "enum": ["arbitrum"]
              },
              "txHash": {
                "type": ["string", "null"],
                "description": "The transaction that credited your wallet."
              }
            }
          },
          "whishCashIn": {
            "type": ["string", "null"],
            "description": "The Whish cash-in behind a cash payment; `null` for crypto."
          },
          "destination": {
            "type": "string",
            "enum": ["cadmos_wallet"],
            "description": "Always your Cadmos wallet."
          }
        },
        "examples": [
          {
            "id": "0x5f2c0c3d2b1a09f8e7d6c5b4a39281706f5e4d3c2b1a09f8e7d6c5b4a3928170",
            "linkUuid": "0b6f5a8e-1c2d-4e3f-9a8b-7c6d5e4f3a2b",
            "externalReference": "order-42",
            "asset": "USDT",
            "gross": "100000000",
            "gatewayFee": "500000",
            "appliedRateBps": 50,
            "netCusd": "99500000",
            "settledAt": "2026-11-17T10:00:00.000Z",
            "settlement": {
              "chain": "arbitrum",
              "txHash": "0xdfd1a5041e8abc7c9b2f6a0e1d3c5b7a9f8e6d4c2b0a1f3e5d7c9b8a6f4e2d0c"
            },
            "whishCashIn": null,
            "destination": "cadmos_wallet"
          }
        ]
      }
    }
  }
}
