{"openapi":"3.1.0","info":{"title":"CashPayment API","version":"v1"},"paths":{"/v1/orders":{"post":{"tags":["orders"],"operationId":"orders.create","parameters":[{"name":"idempotency-key","in":"header","schema":{"type":"string","description":"16–128 letters, digits, `_` or `-`. Use a new UUID for each order and reuse it when retrying.","examples":["5f2b7c1e-9a4d-4e8b-b1c3-7d6e0a9f2c41"]},"required":true}],"security":[{"bearer":[]}],"responses":{"201":{"description":"Order","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Order"}}}},"400":{"description":"The request is malformed.","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string","enum":["INVALID_INPUT","BODY_TOO_LARGE"],"description":"Machine-readable error code.","examples":["INVALID_INPUT"]},"message":{"type":"string","description":"Same as `code`. Do not show it to customers.","examples":["INVALID_INPUT"]}},"required":["code","message"],"additionalProperties":false,"description":"The request is malformed."}}}},"401":{"description":"The API key is missing, invalid, or deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"anyOf":[{"type":"string","enum":["UNAUTHORIZED"]}],"description":"Machine-readable error code.","examples":["UNAUTHORIZED"]},"message":{"type":"string","description":"Same as `code`. Do not show it to customers.","examples":["UNAUTHORIZED"]}},"required":["code","message"],"additionalProperties":false,"description":"The API key is missing, invalid, or deleted."}}}},"409":{"description":"The request conflicts with the current state.","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string","enum":["IDEMPOTENCY_CONFLICT","ORDER_IN_PROGRESS","MERCHANT_DISABLED"],"description":"Machine-readable error code.","examples":["IDEMPOTENCY_CONFLICT"]},"message":{"type":"string","description":"Same as `code`. Do not show it to customers.","examples":["IDEMPOTENCY_CONFLICT"]}},"required":["code","message"],"additionalProperties":false,"description":"The request conflicts with the current state."}}}},"422":{"description":"The pay link does not exist or is not yours.","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"anyOf":[{"type":"string","enum":["SLUG_NOT_FOUND"]}],"description":"Machine-readable error code.","examples":["SLUG_NOT_FOUND"]},"message":{"type":"string","description":"Same as `code`. Do not show it to customers.","examples":["SLUG_NOT_FOUND"]}},"required":["code","message"],"additionalProperties":false,"description":"The pay link does not exist or is not yours."}}}},"429":{"description":"Too many requests for this API key.","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"anyOf":[{"type":"string","enum":["RATE_LIMITED"]}],"description":"Machine-readable error code.","examples":["RATE_LIMITED"]},"message":{"type":"string","description":"Same as `code`. Do not show it to customers.","examples":["RATE_LIMITED"]}},"required":["code","message"],"additionalProperties":false,"description":"Too many requests for this API key."}}}},"500":{"description":"Unexpected server error.","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"anyOf":[{"type":"string","enum":["INTERNAL_ERROR"]}],"description":"Machine-readable error code.","examples":["INTERNAL_ERROR"]},"message":{"type":"string","description":"Same as `code`. Do not show it to customers.","examples":["INTERNAL_ERROR"]}},"required":["code","message"],"additionalProperties":false,"description":"Unexpected server error."}}}},"503":{"description":"Payments are temporarily unavailable. Retry later.","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string","enum":["WALLET_UNAVAILABLE","QUOTE_UNAVAILABLE","PAYMENTS_PAUSED","PAYMENTS_UNAVAILABLE","PAYMENTS_NOT_CONFIGURED","WALLET_NOT_CONFIGURED"],"description":"Machine-readable error code.","examples":["WALLET_UNAVAILABLE"]},"message":{"type":"string","description":"Same as `code`. Do not show it to customers.","examples":["WALLET_UNAVAILABLE"]}},"required":["code","message"],"additionalProperties":false,"description":"Payments are temporarily unavailable. Retry later."}}}}},"description":"Creates an order and its Lightning invoice. Send the customer to `checkoutUrl`, or show `invoice` yourself.","summary":"Create an order","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/NewOrder"}}},"required":true}}},"/v1/orders/{orderId}":{"get":{"tags":["orders"],"operationId":"orders.order","parameters":[{"name":"orderId","in":"path","schema":{"type":"string","description":"Order ID, a UUID.","examples":["12345678-1234-4234-8234-123456789abc"]},"required":true}],"security":[{"bearer":[]}],"responses":{"200":{"description":"Order","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Order"}}}},"400":{"description":"The request is malformed.","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string","enum":["INVALID_INPUT","BODY_TOO_LARGE"],"description":"Machine-readable error code.","examples":["INVALID_INPUT"]},"message":{"type":"string","description":"Same as `code`. Do not show it to customers.","examples":["INVALID_INPUT"]}},"required":["code","message"],"additionalProperties":false,"description":"The request is malformed."}}}},"401":{"description":"The API key is missing, invalid, or deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"anyOf":[{"type":"string","enum":["UNAUTHORIZED"]}],"description":"Machine-readable error code.","examples":["UNAUTHORIZED"]},"message":{"type":"string","description":"Same as `code`. Do not show it to customers.","examples":["UNAUTHORIZED"]}},"required":["code","message"],"additionalProperties":false,"description":"The API key is missing, invalid, or deleted."}}}},"404":{"description":"No order with this ID belongs to you.","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"anyOf":[{"type":"string","enum":["ORDER_NOT_FOUND"]}],"description":"Machine-readable error code.","examples":["ORDER_NOT_FOUND"]},"message":{"type":"string","description":"Same as `code`. Do not show it to customers.","examples":["ORDER_NOT_FOUND"]}},"required":["code","message"],"additionalProperties":false,"description":"No order with this ID belongs to you."}}}},"409":{"description":"Your merchant account is disabled.","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"anyOf":[{"type":"string","enum":["MERCHANT_DISABLED"]}],"description":"Machine-readable error code.","examples":["MERCHANT_DISABLED"]},"message":{"type":"string","description":"Same as `code`. Do not show it to customers.","examples":["MERCHANT_DISABLED"]}},"required":["code","message"],"additionalProperties":false,"description":"Your merchant account is disabled."}}}},"429":{"description":"Too many requests for this API key.","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"anyOf":[{"type":"string","enum":["RATE_LIMITED"]}],"description":"Machine-readable error code.","examples":["RATE_LIMITED"]},"message":{"type":"string","description":"Same as `code`. Do not show it to customers.","examples":["RATE_LIMITED"]}},"required":["code","message"],"additionalProperties":false,"description":"Too many requests for this API key."}}}},"500":{"description":"Unexpected server error.","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"anyOf":[{"type":"string","enum":["INTERNAL_ERROR"]}],"description":"Machine-readable error code.","examples":["INTERNAL_ERROR"]},"message":{"type":"string","description":"Same as `code`. Do not show it to customers.","examples":["INTERNAL_ERROR"]}},"required":["code","message"],"additionalProperties":false,"description":"Unexpected server error."}}}},"503":{"description":"Payments are temporarily unavailable. Retry later.","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string","enum":["WALLET_UNAVAILABLE","QUOTE_UNAVAILABLE","PAYMENTS_PAUSED","PAYMENTS_UNAVAILABLE","PAYMENTS_NOT_CONFIGURED","WALLET_NOT_CONFIGURED"],"description":"Machine-readable error code.","examples":["WALLET_UNAVAILABLE"]},"message":{"type":"string","description":"Same as `code`. Do not show it to customers.","examples":["WALLET_UNAVAILABLE"]}},"required":["code","message"],"additionalProperties":false,"description":"Payments are temporarily unavailable. Retry later."}}}}},"description":"Returns one of your orders. An unpaid order is checked against the wallet before it is returned.","summary":"Retrieve an order"}}},"components":{"schemas":{"Order":{"type":"object","properties":{"id":{"type":"string","description":"Order ID, a UUID.","examples":["12345678-1234-4234-8234-123456789abc"]},"slug":{"type":"string","description":"Pay link the order belongs to. It must be one of your pay links.","examples":["onne"]},"reference":{"type":"string","description":"The reference you sent.","examples":["WC-10234"]},"amountUsdCents":{"type":"integer","minimum":100,"maximum":1000000,"description":"Amount in US cents, from 100 ($1.00) to 1000000 ($10,000.00).","examples":[1500]},"amountSat":{"type":"integer","minimum":1,"maximum":9007199254740,"description":"Amount in satoshis, quoted when the order was created. The invoice is for exactly this amount.","examples":[15000]},"status":{"type":"string","enum":["pending","paid","expired"],"description":"`pending` until the invoice is paid or expires. `paid` is final. An `expired` order can still become `paid` if a late payment arrives.","examples":["pending"]},"invoice":{"type":"string","description":"BOLT11 Lightning invoice. Show it yourself or send the customer to `checkoutUrl`.","examples":["lnbc150u1p5..."]},"checkoutUrl":{"type":"string","description":"Hosted checkout page for this order.","examples":["https://www.cashpayment.co/invoice/12345678-1234-4234-8234-123456789abc"]},"successUrl":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The success URL you sent, or null.","examples":["https://shop.example.com/thanks"]},"cancelUrl":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The cancel URL you sent, or null.","examples":["https://shop.example.com/cart"]},"createdAt":{"type":"string","description":"When the order was created. ISO 8601, UTC.","examples":["2026-11-17T12:00:00.000Z"]},"expiresAt":{"type":"string","description":"When the invoice expires, one hour after creation. ISO 8601, UTC.","examples":["2026-11-17T13:00:00.000Z"]},"paidAt":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"When the payment arrived, or null. ISO 8601, UTC.","examples":[null]}},"required":["id","slug","reference","amountUsdCents","amountSat","status","invoice","checkoutUrl","successUrl","cancelUrl","createdAt","expiresAt","paidAt"],"additionalProperties":false},"NewOrder":{"type":"object","properties":{"slug":{"type":"string","description":"Pay link the order belongs to. It must be one of your pay links.","examples":["onne"]},"amountUsdCents":{"type":"integer","minimum":100,"maximum":1000000,"description":"Amount in US cents, from 100 ($1.00) to 1000000 ($10,000.00).","examples":[1500]},"reference":{"type":"string","maxLength":128,"description":"Your own order number, up to 128 characters. It is returned as is and does not need to be unique.","examples":["WC-10234"]},"successUrl":{"type":"string","maxLength":2048,"format":"uri","pattern":"^https://","description":"HTTPS URL the checkout page sends the customer to after payment.","examples":["https://shop.example.com/thanks"]},"cancelUrl":{"type":"string","maxLength":2048,"format":"uri","pattern":"^https://","description":"HTTPS URL behind the checkout page's “Return to store” link while the order is unpaid.","examples":["https://shop.example.com/cart"]}},"required":["slug","amountUsdCents","reference"],"additionalProperties":false},"WebhookEvent":{"type":"object","properties":{"id":{"type":"string","description":"Event ID. Retries and manual resends carry the same ID, so use it to skip duplicates.","examples":["0b6a3c52-7f0e-4c4e-9d43-5a0f1f4c2e9b"]},"type":{"type":"string","enum":["order.paid","order.expired"],"description":"Event type.","examples":["order.paid"]},"timestamp":{"type":"string","description":"When the event was created. ISO 8601, UTC.","examples":["2026-11-17T12:03:42.000Z"]},"data":{"$ref":"#/components/schemas/WebhookOrder"}},"required":["id","type","timestamp","data"],"additionalProperties":false},"WebhookOrder":{"type":"object","properties":{"id":{"type":"string","description":"Order ID, a UUID.","examples":["12345678-1234-4234-8234-123456789abc"]},"slug":{"type":"string","description":"Pay link the order belongs to. It must be one of your pay links.","examples":["onne"]},"reference":{"type":"string","description":"The reference you sent.","examples":["WC-10234"]},"amountUsdCents":{"type":"integer","minimum":100,"maximum":1000000,"description":"Amount in US cents, from 100 ($1.00) to 1000000 ($10,000.00).","examples":[1500]},"amountSat":{"type":"integer","minimum":1,"maximum":9007199254740,"description":"Amount in satoshis, quoted when the order was created. The invoice is for exactly this amount.","examples":[15000]},"status":{"type":"string","enum":["pending","paid","expired"],"description":"Order status when the event was created: `paid` for `order.paid`, `expired` for `order.expired`.","examples":["paid"]},"createdAt":{"type":"string","description":"When the order was created. ISO 8601, UTC.","examples":["2026-11-17T12:00:00.000Z"]},"expiresAt":{"type":"string","description":"When the invoice expires. ISO 8601, UTC.","examples":["2026-11-17T13:00:00.000Z"]},"paidAt":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"When the payment arrived, or null. ISO 8601, UTC.","examples":["2026-11-17T12:03:41.000Z"]}},"required":["id","slug","reference","amountUsdCents","amountSat","status","createdAt","expiresAt","paidAt"],"additionalProperties":false}},"securitySchemes":{"bearer":{"description":"Your secret API key, `cp_live_…`, created in the merchant console.","type":"http","scheme":"Bearer"}}},"security":[],"tags":[{"name":"orders","description":"Create and read orders."}],"servers":[{"url":"https://api.cashpayment.co","description":"Production"}],"webhooks":{"order.paid":{"post":{"operationId":"webhooks.order.paid","summary":"Order paid","description":"Sent when an API order is paid, including a payment that arrives after the order expired.","parameters":[{"name":"svix-id","in":"header","required":true,"description":"Message ID. Stays the same when a message is retried.","schema":{"type":"string"},"example":"msg_2pLqV7sM1hYk3fNb0aXcRw9dT4e"},{"name":"svix-timestamp","in":"header","required":true,"description":"Unix timestamp in seconds when the message was signed.","schema":{"type":"string"},"example":"1763380982"},{"name":"svix-signature","in":"header","required":true,"description":"Space-separated list of signatures, each `v1,` followed by a Base64 HMAC-SHA256.","schema":{"type":"string"},"example":"v1,g0hM9SsE+OTPJTGt/tmIKtSyZlE3uFJELVlNIOLJ1OE="}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookEvent"},"example":{"id":"0b6a3c52-7f0e-4c4e-9d43-5a0f1f4c2e9b","type":"order.paid","timestamp":"2026-11-17T12:03:42.000Z","data":{"id":"12345678-1234-4234-8234-123456789abc","slug":"onne","reference":"WC-10234","amountUsdCents":1500,"amountSat":15000,"status":"paid","createdAt":"2026-11-17T12:00:00.000Z","expiresAt":"2026-11-17T13:00:00.000Z","paidAt":"2026-11-17T12:03:41.000Z"}}}}},"responses":{"200":{"description":"Return any 2xx status within 30 seconds. Any other result is retried."}}}},"order.expired":{"post":{"operationId":"webhooks.order.expired","summary":"Order expired","description":"Sent when an unpaid API order passes `expiresAt`.","parameters":[{"name":"svix-id","in":"header","required":true,"description":"Message ID. Stays the same when a message is retried.","schema":{"type":"string"},"example":"msg_2pLqV7sM1hYk3fNb0aXcRw9dT4e"},{"name":"svix-timestamp","in":"header","required":true,"description":"Unix timestamp in seconds when the message was signed.","schema":{"type":"string"},"example":"1763380982"},{"name":"svix-signature","in":"header","required":true,"description":"Space-separated list of signatures, each `v1,` followed by a Base64 HMAC-SHA256.","schema":{"type":"string"},"example":"v1,g0hM9SsE+OTPJTGt/tmIKtSyZlE3uFJELVlNIOLJ1OE="}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookEvent"},"example":{"id":"0b6a3c52-7f0e-4c4e-9d43-5a0f1f4c2e9b","type":"order.expired","timestamp":"2026-11-17T13:00:31.000Z","data":{"id":"12345678-1234-4234-8234-123456789abc","slug":"onne","reference":"WC-10234","amountUsdCents":1500,"amountSat":15000,"status":"expired","createdAt":"2026-11-17T12:00:00.000Z","expiresAt":"2026-11-17T13:00:00.000Z","paidAt":null}}}}},"responses":{"200":{"description":"Return any 2xx status within 30 seconds. Any other result is retried."}}}}}}