# Errors (/docs/api/errors) Every non-2xx response has the same body. Branch on `type` and `code`; `message` is for people and may change. ```json { "error": { "type": "invalid_request_error", "code": "invalid_amount", "message": "amount is required, in minor units (e.g. 1999 for $19.99).", "param": "amount", "request_id": "req_01KA4XZY8T2R5M7P1Q4W6E8R0T", "doc_url": "https://runepay.co/docs/api/errors#invalid_amount" } } ``` | Field | | | --- | --- | | `type` | One of the 6 types below. | | `code` | A stable, machine-readable code from the tables below. | | `message` | A human-readable explanation. | | `param` | The parameter at fault, as a path such as `enabled_events[1]`, when there is one. | | `object_id` | Only on `secret_not_replayable`: the object the original request created or changed. | | `request_id` | The same value as the `Request-Id` response header. Quote it when you contact support. | | `doc_url` | A link to this page, at the code. | Unknown body parameters are rejected with `parameter_unknown`, so typos fail loudly instead of being ignored. ## `invalid_request_error` [#invalid_request_error] The request was wrong: a missing or malformed parameter, an object that does not exist, or one in the wrong state. Fix the request before retrying. | Code | Status | Meaning | | --- | --- | --- | | invalid_json | 400 | The request body is not valid JSON or is not a JSON object. | | body_too_large | 413 | The request body is larger than 256 KB. | | invalid_line_items | 400 | Pass 1–100 valid inline price_data line items. | | invalid_expires_at | 400 | expires_at must be 30 minutes to 24 hours from now. | | parameter_missing | 400 | A required parameter is missing. | | parameter_unknown | 400 | The request has a parameter this endpoint does not accept. | | parameter_invalid_string | 400 | The parameter must be a string. | | parameter_invalid_integer | 400 | The parameter must be an integer. | | parameter_invalid_number | 400 | The parameter must be a number. | | parameter_invalid_boolean | 400 | The parameter must be true or false. | | parameter_invalid_array | 400 | The parameter must be an array. | | parameter_invalid_object | 400 | The parameter must be an object. | | parameter_invalid_empty | 400 | The parameter must not be empty. | | parameter_invalid_value | 400 | The parameter's value is not allowed (out of range, wrong format, or not one of the listed values). | | invalid_limit | 400 | `limit` must be an integer from 1 to 100. | | invalid_cursor | 400 | `starting_after` is not an object this key can see. | | invalid_created | 400 | A `created[…]` filter is not a unix timestamp in seconds. | | invalid_status | 400 | `status` is not one of the allowed values. | | invalid_amount | 400 | The amount is missing, not a positive integer in minor units, or outside what the object allows. | | invalid_currency | 400 | The currency is not a three-letter ISO 4217 code. | | unsupported_currency | 400 | The currency is not enabled for this account. | | invalid_url | 400 | The URL is not an allowed absolute URL (http(s) for redirects, public HTTPS for webhooks). | | invalid_email | 400 | The email address is not valid. | | invalid_name | 400 | `name` is missing or too long. | | invalid_description | 400 | `description` is not a string or is too long. | | invalid_active | 400 | `active` must be true or false. | | invalid_events | 400 | `enabled_events` must be a nonempty list of event types. | | invalid_event | 400 | `event_id` is required. | | invalid_immediate | 400 | `immediate` must be a boolean. | | invalid_request | 400 | Required parameters are missing or malformed. | | invalid_input | 400 | The hosted checkout request is malformed. | | invalid_action | 400 | The hosted checkout action is not recognised. | | invalid_dispute | 400 | The dispute data from the processor is not valid. | | missing_payment | 400 | `payment` is required. | | missing_token | 400 | The card token is missing. | | unsupported | 400 | The operation is not supported for this payment or processor. | | not_found | 404 | No such object for this key's organization and mode. | | payment_link_unavailable | 404 | The payment link cannot take payments right now (503 when the cause is temporary). | | payment_link_inactive | 410 | The payment link is deactivated. | | checkout_expired | 410 | The checkout session has expired. | | checkout_closed | 409 | The checkout session is already complete. | | amount_out_of_range | 400 | The buyer-chosen amount is outside the payment link's min_amount and max_amount. | | invalid_payment_transition | 409 | The payment cannot move to that status from its current one. | | payment_in_progress | 409 | The payment already has a processor attempt in progress. | | payment_not_confirmable | 409 | The payment cannot be confirmed in its current status. | | not_refundable | 409 | The payment cannot be refunded in its current status, or the amount exceeds what is left. | | refund_not_ready | 409 | The processor reported a refund before RunePay recorded it. | | processor_mismatch | 409 | The processor's data does not match the payment. | | endpoint_disabled | 409 | The webhook endpoint is disabled. Enable it first. | | rotation_in_progress | 409 | A previous signing secret is still in its overlap window. Wait, or rotate with `immediate: true`. | ## `authentication_error` [#authentication_error] No API key, or an unknown or revoked one. | Code | Status | Meaning | | --- | --- | --- | | invalid_api_key | 401 | No API key, or the key is unknown or revoked. Send `Authorization: Bearer sk_…`. | ## `permission_error` [#permission_error] The key is valid but may not do this: a publishable key, a live key on an account that is not live yet, or a paused account. | Code | Status | Meaning | | --- | --- | --- | | secret_key_required | 403 | The endpoint needs a secret key (`sk_…`); publishable keys are refused. | | permission_denied | 403 | The key lacks the scope this endpoint needs. Reserved for restricted keys (`rk_…`). | | account_not_ready | 403 | The merchant account is not set up to take payments. | | account_not_live | 403 | The organization is not approved for live payments yet; use a test key. | | account_paused | 403 | Payments are paused for this account. | | checkout_challenge_required | 403 | The buyer must complete a challenge before paying. | | checkout_challenge_invalid | 403 | The buyer's challenge response is not valid. | ## `idempotency_error` [#idempotency_error] The `Idempotency-Key` conflicts with an earlier request. See [Idempotency](/docs/api/idempotency). | Code | Status | Meaning | | --- | --- | --- | | key_reused | 422 | The Idempotency-Key was already used with a different request. | | in_progress | 409 | A request with this Idempotency-Key is still in progress. | | secret_not_replayable | 409 | The request with this Idempotency-Key succeeded, but its response held a secret that is never stored. `object_id` names the object: retrieve it, or rotate its secret. | ## `rate_limit_error` [#rate_limit_error] Too many requests. Back off and retry. | Code | Status | Meaning | | --- | --- | --- | | rate_limited | 429 | Too many requests. Reserved; rate limits are not enforced yet. | | checkout_rate_limited | 429 | Too many checkout attempts from this buyer. Try again later. | | checkout_attempt_limit | 429 | Too many payment attempts on this checkout. | ## `api_error` [#api_error] A problem on RunePay's side or upstream. A retry with the same `Idempotency-Key` returns this same stored error and never runs the operation twice; see [Idempotency](/docs/api/idempotency) before retrying with a new key. | Code | Status | Meaning | | --- | --- | --- | | not_configured | 503 | The API is not configured on this deployment. | | internal | 500 | Something went wrong on RunePay's side. Retry with the same Idempotency-Key. | | checkout_unavailable | 503 | Checkout is temporarily unavailable. | | payment_unavailable | 503 | The payment could not be processed right now. Try again. | | processor_unavailable | 503 | The card processor is unavailable. Try again. | | risk_screening_unavailable | 503 | Risk screening is unavailable, so the payment was not attempted. Try again. | | no_test_processor | 500 | Test mode has no processor configured. | # Idempotency (/docs/api/idempotency) Networks fail. If a request to create a checkout or a refund times out, you can't tell whether it ran. Send an `Idempotency-Key` header and retry with the same key: RunePay runs the request once and returns the same result to every retry. ```bash curl https://runepay.co/api/v1/refunds \ -H "Authorization: Bearer $RUNEPAY_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: refund_order_1042" \ -d '{ "payment": "pay_01KA4Y0Z9V3T6N8Q2W5E7R1T3Y" }' ``` ## How it works [#how-it-works] - Every `POST`, `PATCH` and `DELETE` accepts the header. `GET` requests don't need it. - Use a value that identifies the operation in your system, such as an order id, or a random UUID you store before sending. Keys are scoped to your account and mode. - The first request with a key claims it. Its response, **success or error**, is stored for **24 hours**. - A retry with the same key and the same request (method, path and body) gets the stored response, with the header `Idempotent-Replayed: true`. The operation does not run again. - A request that fails validation (a malformed body or parameter) does not claim the key, so you can fix it and resend with the same key. ## Conflicts [#conflicts] | Status | Code | When | | --- | --- | --- | | `422` | [`key_reused`](/docs/api/errors#key_reused) | The key was used with a different request. Use a new key for a new operation. | | `409` | [`in_progress`](/docs/api/errors#in_progress) | The first request with this key is still running. Retry shortly. | | `409` | [`secret_not_replayable`](/docs/api/errors#secret_not_replayable) | See below. | ## Retrying after an error [#retrying-after-an-error] Because errors are stored too, a retry with the same key returns the same error, including a `500`. A replayed error keeps the original `request_id`, in the body and the `Request-Id` header. That is deliberate: a request that failed part-way may already have reached the card processor, and replaying the error guarantees the operation is never attempted twice. Before retrying with a **new** key, check the object's state, for example by listing the payment's refunds or reading the payment. ## Responses that hold a secret [#responses-that-hold-a-secret] Creating a webhook endpoint and rotating its secret return a signing secret. RunePay stores it encrypted so it can sign deliveries, but does not store the plaintext secret or replay it. These routes claim the key without storing the successful response in the idempotency cache (the `claim_only` mode). A retry with the same key does not create or rotate again; it gets `409 idempotency_error` with code `secret_not_replayable` and `object_id` set to the endpoint's id: ```json { "error": { "type": "idempotency_error", "code": "secret_not_replayable", "message": "This request already succeeded, but its response held a secret that is not stored. Retrieve the object, or rotate its secret to get a new one.", "object_id": "we_01KA9F6G8H0J2K4M6N8P0Q2R4S", "request_id": "req_01KA4XZY8T2R5M7P1Q4W6E8R0T", "doc_url": "https://runepay.co/docs/api/errors#secret_not_replayable" } } ``` The endpoint exists. If you didn't save the secret from the first response, rotate it to get a new one. `DELETE /webhook_endpoints/{id}/previous_secret` ignores the header: deleting twice has the same effect as deleting once. # API reference (/docs/api) The endpoint pages in this section are generated from RunePay's OpenAPI 3.1 spec, [`/openapi/runepay-v1.json`](/openapi/runepay-v1.json), which is generated from the same schemas that validate requests. If a page and the API disagree, that is a bug. ## Base URL and authentication [#base-url-and-authentication] ```http POST https://runepay.co/api/v1/checkout_sessions Authorization: Bearer sk_test_... Content-Type: application/json ``` Send a secret key as a bearer token ([Keys and security](/docs/keys)). The API is server to server: it sends no CORS headers. ## Requests [#requests] - Request bodies are JSON objects, at most 256 KB. - `POST` creates objects and runs actions; `GET` reads and lists. Updating a webhook endpoint uses `PATCH` today; payment links update with `POST`. - Unknown body parameters are rejected (`parameter_unknown`), so a typo fails instead of being ignored. - Every `POST`, `PATCH` and `DELETE` accepts an `Idempotency-Key` header. See [Idempotency](/docs/api/idempotency). ## Responses [#responses] - Objects have an `id` with a type prefix (`cs_`, `pay_`, `re_`, `dp_`, `plink_`, `evt_`, `we_`), `livemode`, and a `created` time. - Times are unix timestamps in seconds. - Money is an integer in the currency's smallest unit (`1999` is $19.99) with a three-letter `currency`, uppercase in responses and any case in requests. USD is the currency enabled today. - `metadata` is a set of string keys and string values you attach and get back. Today, non-string values are dropped. - Every response, errors included, has a `Request-Id` header (`req_…`) and `Cache-Control: no-store`. - Errors share one shape. See [Errors](/docs/api/errors). - Lists are paged. See [Pagination](/docs/api/pagination). ## Resources [#resources] | Resource | What it is | | --- | --- | | [Checkout sessions](/docs/api/checkout-sessions/create-checkout-session) | A hosted checkout page for one payment. The main way to take payments. | | [Payments](/docs/api/payments/list-payments) | Card payments, created by checkout. | | [Refunds](/docs/api/refunds/create-refund) | Money returned to the buyer for a payment. | | [Disputes](/docs/api/disputes/list-disputes) | Chargebacks and inquiries raised by the buyer's bank. | | [Payment links](/docs/api/payment-links/list-payment-links) | Reusable checkout URLs you can share. | | [Balance](/docs/api/balance/retrieve-balance) | Funds RunePay holds for you, by state. | | [Payouts](/docs/api/payouts/list-payouts) | Transfers of your available balance to your bank or wallet. | | [Events](/docs/api/events/list-events) | Things that happened in your account; the same objects webhooks deliver. | | [Webhook endpoints](/docs/api/webhook-endpoints/list-webhook-endpoints) | URLs RunePay sends signed events to. | Webhook payloads are listed in the [event reference](/docs/webhooks/events). # Pagination (/docs/api/pagination) List endpoints (`GET /checkout_sessions`, `/payments`, `/disputes`, `/payouts`, `/payment_links`, `/events`, `/webhook_endpoints` and an endpoint's `/deliveries`) return objects newest first, one page at a time. ```json { "data": [{ "id": "pay_01KA4Y0Z9V3T6N8Q2W5E7R1T3Y", "object": "payment", "...": "..." }], "has_more": true } ``` | Parameter | | | --- | --- | | `limit` | Page size, 1 to 100. Default 20. Out of range is `400 invalid_limit`. | | `starting_after` | An object id from the previous page. The page starts after it. An id this key can't see is `400 invalid_cursor`. | To get the next page, pass the `id` of the last object in `data` as `starting_after`. Stop when `has_more` is `false`. ```js async function* allPayments(key) { let startingAfter; while (true) { const url = new URL("https://runepay.co/api/v1/payments"); url.searchParams.set("limit", "100"); if (startingAfter) url.searchParams.set("starting_after", startingAfter); const res = await fetch(url, { headers: { Authorization: `Bearer ${key}` } }); if (!res.ok) throw new Error(`RunePay ${res.status}`); const page = await res.json(); yield* page.data; if (!page.has_more || page.data.length === 0) return; startingAfter = page.data.at(-1).id; } } ``` Some lists take filters, such as `status` and `created[gte]` / `created[lte]` (unix seconds) on payments, `payment` on disputes, or `active` on payment links. Each endpoint's page lists its own. A later release adds `ending_before` (to page backwards), `object: "list"` and `url` on every list response (payment links already return `object: "list"`), `created[gt]` / `created[lt]`, and more filters. `limit`, `starting_after`, `data` and `has_more` keep working as they do now. # Rate limits (/docs/api/rate-limits) The API does not enforce rate limits yet, and responses carry no rate limit headers. The `rate_limited` error code is reserved for when it does. Hosted checkout has its own limits on attempts per buyer, which you may see as `checkout_rate_limited` or `checkout_attempt_limit` on the checkout page. They don't apply to API requests. ## Planned limits [#planned-limits] These starting limits may be tuned before launch: | Bucket | Limit | | --- | --- | | Live key, all requests | 100 requests per 10 seconds | | Test key, all requests | 50 requests per 10 seconds | | `POST /checkout_sessions` and `POST /refunds` | 25 requests per 10 seconds, separately | Every response will carry `RateLimit-Limit`, `RateLimit-Remaining` and `RateLimit-Reset`. Over the limit, the API will return `429` with `rate_limit_error` / `rate_limited` and a `Retry-After` header in seconds. ## Handling 429 [#handling-429] Build it in now so nothing changes at launch: on a `429`, wait `Retry-After` seconds (or back off exponentially with jitter if it is missing), then retry with the same `Idempotency-Key`. A rate-limited request has not run. # Versioning (/docs/api/versioning) API versions are not implemented yet. Requests don't take a version header and responses don't return one. The plan for v1: - **Date-based versions**, sent as a `RunePay-Version` header (for example `RunePay-Version: 2026-12-15`). The first version is the launch date. - **Pinning:** your account is pinned to the version current at its first API request. A request header overrides the pin for that one request, and the response says which version was used. - **Webhook endpoints** get their own `api_version`, so payloads keep their shape until you change it. - **Additive changes don't need a new version:** new endpoints, new optional parameters, new fields in responses and new event types can appear at any time. Write clients that ignore fields they don't know. - Breaking changes get a new dated version and an entry in the [changelog](/docs/changelog). The `/v1` in the URL only changes for a ground-up redesign. Until launch, the API can still change in breaking ways. Each change is in the changelog. # Changelog (/docs/changelog) The API is not versioned yet (see [Versioning](/docs/api/versioning)). Until the v1 launch, changes are listed here by date. ## Checkout sessions v1 [#checkout-sessions-v1] Checkout creation now requires inline `line_items` with `price_data`; the top-level `amount`, `currency` and `description` shorthand is removed. Sessions return `amount_subtotal`, `amount_tax` and `amount_total` (replacing `amount`), immutable line items, customer and client references, `payment_status` and tax behavior. The current `none` tax calculator returns zero tax. Live launch still requires selecting a tax engine. Retrieve and list sessions, page their line items, or explicitly expire an open session. Hosted checkout shows every item and quantity. Expiry is persisted on read and by the daily settlement sweep, and emits `checkout.session.expired` once. Pending payments prevent expiry. Set `expires_at` between 30 minutes and 24 hours; use `{CHECKOUT_SESSION_ID}` in `success_url` to correlate the return. Customer ids return `404 not_found` until the customers resource ships; use `customer_email` and `client_reference_id` for now. ## Webhook envelope and runner [#webhook-envelope-and-runner] Events now wrap the full object snapshot in `data.object`, with `object: "event"`, `api_version` and originating API `request` context. Fulfil on `checkout.session.completed`. New emitted types: `refund.created`, `dispute.updated`, `payout.created` and `payout.failed`. Updates include changed fields' previous values in `data.previous_attributes`. The first delivery is kicked after commit; the existing every-minute runner retries failures. Delivery requests add `RunePay-Event-Id` and `RunePay-Event-Type`. Endpoint creation accepts `api_version`, `description` and `metadata`; `DELETE /webhook_endpoints/{id}` soft-deletes an endpoint. `GET /events/{id}` retrieves snapshots from the last 30 days, and event lists accept type and creation-time filters. ## 2026-11-15 [#2026-11-15] **Docs.** These docs launch at `/docs`: a quickstart, guides for webhooks, testing, keys, tax, idempotency, pagination, versioning and rate limits, an API reference generated from the OpenAPI spec, and an event reference. Every page is also served as Markdown (`/llms.txt`, `/llms-full.txt`, and `.md` on any page URL). **API foundations.** Behaviour changes for existing integrations: - Errors gain `param`, `request_id` and `doc_url`, and every code is listed in the [error catalog](/docs/api/errors). - Publishable keys are refused with `403 permission_error` (code `secret_key_required`); this was an `authentication_error` before. - Unknown body parameters are rejected with `parameter_unknown`. - Every response carries a `Request-Id` header and `Cache-Control: no-store`. - `Idempotency-Key` is accepted on every `POST`, `PATCH` and `DELETE`. Creating a webhook endpoint and rotating its secret answer a retry with `409 secret_not_replayable` instead of running again. - The OpenAPI 3.1 spec is published at [`/openapi/runepay-v1.json`](/openapi/runepay-v1.json). # RunePay docs (/docs) RunePay is a merchant of record for digital businesses. You create a hosted checkout from your server, send the buyer to it, and RunePay takes the payment, handles disputes and tax as the seller, and pays out your balance to your bank or a stablecoin wallet. The API is plain HTTPS and JSON at `https://runepay.co/api/v1`, authenticated with a secret key. ## Status [#status] The API is in active development ahead of its v1 launch. These docs describe what is live today, and mark anything planned with a **Planned** note. The [changelog](/docs/changelog) lists each change. ## For AI coding agents [#for-ai-coding-agents] - [`/llms.txt`](/llms.txt) indexes these docs, and [`/llms-full.txt`](/llms-full.txt) holds all of them as Markdown. - Any page is available as Markdown by adding `.md` to its URL, for example [`/docs/quickstart.md`](/docs/quickstart.md). - The OpenAPI 3.1 spec is at [`/openapi/runepay-v1.json`](/openapi/runepay-v1.json); the [API reference](/docs/api) is generated from it. # Keys and security (/docs/keys) ## Secret keys [#secret-keys] Every API request is authenticated with a secret key as a bearer token: ```http Authorization: Bearer sk_test_... ``` - `sk_test_…` keys use test mode and `sk_live_…` keys use live mode. See [Testing](/docs/testing). - Create and revoke keys in the dashboard under **Developers → API keys**. A key is shown once, when you create it; RunePay stores only a hash. - A missing, unknown or revoked key gets `401 invalid_api_key`. ## Keep them on your server [#keep-them-on-your-server] A secret key can create checkouts, issue refunds and read your payments and payouts. Treat it like a password: - **Never put it in a browser, mobile app or public repository.** The API sends no CORS headers, so browsers can't call it anyway: create checkout sessions from your server and redirect the buyer to the hosted page. - Store it in your platform's secret manager or an environment variable, not in code. - Give each system its own key, so you can revoke one without touching the others. ## Rotate a key [#rotate-a-key] There is no in-place roll. To rotate: create a new secret key, deploy it, check that requests succeed with it (the dashboard shows each key's last use), then revoke the old one. Revoking is immediate. If a key leaks, revoke it straight away and create a new one. ## Publishable keys [#publishable-keys] The dashboard can still create publishable keys (`pk_test_…`, `pk_live_…`), but nothing uses them: every API endpoint refuses them with `403 secret_key_required`. They are kept for a future embedded checkout. You don't need one. **Restricted keys** (`rk_test_…`, `rk_live_…`) limited to scopes such as `checkout_sessions:write` or `payments:read` are planned, with a preset for e-commerce plugins. Each endpoint's scope is already in the [OpenAPI spec](/openapi/runepay-v1.json) as `x-runepay-scope`. Until they ship, every secret key has full access to its mode. ## Webhook secrets [#webhook-secrets] Each webhook endpoint has its own signing secret (`whsec_…`), separate from API keys. See [verifying signatures](/docs/webhooks#verify-the-signature) and [rotating the secret](/docs/webhooks#rotate-the-secret). # Quickstart: hosted checkout in 5 minutes (/docs/quickstart) You need a RunePay account. Everything here uses **test mode**: no real cards, no real money. ## Get a test secret key [#get-a-test-secret-key] In the dashboard, make sure the top bar says **Test**, then open **Developers → API keys → Create key** and choose **Secret**. Copy the key (`sk_test_…`); it is shown once. Keep it on your server, for example in an environment variable: ```bash export RUNEPAY_KEY=sk_test_... ``` ## Set up your webhook [#set-up-your-webhook] Before taking a payment, create a webhook endpoint for `checkout.session.completed`, the event to fulfil orders on. The endpoint must exist when the payment succeeds to receive its event. The response holds the signing `secret`, shown once: store it. ```bash curl https://runepay.co/api/v1/webhook_endpoints \ -H "Authorization: Bearer $RUNEPAY_KEY" \ -H "Content-Type: application/json" \ -d '{ "url": "https://merchant.example/runepay/webhooks", "enabled_events": ["checkout.session.completed"] }' ``` Set up the handler at that URL now: verify the `RunePay-Signature` header, look up the order by `data.object.id` (the checkout session) or `data.object.metadata.order_id`, fulfil it, and return `200`. [Fulfil orders with webhooks](/docs/webhooks) has the verification code for Node, PHP and Python. When you pay in the next steps, RunePay will send your endpoint a signed `POST` like this: ```json { "id": "evt_01KA8E5F7G9H1J3K5M7N9P1Q3R", "object": "event", "type": "checkout.session.completed", "api_version": "2026-12-15", "livemode": false, "created": 1767225600, "data": { "object": { "id": "cs_01KA4XZY8T2R5M7P1Q4W6E8R0T", "object": "checkout_session", "livemode": false, "status": "complete", "currency": "USD", "description": "Pro plan, 1 month", "customer_email": null, "payment": "pay_01KA4Y0Z9V3T6N8Q2W5E7R1T3Y", "payment_link": null, "success_url": "https://merchant.example/thanks?session={CHECKOUT_SESSION_ID}", "cancel_url": null, "metadata": { "order_id": "1042" }, "url": "https://runepay.co/pay/cs_01KA4XZY8T2R5M7P1Q4W6E8R0T", "expires_at": 1767312000, "created": 1767225600, "amount_subtotal": 1999, "amount_tax": 0, "amount_total": 1999, "tax_behavior": "exclusive", "payment_status": "paid", "line_items": { "object": "list", "url": "/api/v1/checkout_sessions/cs_01KA4XZY8T2R5M7P1Q4W6E8R0T/line_items", "data": [ { "id": "li_01KA4XZY8T2R5M7P1Q4W6E8R0T", "object": "item", "currency": "USD", "quantity": 1, "price_data": { "currency": "USD", "unit_amount": 1999, "product_data": { "name": "Pro plan, 1 month" }, "tax_code": "saas", "tax_behavior": "exclusive" }, "amount_subtotal": 1999, "amount_tax": 0, "amount_total": 1999 } ], "has_more": false }, "client_reference_id": "order_1042", "customer": null, "locale": "auto", "expired_at": null } }, "request": null } ``` The first delivery runs after the payment response; the every-minute runner handles retries for up to 72 hours. ## Create a checkout session [#create-a-checkout-session] One call per order. Amounts are integers in the smallest currency unit, so `1999` is $19.99. Send an `Idempotency-Key` (your order id works) so a retried request never creates a second session. ```bash curl https://runepay.co/api/v1/checkout_sessions \ -H "Authorization: Bearer $RUNEPAY_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: order_1042" \ -d '{ "line_items": [{ "price_data": { "currency": "usd", "unit_amount": 1999, "product_data": { "name": "Pro plan, 1 month" }, "tax_code": "saas" }, "quantity": 1 }], "client_reference_id": "order_1042", "success_url": "https://merchant.example/thanks?session={CHECKOUT_SESSION_ID}", "metadata": { "order_id": "1042" } }' ``` For the typed client with automatic idempotency and retries, see the [Node.js SDK](/docs/sdk). It is available from source and is not published to npm yet. ```js const res = await fetch("https://runepay.co/api/v1/checkout_sessions", { method: "POST", headers: { Authorization: `Bearer ${process.env.RUNEPAY_KEY}`, "Content-Type": "application/json", "Idempotency-Key": "order_1042", }, body: JSON.stringify({ line_items: [{ price_data: { currency: "usd", unit_amount: 1999, product_data: { name: "Pro plan, 1 month" }, tax_code: "saas", }, quantity: 1 }], client_reference_id: "order_1042", success_url: "https://merchant.example/thanks?session={CHECKOUT_SESSION_ID}", metadata: { order_id: "1042" }, }), }); if (!res.ok) throw new Error(`RunePay ${res.status}: ${JSON.stringify(await res.json())}`); const session = await res.json(); // redirect the buyer to session.url ``` The response is `201` with the session. Save its `id` with your order, then redirect the buyer to `url`: ```json { "id": "cs_01KA4XZY8T2R5M7P1Q4W6E8R0T", "object": "checkout_session", "livemode": false, "status": "open", "currency": "USD", "description": "Pro plan, 1 month", "customer_email": null, "payment": null, "payment_link": null, "success_url": "https://merchant.example/thanks?session={CHECKOUT_SESSION_ID}", "cancel_url": null, "metadata": { "order_id": "1042" }, "url": "https://runepay.co/pay/cs_01KA4XZY8T2R5M7P1Q4W6E8R0T", "expires_at": 1767312000, "created": 1767225600, "amount_subtotal": 1999, "amount_tax": 0, "amount_total": 1999, "tax_behavior": "exclusive", "payment_status": "unpaid", "line_items": { "object": "list", "url": "/api/v1/checkout_sessions/cs_01KA4XZY8T2R5M7P1Q4W6E8R0T/line_items", "data": [ { "id": "li_01KA4XZY8T2R5M7P1Q4W6E8R0T", "object": "item", "currency": "USD", "quantity": 1, "price_data": { "currency": "USD", "unit_amount": 1999, "product_data": { "name": "Pro plan, 1 month" }, "tax_code": "saas", "tax_behavior": "exclusive" }, "amount_subtotal": 1999, "amount_tax": 0, "amount_total": 1999 } ], "has_more": false }, "client_reference_id": "order_1042", "customer": null, "locale": "auto", "expired_at": null } ``` A session defaults to 24 hours. Set `expires_at` to a Unix timestamp 30 minutes to 24 hours from creation. Read it with `GET /api/v1/checkout_sessions/:id`; list its items at `GET /api/v1/checkout_sessions/:id/line_items`. An expired session is persisted and emits `checkout.session.expired` once. The success URL placeholder is replaced when the buyer returns; fulfil from the webhook, not the redirect. See [Create a checkout session](/docs/api/checkout-sessions/create-checkout-session) for every parameter. ## Pay with a test card [#pay-with-a-test-card] Open `url` in a browser. The test checkout page lists its test cards; use any future expiry date and any CVC. | Card number | Result | | --- | --- | | `4242 4242 4242 4242` | Succeeds | | `4000 0027 6000 3184` | Asks for a bank check (3D Secure), then succeeds or fails as you choose | | `4000 0000 0000 0002` | Is declined | After a successful payment, the buyer lands on your `success_url` and RunePay queues `checkout.session.completed` for the endpoint you registered. [Testing](/docs/testing) covers every outcome, and the cards to use when the test processor is the Rebilly sandbox. ## Check the payment [#check-the-payment] To read the payment yourself, for example on your success page, retrieve it by the id from the event: ```bash curl https://runepay.co/api/v1/payments/pay_01KA4Y0Z9V3T6N8Q2W5E7R1T3Y \ -H "Authorization: Bearer $RUNEPAY_KEY" ``` A `status` of `succeeded` means you were paid. The payment's `checkout_session` field links it back to your session. ## Go live [#go-live] When your account is approved, switch the dashboard to **Live**, create a live secret key (`sk_live_…`) and a live webhook endpoint, and use them instead. Test and live data never mix: a test key cannot see live objects, and the other way round. Until approval, live keys get `403 account_not_live`. # Node.js SDK (/docs/sdk) `@runepay/node` is RunePay's first-party TypeScript client for Node.js 18 and later. It wraps the [merchant API reference](/docs/api) with generated types, safe retries, pagination and webhook verification. Use it on your server. ## Install from source [#install-from-source] Version `0.1.0` is **not published to the npm registry yet**. The source lives at `packages/node` in the RunePay repository. If you have a checkout, build and pack that package, then install the archive into your application: ```bash # From your RunePay checkout: cd packages/node yarn install --frozen-lockfile yarn pack --filename runepay-node-0.1.0.tgz # From your application directory, using the actual checkout path: yarn add /absolute/path/to/runepay/packages/node/runepay-node-0.1.0.tgz ``` The package is ESM and includes TypeScript declarations. It uses Node's built-in `fetch` and has no runtime dependencies. ## Initialise the client [#initialise-the-client] Create a test [API key](/docs/keys) (`sk_test_…`) and set `RUNEPAY_KEY` on your server. Switch to a live key (`sk_live_…`) after your account is approved. Test and live data are separate. ```ts import RunePay from '@runepay/node'; const runepay = new RunePay({ apiKey: process.env.RUNEPAY_KEY }); // Or new RunePay(): reads RUNEPAY_KEY, then RUNEPAY_API_KEY. ``` A key is required. Never put secret keys in browser code. The default API URL is `https://runepay.co/api/v1`; pass `baseUrl` to use another server. ## Create a checkout session [#create-a-checkout-session] The [Quickstart](/docs/quickstart) walks through the full payment flow. Amounts use the smallest currency unit: `1999` is $19.99. ```ts const session = await runepay.checkoutSessions.create({ line_items: [{ price_data: { currency: 'usd', unit_amount: 1999, product_data: { name: 'Pro plan, 1 month' }, tax_code: 'saas', }, quantity: 1, }], client_reference_id: 'order_1042', success_url: 'https://merchant.example/thanks?session={CHECKOUT_SESSION_ID}', }, { idempotencyKey: 'order_1042' }); // In a server route: redirect the buyer to session.url. const response = Response.redirect(session.url, 303); ``` Fulfil the order from a verified `checkout.session.completed` webhook. The redirect alone does not confirm payment. ## Idempotency, retries and errors [#idempotency-retries-and-errors] POST, PATCH and DELETE calls receive a unique `Idempotency-Key` automatically. The same key and body are reused on every retry of that call. Pass your order's stable `idempotencyKey`, as above, when you may repeat the operation across separate SDK calls. The client retries 429 and 5xx responses twice by default, with exponential backoff starting at 500 ms and honoring `Retry-After`. `deletePreviousSecret` is not retried automatically, because the API ignores idempotency keys for that operation and a retry could retire a newer overlap secret. Configure the other defaults in the constructor: ```ts const runepay = new RunePay({ maxRetries: 3, retryDelayMs: 1000 }); ``` Request options also accept `signal` (an `AbortSignal`) and `requestId` (sent as `Request-Id`). API failures throw `RunePayError` with the HTTP `status` and available `type`, `code`, `param`, `request_id`, `doc_url` and `object_id` fields. ```ts import { RunePayError } from '@runepay/node'; try { const payment = await runepay.payments.retrieve('pay_example'); console.log(payment.status); } catch (error) { if (error instanceof RunePayError) { console.error(error.status, error.code, error.request_id); } throw error; } ``` ## List one page or iterate [#list-one-page-or-iterate] `list()` returns a single API list object. `autoPagingIterable()` fetches subsequent pages lazily using `starting_after`, the last item id and `has_more`. Breaking the loop stops further requests. ```ts const page = await runepay.payments.list({ limit: 20 }); console.log(page.data, page.has_more); for await (const payment of runepay.payments.autoPagingIterable({ limit: 100 })) { console.log(payment.id); } ``` The client covers checkout sessions, payments, refunds, disputes, payment links, balance, payouts, events and webhook endpoints. Nested lists use `checkoutSessions.listLineItems()` / `lineItemsIterator()` and `webhookEndpoints.listDeliveries()` / `deliveriesIterator()`. See the [API reference](/docs/api) for parameters and response fields. ## Verify webhooks [#verify-webhooks] Read the **exact raw body** before parsing JSON. `constructEvent` checks the `RunePay-Signature` header against the endpoint secret, accepts any matching `v1` during rotation, enforces a five-minute timestamp tolerance, and returns the parsed event. Verification failures throw `WebhookSignatureError`. This example uses a server route with the standard Request/Response API: ```ts import { constructEvent, WebhookSignatureError } from '@runepay/node'; export async function POST(request: Request) { const secret = process.env.RUNEPAY_WEBHOOK_SECRET; if (!secret) throw new Error('RUNEPAY_WEBHOOK_SECRET is required'); let event; try { event = constructEvent( new Uint8Array(await request.arrayBuffer()), request.headers.get('RunePay-Signature') ?? '', secret, ); } catch (error) { if (error instanceof WebhookSignatureError) { return new Response('Invalid webhook', { status: 400 }); } throw error; } // Durably store event, deduplicate on event.id, and queue fulfilment here. // A storage or queue failure should return a non-2xx response so RunePay retries. return new Response(null, { status: 200 }); } ``` You can also call `runepay.webhooks.constructEvent(rawBody, header, secret)`. An optional fourth argument changes the timestamp tolerance in seconds; keep replay protection enabled in production. See [Webhooks](/docs/webhooks) for endpoint setup, deduplication, delivery retries and rotation. # Tax and merchant of record (/docs/tax-and-mor) RunePay is the **merchant of record** (MoR) for sales made through it. The buyer's card statement shows RunePay, and RunePay is the seller of record to the buyer. In practice: - **You don't need your own merchant account.** RunePay's acquiring relationships process the payment. - **RunePay handles disputes** with the card networks. You see them as [disputes](/docs/api/disputes/list-disputes) and `dispute.*` events, with the financial effect on your balance. - **RunePay is responsible for sales tax and VAT** on those sales, as the seller of record. - **You are paid out** your balance, net of fees, refunds and disputes, to your bank or a stablecoin wallet on your settlement schedule. See [Merchant of record](/merchant-of-record) for the commercial side. ## Tax in the API today [#tax-in-the-api-today] Create checkout sessions with 1–100 inline `line_items`, each containing `price_data` and a positive integer `quantity`. `price_data` has a currency, integer `unit_amount`, `product_data.name`, optional product description, `tax_code` and `tax_behavior`. All items must share a currency. `tax_behavior` is `exclusive` by default or `inclusive`. The supported codes are `digital_software`, `digital_service`, `ebook`, `saas` and `general_digital` (the default). A session with mixed behaviors reports `tax_behavior: null`; each item keeps its own behavior. Sessions expose `amount_subtotal`, `amount_tax` and `amount_total`; `amount_total` replaces the old `amount` field. Payments expose `amount_tax`. The `none` calculator currently returns zero tax for either behavior. Tax has its own platform `tax_payable` account and is excluded from merchant capture and settlement balances. A real tax engine must be selected and integrated before live sales launch. The current calculator does not determine tax from buyer location or remit tax. These fields and the zero-tax calculator prepare the API for that integration. ## Customer references [#customer-references] `customer_email` and `customer` are mutually exclusive. There is no customers resource yet, so a supplied `customer` id returns `404 not_found`. The session and payment return `customer: null`. Use `customer_email` and `client_reference_id` to associate the checkout with your own records. # Testing (/docs/testing) Test mode is the sandbox. There is no separate environment: the same API, with a test key, on test data. ## Test and live [#test-and-live] | | Test | Live | | --- | --- | --- | | Secret key | `sk_test_…` | `sk_live_…` | | Data | Test objects only | Live objects only | | Cards | Test cards, no money moves | Real cards | | Availability | Always | After your account is approved (`403 account_not_live` before) | Every object has `livemode`. Keys, webhook endpoints, events and idempotency keys are all per mode: a test key never sees live objects, and a test endpoint never receives live events. Switch the dashboard between **Test** and **Live** in the top bar. ## Test cards [#test-cards] The hosted checkout page shows the test cards for the processor behind test mode. Use any future expiry date and any CVC. ### RunePay test processor [#runepay-test-processor] The default test processor simulates outcomes from the card number: | Card number | Result | Processor token | | --- | --- | --- | | `4242 4242 4242 4242` | Succeeds: `payment.succeeded`, then `checkout.session.completed` | `tok_success` | | `4000 0027 6000 3184` | Asks for a bank check (3D Secure). The page shows **Approve** and **Fail** buttons for the check | `tok_3ds` | | `4000 0000 0000 0002` | Declined with `decline_code: "do_not_honor"`: `payment.failed` | `tok_decline` | | Any other valid number | Succeeds | `tok_success` | The test processor also has a `tok_pending` outcome (a payment that stays pending until settled by hand), used by RunePay's own tests. The hosted checkout does not offer it. ### Rebilly sandbox [#rebilly-sandbox] When test mode runs on the Rebilly sandbox, the page shows Rebilly's cards instead: | Card number | Result | | --- | --- | | `5555 5555 5555 4444` | Succeeds | | `4111 1111 1111 1111` | Asks for a bank check (when 3D Secure is on for the sandbox gateway) | | `4000 0000 0000 0002` | Is declined | ## Test the rest of the flow [#test-the-rest-of-the-flow] - **Refunds:** `POST /refunds` with a succeeded test payment's id. A full refund sends `refund.succeeded` and `payment.refunded`; a partial one sends `refund.succeeded`. - **Webhooks:** point a test endpoint at a tunnel to your machine (for example `cloudflared` or `ngrok`); localhost URLs are refused. Use [replay](/docs/webhooks#replay-an-event) to resend an event while you work on your handler. - **Errors:** send a bad request on purpose, such as a string `"unit_amount": "19.99"` inside `line_items[0].price_data`, to see the [error shape](/docs/api/errors). Test helpers to simulate disputes and move the settlement clock (`POST /test_helpers/…`, test mode only) are planned. Until then, disputes and payouts can't be triggered from the API in test mode. # Event reference (/docs/webhooks/events) Each delivery is a JSON `POST` with this envelope. `data.object` is the full serialized object. ```json { "id": "evt_01KA8E5F7G9H1J3K5M7N9P1Q3R", "object": "event", "type": "checkout.session.completed", "api_version": "2026-12-15", "livemode": false, "created": 1767225600, "data": { "object": { "id": "cs_01KA4XZY8T2R5M7P1Q4W6E8R0T", "object": "checkout_session", "livemode": false, "status": "complete", "payment_status": "paid", "amount_subtotal": 1999, "amount_tax": 0, "amount_total": 1999, "currency": "USD", "tax_behavior": "exclusive", "line_items": { "object": "list", "url": "/api/v1/checkout_sessions/cs_01KA4XZY8T2R5M7P1Q4W6E8R0T/line_items", "data": [ { "id": "li_01KA4XZY8T2R5M7P1Q4W6E8R0T", "object": "item", "currency": "USD", "quantity": 1, "price_data": { "currency": "USD", "unit_amount": 1999, "product_data": { "name": "Pro plan, 1 month" }, "tax_code": "saas", "tax_behavior": "exclusive" }, "amount_subtotal": 1999, "amount_tax": 0, "amount_total": 1999 } ], "has_more": false }, "description": "Pro plan, 1 month", "customer_email": null, "customer": null, "client_reference_id": "order_1042", "payment": "pay_01KA4Y0Z9V3T6N8Q2W5E7R1T3Y", "payment_link": null, "success_url": "https://merchant.example/thanks?session={CHECKOUT_SESSION_ID}", "cancel_url": null, "metadata": { "order_id": "1042" }, "locale": "auto", "url": "https://runepay.co/pay/cs_01KA4XZY8T2R5M7P1Q4W6E8R0T", "expires_at": 1767312000, "expired_at": null, "created": 1767225600 } }, "request": null } ``` | Field | | | --- | --- | | `id` | The event id (`evt_…`). The same on every retry and replay: deduplicate on it. | | `object` | Always `event`. | | `api_version` | The endpoint's API version (currently `2026-12-15`). | | `request` | Originating API request id and idempotency key, or null for processor, cron and dashboard events. | | `type` | One of the 16 types below. | | `livemode` | `false` for test-mode events. | | `created` | When the event happened, unix seconds. | | `data.object` | Full object snapshot taken when the event happened; retrieve the object for its current state. | | `data.previous_attributes` | Previous values of changed fields, only on `*.updated`. | Endpoints subscribe to a list of these types, or to `["*"]` for all of them. The same events are listed by `GET /events`. Events are listable and retrievable for 30 days through `GET /events` and `GET /events/{id}`. Event rows are retained for audit; delivery history is pruned after 30 days. Deliveries also carry `RunePay-Event-Id` and `RunePay-Event-Type`. Verify the signature before trusting either header. ## `checkout.session.completed` [#checkoutsessioncompleted] A checkout session's payment succeeded. Sent right after `payment.succeeded` for payments that came from a checkout session. **Fulfil orders on this event.** **`data.object`:** The full checkout session, including `payment`, amount, currency and metadata. Fulfil using `data.object.id` or your metadata order id. ```json { "object": { "id": "cs_01KA4XZY8T2R5M7P1Q4W6E8R0T", "object": "checkout_session", "livemode": false, "status": "complete", "payment_status": "paid", "amount_subtotal": 1999, "amount_tax": 0, "amount_total": 1999, "currency": "USD", "tax_behavior": "exclusive", "line_items": { "object": "list", "url": "/api/v1/checkout_sessions/cs_01KA4XZY8T2R5M7P1Q4W6E8R0T/line_items", "data": [ { "id": "li_01KA4XZY8T2R5M7P1Q4W6E8R0T", "object": "item", "currency": "USD", "quantity": 1, "price_data": { "currency": "USD", "unit_amount": 1999, "product_data": { "name": "Pro plan, 1 month" }, "tax_code": "saas", "tax_behavior": "exclusive" }, "amount_subtotal": 1999, "amount_tax": 0, "amount_total": 1999 } ], "has_more": false }, "description": "Pro plan, 1 month", "customer_email": null, "customer": null, "client_reference_id": "order_1042", "payment": "pay_01KA4Y0Z9V3T6N8Q2W5E7R1T3Y", "payment_link": null, "success_url": "https://merchant.example/thanks?session={CHECKOUT_SESSION_ID}", "cancel_url": null, "metadata": { "order_id": "1042" }, "locale": "auto", "url": "https://runepay.co/pay/cs_01KA4XZY8T2R5M7P1Q4W6E8R0T", "expires_at": 1767312000, "expired_at": null, "created": 1767225600 } } ``` ## `checkout.session.expired` [#checkoutsessionexpired] An open session expires or is explicitly expired, with no pending payment. **`data.object`:** The full checkout session, including immutable line items and zero-tax totals. ```json { "object": { "id": "cs_01KA4XZY8T2R5M7P1Q4W6E8R0T", "object": "checkout_session", "livemode": false, "status": "expired", "payment_status": "unpaid", "amount_subtotal": 1999, "amount_tax": 0, "amount_total": 1999, "currency": "USD", "tax_behavior": "exclusive", "line_items": { "object": "list", "url": "/api/v1/checkout_sessions/cs_01KA4XZY8T2R5M7P1Q4W6E8R0T/line_items", "data": [ { "id": "li_01KA4XZY8T2R5M7P1Q4W6E8R0T", "object": "item", "currency": "USD", "quantity": 1, "price_data": { "currency": "USD", "unit_amount": 1999, "product_data": { "name": "Pro plan, 1 month" }, "tax_code": "saas", "tax_behavior": "exclusive" }, "amount_subtotal": 1999, "amount_tax": 0, "amount_total": 1999 } ], "has_more": false }, "description": "Pro plan, 1 month", "customer_email": null, "customer": null, "client_reference_id": "order_1042", "payment": null, "payment_link": null, "success_url": "https://merchant.example/thanks?session={CHECKOUT_SESSION_ID}", "cancel_url": null, "metadata": { "order_id": "1042" }, "locale": "auto", "url": "https://runepay.co/pay/cs_01KA4XZY8T2R5M7P1Q4W6E8R0T", "expires_at": 1767312000, "expired_at": 1767225600, "created": 1767225600 } } ``` ## `payment.succeeded` [#paymentsucceeded] A payment succeeded (from hosted checkout or a payment link). **`data.object`:** The full [payment](/docs/api/payments/retrieve-payment) object. ```json { "object": { "id": "pay_01KA4Y0Z9V3T6N8Q2W5E7R1T3Y", "object": "payment", "livemode": false, "status": "succeeded", "amount": 1999, "amount_refunded": 0, "amount_tax": 0, "customer": null, "currency": "USD", "fee": 88, "description": "Pro plan, 1 month", "customer_email": "buyer@example.com", "metadata": { "order_id": "1042" }, "checkout_session": "cs_01KA4XZY8T2R5M7P1Q4W6E8R0T", "card": { "brand": "visa", "last4": "4242" }, "decline_code": null, "decline_message": null, "outcome": { "risk_level": "normal", "risk_score": 12 }, "available_on": 1767830400, "created": 1767225600 } } ``` ## `payment.failed` [#paymentfailed] A payment attempt failed, for example a decline. **`data.object`:** The full payment object, with `decline_code` and `decline_message`. ```json { "object": { "id": "pay_01KA4Y0Z9V3T6N8Q2W5E7R1T3Y", "object": "payment", "livemode": false, "status": "failed", "amount": 1999, "amount_refunded": 0, "amount_tax": 0, "customer": null, "currency": "USD", "fee": null, "description": "Pro plan, 1 month", "customer_email": "buyer@example.com", "metadata": { "order_id": "1042" }, "checkout_session": "cs_01KA4XZY8T2R5M7P1Q4W6E8R0T", "card": { "brand": "visa", "last4": "4242" }, "decline_code": "do_not_honor", "decline_message": "The card was declined.", "outcome": { "risk_level": "normal", "risk_score": 12 }, "available_on": null, "created": 1767225600 } } ``` ## `payment.refunded` [#paymentrefunded] A payment is now fully refunded. Partial refunds send `refund.succeeded` only. **`data.object`:** The full payment object. ```json { "object": { "id": "pay_01KA4Y0Z9V3T6N8Q2W5E7R1T3Y", "object": "payment", "livemode": false, "status": "refunded", "amount": 1999, "amount_refunded": 1999, "amount_tax": 0, "customer": null, "currency": "USD", "fee": 88, "description": "Pro plan, 1 month", "customer_email": "buyer@example.com", "metadata": { "order_id": "1042" }, "checkout_session": "cs_01KA4XZY8T2R5M7P1Q4W6E8R0T", "card": { "brand": "visa", "last4": "4242" }, "decline_code": null, "decline_message": null, "outcome": { "risk_level": "normal", "risk_score": 12 }, "available_on": 1767830400, "created": 1767225600 } } ``` ## `refund.created` [#refundcreated] A refund was requested and is pending, before contacting the processor. **`data.object`:** The full refund object with status `pending`. ```json { "object": { "id": "re_01KA5B2C4D6E8F0G2H4J6K8M0N", "object": "refund", "livemode": false, "payment": "pay_01KA4Y0Z9V3T6N8Q2W5E7R1T3Y", "amount": 500, "currency": "USD", "status": "pending", "reason": "requested_by_customer", "failure_reason": null, "created": 1767312000 } } ``` ## `refund.succeeded` [#refundsucceeded] A refund completed. **`data.object`:** The full [refund](/docs/api/refunds/create-refund) object. ```json { "object": { "id": "re_01KA5B2C4D6E8F0G2H4J6K8M0N", "object": "refund", "livemode": false, "payment": "pay_01KA4Y0Z9V3T6N8Q2W5E7R1T3Y", "amount": 500, "currency": "USD", "status": "succeeded", "reason": "requested_by_customer", "failure_reason": null, "created": 1767312000 } } ``` ## `refund.failed` [#refundfailed] A refund failed at the processor. **`data.object`:** The full refund object. ```json { "object": { "id": "re_01KA5B2C4D6E8F0G2H4J6K8M0N", "object": "refund", "livemode": false, "payment": "pay_01KA4Y0Z9V3T6N8Q2W5E7R1T3Y", "amount": 500, "currency": "USD", "status": "failed", "reason": "requested_by_customer", "failure_reason": null, "created": 1767312000 } } ``` ## `dispute.created` [#disputecreated] The buyer's bank opened a dispute (a chargeback or an inquiry). **`data.object`:** The full dispute object, including `financial_effect` and `evidence_due_by`. ```json { "object": { "id": "dp_01KA6C3D5E7F9G1H3J5K7M9N1P", "object": "dispute", "livemode": false, "payment": "pay_01KA4Y0Z9V3T6N8Q2W5E7R1T3Y", "amount": 1999, "currency": "USD", "status": "needs_response", "reason": "fraudulent", "financial_effect": "chargeback", "chargeback_fee": 1500, "evidence_due_by": 1768435200, "closed_at": null, "created": 1767398400 } } ``` ## `dispute.updated` [#disputeupdated] A dispute's status or evidence deadline changed. **`data.object`:** The full dispute object. `data.previous_attributes` contains prior values of changed fields. ```json { "object": { "id": "dp_01KA6C3D5E7F9G1H3J5K7M9N1P", "object": "dispute", "livemode": false, "payment": "pay_01KA4Y0Z9V3T6N8Q2W5E7R1T3Y", "amount": 1999, "currency": "USD", "status": "needs_response", "reason": "fraudulent", "financial_effect": "chargeback", "chargeback_fee": 1500, "evidence_due_by": 1768435200, "closed_at": null, "created": 1767398400 }, "previous_attributes": { "status": "under_review" } } ``` ## `dispute.closed` [#disputeclosed] A dispute was won or lost. **`data.object`:** The full dispute object. ```json { "object": { "id": "dp_01KA6C3D5E7F9G1H3J5K7M9N1P", "object": "dispute", "livemode": false, "payment": "pay_01KA4Y0Z9V3T6N8Q2W5E7R1T3Y", "amount": 1999, "currency": "USD", "status": "won", "reason": "fraudulent", "financial_effect": "chargeback", "chargeback_fee": 1500, "evidence_due_by": 1768435200, "closed_at": 1767225600, "created": 1767398400 } } ``` ## `payout.created` [#payoutcreated] A payout was approved and is in transit. **`data.object`:** The full payout object with status `in_transit`. ```json { "object": { "id": "8d0c7a52-3f3e-4c1b-9a77-0c5b8f1e2d34", "object": "payout", "livemode": false, "amount": 10200, "currency": "USD", "status": "in_transit", "rail": "fiat_ach", "bank_reference": null, "tx_hash": null, "paid_at": null, "created": 1767744000 } } ``` ## `payout.paid` [#payoutpaid] A payout reached your bank or wallet. **`data.object`:** The full payout object. ```json { "object": { "id": "8d0c7a52-3f3e-4c1b-9a77-0c5b8f1e2d34", "object": "payout", "livemode": false, "amount": 10200, "currency": "USD", "status": "paid", "rail": "fiat_ach", "bank_reference": "ACH-20260107-0042", "tx_hash": null, "paid_at": 1767830400, "created": 1767744000 } } ``` ## `payout.failed` [#payoutfailed] A payout failed and its funds were returned to your available balance. **`data.object`:** The full payout object with status `failed`. ```json { "object": { "id": "8d0c7a52-3f3e-4c1b-9a77-0c5b8f1e2d34", "object": "payout", "livemode": false, "amount": 10200, "currency": "USD", "status": "failed", "rail": "fiat_ach", "bank_reference": null, "tx_hash": null, "paid_at": null, "created": 1767744000 } } ``` ## `payment_link.created` [#payment_linkcreated] A payment link was created (API or dashboard). **`data.object`:** The full [payment link](/docs/api/payment-links/retrieve-payment-link) object. ```json { "object": { "id": "plink_01KA7D4E6F8G0H2J4K6M8N0P2Q", "object": "payment_link", "livemode": false, "active": true, "name": "Pro plan", "description": "One month of Pro", "amount": 1999, "min_amount": null, "max_amount": null, "currency": "USD", "success_url": "https://merchant.example/thanks", "metadata": { "plan": "pro" }, "url": "https://runepay.co/pay/l/plink_01KA7D4E6F8G0H2J4K6M8N0P2Q", "created": 1767225600, "updated": 1767225600 } } ``` ## `payment_link.updated` [#payment_linkupdated] A payment link changed, including being deactivated. **`data.object`:** The full payment link object. ```json { "object": { "id": "plink_01KA7D4E6F8G0H2J4K6M8N0P2Q", "object": "payment_link", "livemode": false, "active": false, "name": "Pro plan", "description": "One month of Pro", "amount": 1999, "min_amount": null, "max_amount": null, "currency": "USD", "success_url": "https://merchant.example/thanks", "metadata": { "plan": "pro" }, "url": "https://runepay.co/pay/l/plink_01KA7D4E6F8G0H2J4K6M8N0P2Q", "created": 1767225600, "updated": 1767225600 }, "previous_attributes": { "active": true } } ``` # Fulfil orders with webhooks (/docs/webhooks) RunePay tells your server about payments, refunds, disputes and payouts by sending signed events to your webhook endpoints. Fulfil orders from the **`checkout.session.completed`** event, not from the buyer landing on your `success_url`: the buyer can close the tab before the redirect, and anyone can open the success URL. ## Create an endpoint [#create-an-endpoint] Endpoints are per mode: a test endpoint only receives test events. Create one in the dashboard (**Developers → Webhooks**) or with the API: ```bash curl https://runepay.co/api/v1/webhook_endpoints \ -H "Authorization: Bearer $RUNEPAY_KEY" \ -H "Content-Type: application/json" \ -d '{ "url": "https://merchant.example/runepay/webhooks", "enabled_events": ["checkout.session.completed", "refund.succeeded"] }' ``` - `url` must be a public HTTPS URL. Private addresses, IP literals and redirects are refused. - `api_version` defaults to `2026-12-15`. You can also set `description` and string `metadata`. - `enabled_events` lists [event types](/docs/webhooks/events), or `["*"]` for all of them. - The response includes `secret` (`whsec_…`) **once**. It is never shown again, and a retry with the same `Idempotency-Key` returns `409 secret_not_replayable` with the endpoint id instead of the secret. If you lose it, [rotate](/docs/api/webhook-endpoints/rotate-webhook-endpoint-secret) to get a new one. `DELETE /webhook_endpoints/{id}` soft-deletes an endpoint, hides it from reads and stops pending and future deliveries. ## What a delivery looks like [#what-a-delivery-looks-like] Each event is a `POST` with a JSON body and these headers: | Header | | | --- | --- | | `Content-Type` | `application/json` | | `RunePay-Signature` | `t=,v1=` | | `RunePay-Event-Id` | The event id (`evt_…`), unchanged on retries. | | `RunePay-Event-Type` | The event type, for example `checkout.session.completed`. | ```json { "id": "evt_01KA8E5F7G9H1J3K5M7N9P1Q3R", "object": "event", "type": "checkout.session.completed", "api_version": "2026-12-15", "livemode": false, "created": 1767225600, "data": { "object": { "id": "cs_01KA4XZY8T2R5M7P1Q4W6E8R0T", "object": "checkout_session", "livemode": false, "status": "complete", "currency": "USD", "description": "Pro plan, 1 month", "customer_email": null, "payment": "pay_01KA4Y0Z9V3T6N8Q2W5E7R1T3Y", "payment_link": null, "success_url": "https://merchant.example/thanks", "cancel_url": null, "metadata": { "order_id": "1042" }, "url": "https://runepay.co/pay/cs_01KA4XZY8T2R5M7P1Q4W6E8R0T", "expires_at": 1767312000, "created": 1767225600, "amount_subtotal": 1999, "amount_tax": 0, "amount_total": 1999, "tax_behavior": "exclusive", "payment_status": "paid", "line_items": { "object": "list", "url": "/api/v1/checkout_sessions/cs_01KA4XZY8T2R5M7P1Q4W6E8R0T/line_items", "data": [ { "id": "li_01KA4XZY8T2R5M7P1Q4W6E8R0T", "object": "item", "currency": "USD", "quantity": 1, "price_data": { "currency": "USD", "unit_amount": 1999, "product_data": { "name": "Pro plan, 1 month" }, "tax_code": "saas", "tax_behavior": "exclusive" }, "amount_subtotal": 1999, "amount_tax": 0, "amount_total": 1999 } ], "has_more": false }, "client_reference_id": "order_1042", "customer": null, "locale": "auto", "expired_at": null } }, "request": null } ``` The [event reference](/docs/webhooks/events) lists what `data` holds for each type. The object is a snapshot taken when the event happened. `request` is the originating API request (`id` and `idempotency_key`), or null for processor, cron and dashboard events. Only `*.updated` events include `data.previous_attributes`. Verify the signature before trusting routing headers or body fields. ## Verify the signature [#verify-the-signature] The signature is an HMAC-SHA256, keyed with your endpoint secret, over the timestamp, a period, and the **raw request body**: `"{t}.{body}"`. Compute it over the bytes you received, before parsing the JSON; re-serialising changes them. 1. Split the header on `,` and read `t` and every `v1`. 2. Reject the event if `t` is more than 5 minutes from your clock (replay protection). 3. Compute the HMAC and compare it with each `v1` in constant time. Accept if any matches: while a secret [rotation](/docs/api/webhook-endpoints/rotate-webhook-endpoint-secret) overlaps, the header carries one `v1` per active secret. The [Node.js SDK](/docs/sdk#verify-webhooks) provides `constructEvent` for verification and parsing. It is available from source and is not published to npm yet. The manual verifier below works without the SDK. ```mjs import { createHmac, timingSafeEqual } from "node:crypto"; // rawBody: the request body exactly as received (a string, before JSON.parse). // header: the RunePay-Signature header. secret: the endpoint's whsec_… secret. export function verifyRunePaySignature(rawBody, header, secret, toleranceSeconds = 300, now = Date.now() / 1000) { const parts = header.split(",").map((part) => part.trim().split("=")); const t = Number(parts.find(([key]) => key === "t")?.[1]); if (!Number.isInteger(t) || Math.abs(now - t) > toleranceSeconds) return false; const expected = createHmac("sha256", secret).update(`${t}.${rawBody}`).digest(); // During a secret rotation the header carries one v1 per active secret. return parts.some( ([key, value]) => key === "v1" && /^[0-9a-f]{64}$/i.test(value ?? "") && timingSafeEqual(expected, Buffer.from(value, "hex")), ); } ``` With Express, read the raw body for this route only: ```js app.post("/runepay/webhooks", express.raw({ type: "application/json" }), (req, res) => { const raw = req.body.toString("utf8"); if (!verifyRunePaySignature(raw, req.get("RunePay-Signature") ?? "", process.env.RUNEPAY_WEBHOOK_SECRET)) { return res.sendStatus(400); } const event = JSON.parse(raw); // dedupe on event.id, queue the work, then: res.sendStatus(200); }); ``` ```php $tolerance) { return false; } $expected = hash_hmac('sha256', $t . '.' . $rawBody, $secret); foreach ($signatures as $signature) { if (hash_equals($expected, $signature)) { return true; } } return false; } ``` ```php $raw = file_get_contents('php://input'); if (!verify_runepay_signature($raw, $_SERVER['HTTP_RUNEPAY_SIGNATURE'] ?? '', getenv('RUNEPAY_WEBHOOK_SECRET'))) { http_response_code(400); exit; } $event = json_decode($raw, true); ``` ```py import hashlib import hmac import time # raw_body: the request body exactly as received (bytes, before json.loads). # header: the RunePay-Signature header. secret: the endpoint's whsec_… secret. def verify_runepay_signature(raw_body: bytes, header: str, secret: str, tolerance: int = 300, now: float | None = None) -> bool: t, signatures = None, [] for part in header.split(","): key, _, value = part.strip().partition("=") if key == "t" and value.isdigit(): t = int(value) elif key == "v1": # During a secret rotation the header carries one v1 per active secret. signatures.append(value) if t is None or abs((time.time() if now is None else now) - t) > tolerance: return False expected = hmac.new(secret.encode(), f"{t}.".encode() + raw_body, hashlib.sha256).hexdigest() return any(hmac.compare_digest(expected, signature) for signature in signatures) ``` ```python # Flask @app.post("/runepay/webhooks") def runepay_webhook(): raw = request.get_data() if not verify_runepay_signature(raw, request.headers.get("RunePay-Signature", ""), os.environ["RUNEPAY_WEBHOOK_SECRET"]): abort(400) event = json.loads(raw) return "", 200 ``` ### Test vector [#test-vector] Check your implementation against this vector. With your clock set to `timestamp` (or the tolerance check disabled), the header must verify, and changing any byte of the body must make it fail. RunePay's test suite checks all three snippets above against it. ```json { "secret": "whsec_docs_test_vector_do_not_use", "timestamp": 1767225600, "body": "{\"id\":\"evt_01KA8E5F7G9H1J3K5M7N9P1Q3R\",\"object\":\"event\",\"type\":\"checkout.session.completed\",\"api_version\":\"2026-12-15\",\"livemode\":false,\"created\":1767225600,\"data\":{\"object\":{\"id\":\"cs_01KA4XZY8T2R5M7P1Q4W6E8R0T\",\"object\":\"checkout_session\",\"livemode\":false,\"status\":\"complete\",\"amount\":1999,\"currency\":\"USD\",\"description\":\"Pro plan, 1 month\",\"customer_email\":null,\"payment\":\"pay_01KA4Y0Z9V3T6N8Q2W5E7R1T3Y\",\"payment_link\":null,\"success_url\":\"https://merchant.example/thanks\",\"cancel_url\":null,\"metadata\":{\"order_id\":\"1042\"},\"url\":\"https://runepay.co/pay/cs_01KA4XZY8T2R5M7P1Q4W6E8R0T\",\"expires_at\":1767312000,\"created\":1767225600}},\"request\":null}", "signature_header": "t=1767225600,v1=8c406ba8c6c6606433c80ec471a3a04e5fca2811471598dd4a32f7b4e8d97bb1" } ``` ## Handle events safely [#handle-events-safely] - **Deduplicate on `event.id`.** Delivery is at least once: the same event can arrive more than once, including after a [replay](#replay-an-event). Record the ids you have processed and skip repeats. - **Respond 2xx fast.** RunePay waits up to 10 seconds. Store the event, return `200`, and do slow work (emails, licence generation) in a background job. Anything other than 2xx, including a redirect, counts as a failure. - **Don't rely on order.** Events can arrive out of order. Treat each one as a snapshot and retrieve the object (for example `GET /payments/{id}`) when you need its current state. - **Check the mode.** `livemode` is `false` for test events. ## Retries and failures [#retries-and-failures] A failed delivery is retried with jittered exponential backoff, starting at about a minute and capped at 4 hours between attempts, for up to 72 hours. If an endpoint keeps failing with no success for 72 hours, RunePay disables it, fails its pending deliveries and emails the account owner. Fix the endpoint, re-enable it, and replay what you missed. `GET /webhook_endpoints/{id}/deliveries` and the endpoint's page in the dashboard show each delivery's status, attempts and last response code. ## Replay an event [#replay-an-event] To send an event again, for example after fixing a bug in your handler: ```bash curl https://runepay.co/api/v1/webhook_endpoints/we_01KA9F6G8H0J2K4M6N8P0Q2R4S/replay \ -H "Authorization: Bearer $RUNEPAY_KEY" \ -H "Content-Type: application/json" \ -d '{ "event_id": "evt_01KA8E5F7G9H1J3K5M7N9P1Q3R" }' ``` The replay has the same event id, body and `created`; only the signature timestamp is new. `GET /events` lists the last 30 days of events; filter by `type=payment.*` or creation time. `GET /events/{id}` retrieves the original snapshot within that window. Delivery history is pruned after 30 days, while event rows remain for audit. The dashboard can replay from a delivery row too. ## Rotate the secret [#rotate-the-secret] `POST /webhook_endpoints/{id}/rotate` returns a new secret once and keeps signing with the old one too for an overlap window (24 hours by default), so you can deploy the new secret without dropping events. After a leak, pass `{ "immediate": true }` to retire the old secret at once. `DELETE /webhook_endpoints/{id}/previous_secret` ends an overlap early. # List checkout sessions (/docs/api/checkout-sessions/list-checkout-sessions) ## List checkout sessions `GET https://runepay.co/api/v1/checkout_sessions` Scope: `checkout_sessions:read` | Parameter | In | Type | Description | | --- | --- | --- | --- | | `limit` | query | integer | Page size, 1 to 100. | | `starting_after` | query | string | An object id from the previous page; the page starts after it. | | `expand[]` | query | string | | | `status` | query | string (`open`, `complete`, `expired`) | | | `payment_link` | query | string | | | `customer` | query | string | | | `client_reference_id` | query | string | | | `created[gte]` | query | string | | | `created[lte]` | query | string | | Response `200`: ```json { "data": [ { "id": "cs_01KA4XZY8T2R5M7P1Q4W6E8R0T", "object": "checkout_session", "livemode": false, "status": "open", "payment_status": "unpaid", "amount_subtotal": 1999, "amount_tax": 0, "amount_total": 1999, "currency": "USD", "tax_behavior": "exclusive", "line_items": { "object": "list", "url": "/api/v1/checkout_sessions/cs_01KA4XZY8T2R5M7P1Q4W6E8R0T/line_items", "data": [ { "id": "li_01KA4XZY8T2R5M7P1Q4W6E8R0T", "object": "item", "currency": "USD", "quantity": 1, "price_data": { "currency": "USD", "unit_amount": 1999, "product_data": { "name": "Pro plan, 1 month" }, "tax_code": "saas", "tax_behavior": "exclusive" }, "amount_subtotal": 1999, "amount_tax": 0, "amount_total": 1999 } ], "has_more": false }, "description": "Pro plan, 1 month", "customer_email": null, "customer": null, "client_reference_id": "order_1042", "payment": null, "payment_link": null, "success_url": "https://merchant.example/thanks?session={CHECKOUT_SESSION_ID}", "cancel_url": null, "metadata": { "order_id": "1042" }, "locale": "auto", "url": "https://runepay.co/pay/cs_01KA4XZY8T2R5M7P1Q4W6E8R0T", "expires_at": 1767312000, "expired_at": null, "created": 1767225600 } ], "has_more": false } ``` Errors: 400, 401, 403, 500, 503, with the [error shape](/docs/api/errors). # Create a checkout session (/docs/api/checkout-sessions/create-checkout-session) ## Create a checkout session `POST https://runepay.co/api/v1/checkout_sessions` Returns a hosted checkout URL for 1–100 inline line items in one currency. Tax is zero with the none calculator; a tax provider must be selected before live launch. Scope: `checkout_sessions:write` | Parameter | In | Type | Description | | --- | --- | --- | --- | | `expand[]` | query | string | | | `Idempotency-Key` | header | string | Makes a retry safe: the same key and body within 24 hours does not repeat the request. | Body: | Field | Type | Description | | --- | --- | --- | | `line_items` (required) | array | | | `customer_email` | string | | | `customer` | string | Reserved for customers. Until the customers resource ships, every id returns 404 not_found. Mutually exclusive with customer_email. | | `client_reference_id` | string | | | `success_url` | string or null | Absolute http(s) URL. {CHECKOUT_SESSION_ID} is replaced at redirect time. | | `cancel_url` | string or null | Absolute http(s) cancel URL. | | `expires_at` | integer | 30 minutes to 24 hours from now; defaults to 24 hours. | | `metadata` | object | | | `locale` | string (`auto`, `en`) | Hosted checkout supports English; auto uses English. | Example request body: ```json { "line_items": [ { "price_data": { "currency": "usd", "unit_amount": 1999, "product_data": { "name": "Pro plan, 1 month" }, "tax_code": "saas" }, "quantity": 1 } ], "client_reference_id": "order_1042", "success_url": "https://merchant.example/thanks?session={CHECKOUT_SESSION_ID}", "metadata": { "order_id": "1042" } } ``` Response `201`: ```json { "id": "cs_01KA4XZY8T2R5M7P1Q4W6E8R0T", "object": "checkout_session", "livemode": false, "status": "open", "payment_status": "unpaid", "amount_subtotal": 1999, "amount_tax": 0, "amount_total": 1999, "currency": "USD", "tax_behavior": "exclusive", "line_items": { "object": "list", "url": "/api/v1/checkout_sessions/cs_01KA4XZY8T2R5M7P1Q4W6E8R0T/line_items", "data": [ { "id": "li_01KA4XZY8T2R5M7P1Q4W6E8R0T", "object": "item", "currency": "USD", "quantity": 1, "price_data": { "currency": "USD", "unit_amount": 1999, "product_data": { "name": "Pro plan, 1 month" }, "tax_code": "saas", "tax_behavior": "exclusive" }, "amount_subtotal": 1999, "amount_tax": 0, "amount_total": 1999 } ], "has_more": false }, "description": "Pro plan, 1 month", "customer_email": null, "customer": null, "client_reference_id": "order_1042", "payment": null, "payment_link": null, "success_url": "https://merchant.example/thanks?session={CHECKOUT_SESSION_ID}", "cancel_url": null, "metadata": { "order_id": "1042" }, "locale": "auto", "url": "https://runepay.co/pay/cs_01KA4XZY8T2R5M7P1Q4W6E8R0T", "expires_at": 1767312000, "expired_at": null, "created": 1767225600 } ``` Errors: 400, 401, 403, 404, 409, 413, 422, 500, 503, with the [error shape](/docs/api/errors). # Retrieve a checkout session (/docs/api/checkout-sessions/retrieve-checkout-session) ## Retrieve a checkout session `GET https://runepay.co/api/v1/checkout_sessions/{id}` Scope: `checkout_sessions:read` | Parameter | In | Type | Description | | --- | --- | --- | --- | | `id` (required) | path | string | The object id. | | `expand[]` | query | string | | Response `200`: ```json { "id": "cs_01KA4XZY8T2R5M7P1Q4W6E8R0T", "object": "checkout_session", "livemode": false, "status": "open", "payment_status": "unpaid", "amount_subtotal": 1999, "amount_tax": 0, "amount_total": 1999, "currency": "USD", "tax_behavior": "exclusive", "line_items": { "object": "list", "url": "/api/v1/checkout_sessions/cs_01KA4XZY8T2R5M7P1Q4W6E8R0T/line_items", "data": [ { "id": "li_01KA4XZY8T2R5M7P1Q4W6E8R0T", "object": "item", "currency": "USD", "quantity": 1, "price_data": { "currency": "USD", "unit_amount": 1999, "product_data": { "name": "Pro plan, 1 month" }, "tax_code": "saas", "tax_behavior": "exclusive" }, "amount_subtotal": 1999, "amount_tax": 0, "amount_total": 1999 } ], "has_more": false }, "description": "Pro plan, 1 month", "customer_email": null, "customer": null, "client_reference_id": "order_1042", "payment": null, "payment_link": null, "success_url": "https://merchant.example/thanks?session={CHECKOUT_SESSION_ID}", "cancel_url": null, "metadata": { "order_id": "1042" }, "locale": "auto", "url": "https://runepay.co/pay/cs_01KA4XZY8T2R5M7P1Q4W6E8R0T", "expires_at": 1767312000, "expired_at": null, "created": 1767225600 } ``` Errors: 400, 401, 403, 404, 500, 503, with the [error shape](/docs/api/errors). # List a session's line items (/docs/api/checkout-sessions/list-checkout-session-line-items) ## List a session's line items `GET https://runepay.co/api/v1/checkout_sessions/{id}/line_items` Scope: `checkout_sessions:read` | Parameter | In | Type | Description | | --- | --- | --- | --- | | `id` (required) | path | string | The object id. | | `limit` | query | integer | Page size, 1 to 100. | | `starting_after` | query | string | An object id from the previous page; the page starts after it. | Response `200`: ```json { "object": "list", "url": "/api/v1/checkout_sessions/cs_01KA4XZY8T2R5M7P1Q4W6E8R0T/line_items", "data": [ { "id": "li_01KA4XZY8T2R5M7P1Q4W6E8R0T", "object": "item", "currency": "USD", "quantity": 1, "price_data": { "currency": "USD", "unit_amount": 1999, "product_data": { "name": "Pro plan, 1 month" }, "tax_code": "saas", "tax_behavior": "exclusive" }, "amount_subtotal": 1999, "amount_tax": 0, "amount_total": 1999 } ], "has_more": false } ``` Errors: 400, 401, 403, 404, 500, 503, with the [error shape](/docs/api/errors). # Expire an open checkout session (/docs/api/checkout-sessions/expire-checkout-session) ## Expire an open checkout session `POST https://runepay.co/api/v1/checkout_sessions/{id}/expire` Refuses complete sessions and pending payments. Already expired sessions return unchanged. Scope: `checkout_sessions:write` | Parameter | In | Type | Description | | --- | --- | --- | --- | | `id` (required) | path | string | The object id. | | `Idempotency-Key` | header | string | Makes a retry safe: the same key and body within 24 hours does not repeat the request. | Body: | Field | Type | Description | | --- | --- | --- | Example request body: ```json {} ``` Response `200`: ```json { "id": "cs_01KA4XZY8T2R5M7P1Q4W6E8R0T", "object": "checkout_session", "livemode": false, "status": "expired", "payment_status": "unpaid", "amount_subtotal": 1999, "amount_tax": 0, "amount_total": 1999, "currency": "USD", "tax_behavior": "exclusive", "line_items": { "object": "list", "url": "/api/v1/checkout_sessions/cs_01KA4XZY8T2R5M7P1Q4W6E8R0T/line_items", "data": [ { "id": "li_01KA4XZY8T2R5M7P1Q4W6E8R0T", "object": "item", "currency": "USD", "quantity": 1, "price_data": { "currency": "USD", "unit_amount": 1999, "product_data": { "name": "Pro plan, 1 month" }, "tax_code": "saas", "tax_behavior": "exclusive" }, "amount_subtotal": 1999, "amount_tax": 0, "amount_total": 1999 } ], "has_more": false }, "description": "Pro plan, 1 month", "customer_email": null, "customer": null, "client_reference_id": "order_1042", "payment": null, "payment_link": null, "success_url": "https://merchant.example/thanks?session={CHECKOUT_SESSION_ID}", "cancel_url": null, "metadata": { "order_id": "1042" }, "locale": "auto", "url": "https://runepay.co/pay/cs_01KA4XZY8T2R5M7P1Q4W6E8R0T", "expires_at": 1767312000, "expired_at": 1767227400, "created": 1767225600 } ``` Errors: 400, 401, 403, 404, 409, 413, 422, 500, 503, with the [error shape](/docs/api/errors). # List payments (/docs/api/payments/list-payments) ## List payments `GET https://runepay.co/api/v1/payments` Newest first. Scope: `payments:read` | Parameter | In | Type | Description | | --- | --- | --- | --- | | `limit` | query | integer | Page size, 1 to 100. | | `starting_after` | query | string | An object id from the previous page; the page starts after it. | | `status` | query | string (`created`, `pending`, `succeeded`, `failed`, `canceled`, `partially_refunded`, `refunded`, `disputed`, `charged_back`) | | | `created[gte]` | query | string | Created at or after, unix seconds. | | `created[lte]` | query | string | Created at or before, unix seconds (the whole second counts). | Response `200`: ```json { "data": [ { "id": "pay_01KA4Y0Z9V3T6N8Q2W5E7R1T3Y", "object": "payment", "livemode": false, "status": "succeeded", "amount": 1999, "amount_refunded": 0, "amount_tax": 0, "customer": null, "currency": "USD", "fee": 88, "description": "Pro plan, 1 month", "customer_email": "buyer@example.com", "metadata": { "order_id": "1042" }, "checkout_session": "cs_01KA4XZY8T2R5M7P1Q4W6E8R0T", "card": { "brand": "visa", "last4": "4242" }, "decline_code": null, "decline_message": null, "outcome": { "risk_level": "normal", "risk_score": 12 }, "available_on": 1767830400, "created": 1767225600 } ], "has_more": false } ``` Errors: 400, 401, 403, 500, 503, with the [error shape](/docs/api/errors). # Retrieve a payment (/docs/api/payments/retrieve-payment) ## Retrieve a payment `GET https://runepay.co/api/v1/payments/{id}` Scope: `payments:read` | Parameter | In | Type | Description | | --- | --- | --- | --- | | `id` (required) | path | string | The object id. | Response `200`: ```json { "id": "pay_01KA4Y0Z9V3T6N8Q2W5E7R1T3Y", "object": "payment", "livemode": false, "status": "succeeded", "amount": 1999, "amount_refunded": 0, "amount_tax": 0, "customer": null, "currency": "USD", "fee": 88, "description": "Pro plan, 1 month", "customer_email": "buyer@example.com", "metadata": { "order_id": "1042" }, "checkout_session": "cs_01KA4XZY8T2R5M7P1Q4W6E8R0T", "card": { "brand": "visa", "last4": "4242" }, "decline_code": null, "decline_message": null, "outcome": { "risk_level": "normal", "risk_score": 12 }, "available_on": 1767830400, "created": 1767225600 } ``` Errors: 400, 401, 403, 404, 500, 503, with the [error shape](/docs/api/errors). # Refund a payment (/docs/api/refunds/create-refund) ## Refund a payment `POST https://runepay.co/api/v1/refunds` Omit `amount` for a full refund of what is left. Scope: `refunds:write` | Parameter | In | Type | Description | | --- | --- | --- | --- | | `Idempotency-Key` | header | string | Makes a retry safe: the same key and body within 24 hours does not repeat the request. | Body: | Field | Type | Description | | --- | --- | --- | | `payment` (required) | string | The payment to refund. | | `amount` | integer | Amount in minor units. Defaults to the whole refundable amount. | | `reason` | string or null | Your reason, kept on the refund. | Example request body: ```json { "payment": "pay_01KA4Y0Z9V3T6N8Q2W5E7R1T3Y", "amount": 500, "reason": "requested_by_customer" } ``` Response `201`: ```json { "id": "re_01KA5B2C4D6E8F0G2H4J6K8M0N", "object": "refund", "livemode": false, "payment": "pay_01KA4Y0Z9V3T6N8Q2W5E7R1T3Y", "amount": 500, "currency": "USD", "status": "succeeded", "reason": "requested_by_customer", "failure_reason": null, "created": 1767312000 } ``` Errors: 400, 401, 403, 404, 409, 413, 422, 500, 503, with the [error shape](/docs/api/errors). # List disputes (/docs/api/disputes/list-disputes) ## List disputes `GET https://runepay.co/api/v1/disputes` Newest first. Scope: `disputes:read` | Parameter | In | Type | Description | | --- | --- | --- | --- | | `limit` | query | integer | Page size, 1 to 100. | | `starting_after` | query | string | An object id from the previous page; the page starts after it. | | `payment` | query | string | Only disputes on this payment. | Response `200`: ```json { "data": [ { "id": "dp_01KA6C3D5E7F9G1H3J5K7M9N1P", "object": "dispute", "livemode": false, "payment": "pay_01KA4Y0Z9V3T6N8Q2W5E7R1T3Y", "amount": 1999, "currency": "USD", "status": "needs_response", "reason": "fraudulent", "financial_effect": "chargeback", "chargeback_fee": 1500, "evidence_due_by": 1768435200, "closed_at": null, "created": 1767398400 } ], "has_more": false } ``` Errors: 400, 401, 403, 500, 503, with the [error shape](/docs/api/errors). # Retrieve a dispute (/docs/api/disputes/retrieve-dispute) ## Retrieve a dispute `GET https://runepay.co/api/v1/disputes/{id}` Scope: `disputes:read` | Parameter | In | Type | Description | | --- | --- | --- | --- | | `id` (required) | path | string | The object id. | Response `200`: ```json { "id": "dp_01KA6C3D5E7F9G1H3J5K7M9N1P", "object": "dispute", "livemode": false, "payment": "pay_01KA4Y0Z9V3T6N8Q2W5E7R1T3Y", "amount": 1999, "currency": "USD", "status": "needs_response", "reason": "fraudulent", "financial_effect": "chargeback", "chargeback_fee": 1500, "evidence_due_by": 1768435200, "closed_at": null, "created": 1767398400 } ``` Errors: 400, 401, 403, 404, 500, 503, with the [error shape](/docs/api/errors). # List payment links (/docs/api/payment-links/list-payment-links) ## List payment links `GET https://runepay.co/api/v1/payment_links` Newest first. Scope: `payment_links:read` | Parameter | In | Type | Description | | --- | --- | --- | --- | | `limit` | query | integer | Page size, 1 to 100. | | `starting_after` | query | string | An object id from the previous page; the page starts after it. | | `active` | query | string (`true`, `false`) | Only active or only inactive links. | Response `200`: ```json { "object": "list", "data": [ { "id": "plink_01KA7D4E6F8G0H2J4K6M8N0P2Q", "object": "payment_link", "livemode": false, "active": true, "name": "Pro plan", "description": "One month of Pro", "amount": 1999, "min_amount": null, "max_amount": null, "currency": "USD", "success_url": "https://merchant.example/thanks", "metadata": { "plan": "pro" }, "url": "https://runepay.co/pay/l/plink_01KA7D4E6F8G0H2J4K6M8N0P2Q", "created": 1767225600, "updated": 1767225600 } ], "has_more": false } ``` Errors: 400, 401, 403, 500, 503, with the [error shape](/docs/api/errors). # Create a payment link (/docs/api/payment-links/create-payment-link) ## Create a payment link `POST https://runepay.co/api/v1/payment_links` A reusable checkout URL. Pass `amount`, or omit it and pass `min_amount` and `max_amount` to let the buyer choose. Scope: `payment_links:write` | Parameter | In | Type | Description | | --- | --- | --- | --- | | `Idempotency-Key` | header | string | Makes a retry safe: the same key and body within 24 hours does not repeat the request. | Body: | Field | Type | Description | | --- | --- | --- | | `name` (required) | string | Shown to the buyer. | | `description` | string or null | Shown to the buyer. | | `amount` | integer or null | Fixed amount in minor units. | | `min_amount` | integer or null | Lowest amount the buyer may choose, in minor units. | | `max_amount` | integer or null | Highest amount the buyer may choose, in minor units. | | `currency` | string or null | ISO 4217 code, any case. Defaults to the account's currency. | | `success_url` | string or null | Where the buyer goes after paying. Absolute http(s) URL. | | `metadata` | | Key-value strings stored on the object. Values that are not strings are ignored. | Example request body: ```json { "name": "Pro plan", "description": "One month of Pro", "amount": 1999, "success_url": "https://merchant.example/thanks", "metadata": { "plan": "pro" } } ``` Response `201`: ```json { "id": "plink_01KA7D4E6F8G0H2J4K6M8N0P2Q", "object": "payment_link", "livemode": false, "active": true, "name": "Pro plan", "description": "One month of Pro", "amount": 1999, "min_amount": null, "max_amount": null, "currency": "USD", "success_url": "https://merchant.example/thanks", "metadata": { "plan": "pro" }, "url": "https://runepay.co/pay/l/plink_01KA7D4E6F8G0H2J4K6M8N0P2Q", "created": 1767225600, "updated": 1767225600 } ``` Errors: 400, 401, 403, 409, 413, 422, 500, 503, with the [error shape](/docs/api/errors). # Retrieve a payment link (/docs/api/payment-links/retrieve-payment-link) ## Retrieve a payment link `GET https://runepay.co/api/v1/payment_links/{id}` Scope: `payment_links:read` | Parameter | In | Type | Description | | --- | --- | --- | --- | | `id` (required) | path | string | The object id. | Response `200`: ```json { "id": "plink_01KA7D4E6F8G0H2J4K6M8N0P2Q", "object": "payment_link", "livemode": false, "active": true, "name": "Pro plan", "description": "One month of Pro", "amount": 1999, "min_amount": null, "max_amount": null, "currency": "USD", "success_url": "https://merchant.example/thanks", "metadata": { "plan": "pro" }, "url": "https://runepay.co/pay/l/plink_01KA7D4E6F8G0H2J4K6M8N0P2Q", "created": 1767225600, "updated": 1767225600 } ``` Errors: 400, 401, 403, 404, 500, 503, with the [error shape](/docs/api/errors). # Update a payment link (/docs/api/payment-links/update-payment-link) ## Update a payment link `POST https://runepay.co/api/v1/payment_links/{id}` Changes `active`, `name` or `description`. Omitted fields keep their value. Scope: `payment_links:write` | Parameter | In | Type | Description | | --- | --- | --- | --- | | `id` (required) | path | string | The object id. | | `Idempotency-Key` | header | string | Makes a retry safe: the same key and body within 24 hours does not repeat the request. | Body: | Field | Type | Description | | --- | --- | --- | | `active` | boolean | | | `name` | string | | | `description` | string or null | null clears it. | Example request body: ```json { "active": false } ``` Response `200`: ```json { "id": "plink_01KA7D4E6F8G0H2J4K6M8N0P2Q", "object": "payment_link", "livemode": false, "active": false, "name": "Pro plan", "description": "One month of Pro", "amount": 1999, "min_amount": null, "max_amount": null, "currency": "USD", "success_url": "https://merchant.example/thanks", "metadata": { "plan": "pro" }, "url": "https://runepay.co/pay/l/plink_01KA7D4E6F8G0H2J4K6M8N0P2Q", "created": 1767225600, "updated": 1767312000 } ``` Errors: 400, 401, 403, 404, 409, 413, 422, 500, 503, with the [error shape](/docs/api/errors). # Retrieve the balance (/docs/api/balance/retrieve-balance) ## Retrieve the balance `GET https://runepay.co/api/v1/balance` Scope: `balance:read` | Parameter | In | Type | Description | | --- | --- | --- | --- | | `currency` | query | string | ISO 4217 code, any case. | Response `200`: ```json { "object": "balance", "livemode": false, "currency": "USD", "pending": 18990, "available": 10200, "reserve": 1200 } ``` Errors: 400, 401, 403, 500, 503, with the [error shape](/docs/api/errors). # List payouts (/docs/api/payouts/list-payouts) ## List payouts `GET https://runepay.co/api/v1/payouts` This merchant's payout lines from approval on, newest first. Scope: `payouts:read` | Parameter | In | Type | Description | | --- | --- | --- | --- | | `limit` | query | integer | Page size, 1 to 100. | | `starting_after` | query | string | An object id from the previous page; the page starts after it. | Response `200`: ```json { "data": [ { "id": "8d0c7a52-3f3e-4c1b-9a77-0c5b8f1e2d34", "object": "payout", "livemode": false, "amount": 10200, "currency": "USD", "status": "paid", "rail": "fiat_ach", "bank_reference": "ACH-20260107-0042", "tx_hash": null, "paid_at": 1767830400, "created": 1767744000 } ], "has_more": false } ``` Errors: 400, 401, 403, 500, 503, with the [error shape](/docs/api/errors). # Retrieve a payout (/docs/api/payouts/retrieve-payout) ## Retrieve a payout `GET https://runepay.co/api/v1/payouts/{id}` Scope: `payouts:read` | Parameter | In | Type | Description | | --- | --- | --- | --- | | `id` (required) | path | string | The object id. | Response `200`: ```json { "id": "8d0c7a52-3f3e-4c1b-9a77-0c5b8f1e2d34", "object": "payout", "livemode": false, "amount": 10200, "currency": "USD", "status": "paid", "rail": "fiat_ach", "bank_reference": "ACH-20260107-0042", "tx_hash": null, "paid_at": 1767830400, "created": 1767744000 } ``` Errors: 400, 401, 403, 404, 500, 503, with the [error shape](/docs/api/errors). # List events (/docs/api/events/list-events) ## List events `GET https://runepay.co/api/v1/events` Newest first. Only events from the last 30 days are listable. Filter by exact type or a prefix such as payment.*. Scope: `events:read` | Parameter | In | Type | Description | | --- | --- | --- | --- | | `limit` | query | integer | Page size, 1 to 100. | | `starting_after` | query | string | An object id from the previous page; the page starts after it. | | `type` | query | string | | | `created[gte]` | query | string | Created at or after, unix seconds. | | `created[lte]` | query | string | Created at or before, unix seconds. | Response `200`: ```json { "data": [ { "id": "evt_01KA8E5F7G9H1J3K5M7N9P1Q3R", "object": "event", "type": "payment.succeeded", "api_version": "2026-12-15", "livemode": false, "created": 1767225600, "data": { "object": { "id": "pay_01KA4Y0Z9V3T6N8Q2W5E7R1T3Y", "object": "payment", "livemode": false, "status": "succeeded", "amount": 1999, "amount_refunded": 0, "amount_tax": 0, "customer": null, "currency": "USD", "fee": 88, "description": "Pro plan, 1 month", "customer_email": "buyer@example.com", "metadata": { "order_id": "1042" }, "checkout_session": "cs_01KA4XZY8T2R5M7P1Q4W6E8R0T", "card": { "brand": "visa", "last4": "4242" }, "decline_code": null, "decline_message": null, "outcome": { "risk_level": "normal", "risk_score": 12 }, "available_on": 1767830400, "created": 1767225600 } }, "request": null } ], "has_more": false } ``` Errors: 400, 401, 403, 500, 503, with the [error shape](/docs/api/errors). # Retrieve an event (/docs/api/events/retrieve-event) ## Retrieve an event `GET https://runepay.co/api/v1/events/{id}` Returns the original snapshot for an event from the last 30 days. Scope: `events:read` | Parameter | In | Type | Description | | --- | --- | --- | --- | | `id` (required) | path | string | The object id. | Response `200`: ```json { "id": "evt_01KA8E5F7G9H1J3K5M7N9P1Q3R", "object": "event", "type": "payment.succeeded", "api_version": "2026-12-15", "livemode": false, "created": 1767225600, "data": { "object": { "id": "pay_01KA4Y0Z9V3T6N8Q2W5E7R1T3Y", "object": "payment", "livemode": false, "status": "succeeded", "amount": 1999, "amount_refunded": 0, "amount_tax": 0, "customer": null, "currency": "USD", "fee": 88, "description": "Pro plan, 1 month", "customer_email": "buyer@example.com", "metadata": { "order_id": "1042" }, "checkout_session": "cs_01KA4XZY8T2R5M7P1Q4W6E8R0T", "card": { "brand": "visa", "last4": "4242" }, "decline_code": null, "decline_message": null, "outcome": { "risk_level": "normal", "risk_score": 12 }, "available_on": 1767830400, "created": 1767225600 } }, "request": null } ``` Errors: 400, 401, 403, 404, 500, 503, with the [error shape](/docs/api/errors). # List webhook endpoints (/docs/api/webhook-endpoints/list-webhook-endpoints) ## List webhook endpoints `GET https://runepay.co/api/v1/webhook_endpoints` Newest first. Scope: `webhook_endpoints:read` | Parameter | In | Type | Description | | --- | --- | --- | --- | | `limit` | query | integer | Page size, 1 to 100. | | `starting_after` | query | string | An object id from the previous page; the page starts after it. | Response `200`: ```json { "data": [ { "id": "we_01KA9F6G8H0J2K4M6N8P0Q2R4S", "object": "webhook_endpoint", "url": "https://merchant.example/hooks", "livemode": false, "enabled_events": [ "*" ], "status": "enabled", "api_version": "2026-12-15", "description": null, "metadata": {}, "created": 1767225600 } ], "has_more": false } ``` Errors: 400, 401, 403, 500, 503, with the [error shape](/docs/api/errors). # Create a webhook endpoint (/docs/api/webhook-endpoints/create-webhook-endpoint) ## Create a webhook endpoint `POST https://runepay.co/api/v1/webhook_endpoints` Returns the signing `secret` once. A retry with the same Idempotency-Key gets `409 secret_not_replayable` with the endpoint id instead of the secret. Scope: `webhook_endpoints:write` | Parameter | In | Type | Description | | --- | --- | --- | --- | | `Idempotency-Key` | header | string | Makes a retry safe: the same key and body within 24 hours does not repeat the request. | Body: | Field | Type | Description | | --- | --- | --- | | `api_version` | string | Event envelope version. Defaults to 2026-12-15. | | `description` | string or null | | | `metadata` | object | Your own key-value strings, returned as sent. | | `url` (required) | string | A public HTTPS URL. | | `enabled_events` (required) | array | Event types to deliver, or `["*"]` for all. | Example request body: ```json { "url": "https://merchant.example/hooks", "enabled_events": [ "*" ] } ``` Response `201`: ```json { "id": "we_01KA9F6G8H0J2K4M6N8P0Q2R4S", "object": "webhook_endpoint", "url": "https://merchant.example/hooks", "livemode": false, "enabled_events": [ "*" ], "status": "enabled", "api_version": "2026-12-15", "description": null, "metadata": {}, "created": 1767225600, "secret": "whsec_9fK2mQ7xR4tV1wY8zA3bC6dE0gH5jL" } ``` Errors: 400, 401, 403, 409, 413, 422, 500, 503, with the [error shape](/docs/api/errors). # Retrieve a webhook endpoint (/docs/api/webhook-endpoints/retrieve-webhook-endpoint) ## Retrieve a webhook endpoint `GET https://runepay.co/api/v1/webhook_endpoints/{id}` Never returns the signing secret. Scope: `webhook_endpoints:read` | Parameter | In | Type | Description | | --- | --- | --- | --- | | `id` (required) | path | string | The object id. | Response `200`: ```json { "id": "we_01KA9F6G8H0J2K4M6N8P0Q2R4S", "object": "webhook_endpoint", "url": "https://merchant.example/hooks", "livemode": false, "enabled_events": [ "*" ], "status": "enabled", "api_version": "2026-12-15", "description": null, "metadata": {}, "created": 1767225600 } ``` Errors: 400, 401, 403, 404, 500, 503, with the [error shape](/docs/api/errors). # Update a webhook endpoint (/docs/api/webhook-endpoints/update-webhook-endpoint) ## Update a webhook endpoint `PATCH https://runepay.co/api/v1/webhook_endpoints/{id}` Disabling fails pending deliveries; enabling does not resend them. Scope: `webhook_endpoints:write` | Parameter | In | Type | Description | | --- | --- | --- | --- | | `id` (required) | path | string | The object id. | | `Idempotency-Key` | header | string | Makes a retry safe: the same key and body within 24 hours does not repeat the request. | Body: | Field | Type | Description | | --- | --- | --- | | `api_version` | string | Event envelope version. Defaults to 2026-12-15. | | `description` | string or null | | | `metadata` | object | Your own key-value strings, returned as sent. | | `url` | string | A public HTTPS URL. | | `enabled_events` | array | | | `status` | string (`enabled`, `disabled`) | | Example request body: ```json { "status": "disabled" } ``` Response `200`: ```json { "id": "we_01KA9F6G8H0J2K4M6N8P0Q2R4S", "object": "webhook_endpoint", "url": "https://merchant.example/hooks", "livemode": false, "enabled_events": [ "*" ], "status": "disabled", "api_version": "2026-12-15", "description": null, "metadata": {}, "created": 1767225600 } ``` Errors: 400, 401, 403, 404, 409, 413, 422, 500, 503, with the [error shape](/docs/api/errors). # Delete a webhook endpoint (/docs/api/webhook-endpoints/delete-webhook-endpoint) ## Delete a webhook endpoint `DELETE https://runepay.co/api/v1/webhook_endpoints/{id}` Soft-deletes the endpoint, hides it from reads and stops pending and future deliveries. Scope: `webhook_endpoints:write` | Parameter | In | Type | Description | | --- | --- | --- | --- | | `id` (required) | path | string | The object id. | | `Idempotency-Key` | header | string | Makes a retry safe: the same key and body within 24 hours does not repeat the request. | Response `200`: ```json { "id": "we_01KA9F6G8H0J2K4M6N8P0Q2R4S", "object": "webhook_endpoint", "deleted": true } ``` Errors: 400, 401, 403, 404, 409, 413, 422, 500, 503, with the [error shape](/docs/api/errors). # List an endpoint's deliveries (/docs/api/webhook-endpoints/list-webhook-deliveries) ## List an endpoint's deliveries `GET https://runepay.co/api/v1/webhook_endpoints/{id}/deliveries` Most recently queued or replayed first. Scope: `webhook_endpoints:read` | Parameter | In | Type | Description | | --- | --- | --- | --- | | `id` (required) | path | string | The object id. | | `limit` | query | integer | Page size, 1 to 100. | | `starting_after` | query | string | An object id from the previous page; the page starts after it. | Response `200`: ```json { "data": [ { "id": "0f9e8d7c-6b5a-4c3d-8e2f-1a0b9c8d7e6f", "event_id": "evt_01KA8E5F7G9H1J3K5M7N9P1Q3R", "status": "succeeded", "attempts": 1, "last_response_status": 200, "last_error": null, "created": 1767225600, "delivered_at": 1767225601 } ], "has_more": false } ``` Errors: 400, 401, 403, 404, 500, 503, with the [error shape](/docs/api/errors). # Retire the previous signing secret (/docs/api/webhook-endpoints/delete-webhook-endpoint-previous-secret) ## Retire the previous signing secret `DELETE https://runepay.co/api/v1/webhook_endpoints/{id}/previous_secret` Ends a rotation overlap now. Deliveries are then signed with the current secret only. Scope: `webhook_endpoints:write` | Parameter | In | Type | Description | | --- | --- | --- | --- | | `id` (required) | path | string | The object id. | Response `200`: ```json { "id": "we_01KA9F6G8H0J2K4M6N8P0Q2R4S", "object": "webhook_endpoint", "url": "https://merchant.example/hooks", "livemode": false, "enabled_events": [ "*" ], "status": "enabled", "api_version": "2026-12-15", "description": null, "metadata": {}, "created": 1767225600 } ``` Errors: 400, 401, 403, 404, 413, 500, 503, with the [error shape](/docs/api/errors). # Replay an event to an endpoint (/docs/api/webhook-endpoints/replay-webhook-event) ## Replay an event to an endpoint `POST https://runepay.co/api/v1/webhook_endpoints/{id}/replay` Queues the event for the enabled endpoint and resets its delivery attempts and retry window. Scope: `webhook_endpoints:write` | Parameter | In | Type | Description | | --- | --- | --- | --- | | `id` (required) | path | string | The object id. | | `Idempotency-Key` | header | string | Makes a retry safe: the same key and body within 24 hours does not repeat the request. | Body: | Field | Type | Description | | --- | --- | --- | | `event_id` (required) | string | The event to deliver again. | Example request body: ```json { "event_id": "evt_01KA8E5F7G9H1J3K5M7N9P1Q3R" } ``` Response `200`: ```json { "id": "0f9e8d7c-6b5a-4c3d-8e2f-1a0b9c8d7e6f", "event_id": "evt_01KA8E5F7G9H1J3K5M7N9P1Q3R", "status": "pending" } ``` Errors: 400, 401, 403, 404, 409, 413, 422, 500, 503, with the [error shape](/docs/api/errors). # Rotate the signing secret (/docs/api/webhook-endpoints/rotate-webhook-endpoint-secret) ## Rotate the signing secret `POST https://runepay.co/api/v1/webhook_endpoints/{id}/rotate` Returns the new secret once. Deliveries are signed with both secrets during the overlap unless `immediate` is true. A retry with the same Idempotency-Key gets `409 secret_not_replayable`; rotate again for a new secret. Scope: `webhook_endpoints:write` | Parameter | In | Type | Description | | --- | --- | --- | --- | | `id` (required) | path | string | The object id. | | `Idempotency-Key` | header | string | Makes a retry safe: the same key and body within 24 hours does not repeat the request. | Body: | Field | Type | Description | | --- | --- | --- | | `immediate` | boolean | Retire the current and any previous secret now, e.g. after a leak. | Example request body: ```json { "immediate": false } ``` Response `200`: ```json { "id": "we_01KA9F6G8H0J2K4M6N8P0Q2R4S", "object": "webhook_endpoint", "url": "https://merchant.example/hooks", "livemode": false, "enabled_events": [ "*" ], "status": "enabled", "api_version": "2026-12-15", "description": null, "metadata": {}, "created": 1767225600, "secret": "whsec_9fK2mQ7xR4tV1wY8zA3bC6dE0gH5jL" } ``` Errors: 400, 401, 403, 404, 409, 413, 422, 500, 503, with the [error shape](/docs/api/errors). # checkout.session.completed (/docs/api/webhooks/checkout-session-completed) ## Webhook `checkout.session.completed` Sent to your endpoint, signed with `RunePay-Signature`. The full object is snapshotted at emit time. Payloads are described in the [event reference](/docs/webhooks/events). # checkout.session.expired (/docs/api/webhooks/checkout-session-expired) ## Webhook `checkout.session.expired` Sent to your endpoint, signed with `RunePay-Signature`. The full object is snapshotted at emit time. Payloads are described in the [event reference](/docs/webhooks/events). # payment.succeeded (/docs/api/webhooks/payment-succeeded) ## Webhook `payment.succeeded` Sent to your endpoint, signed with `RunePay-Signature`. The full object is snapshotted at emit time. Payloads are described in the [event reference](/docs/webhooks/events). # payment.failed (/docs/api/webhooks/payment-failed) ## Webhook `payment.failed` Sent to your endpoint, signed with `RunePay-Signature`. The full object is snapshotted at emit time. Payloads are described in the [event reference](/docs/webhooks/events). # payment.refunded (/docs/api/webhooks/payment-refunded) ## Webhook `payment.refunded` Sent to your endpoint, signed with `RunePay-Signature`. The full object is snapshotted at emit time. Payloads are described in the [event reference](/docs/webhooks/events). # refund.created (/docs/api/webhooks/refund-created) ## Webhook `refund.created` Sent to your endpoint, signed with `RunePay-Signature`. The full object is snapshotted at emit time. Payloads are described in the [event reference](/docs/webhooks/events). # refund.succeeded (/docs/api/webhooks/refund-succeeded) ## Webhook `refund.succeeded` Sent to your endpoint, signed with `RunePay-Signature`. The full object is snapshotted at emit time. Payloads are described in the [event reference](/docs/webhooks/events). # refund.failed (/docs/api/webhooks/refund-failed) ## Webhook `refund.failed` Sent to your endpoint, signed with `RunePay-Signature`. The full object is snapshotted at emit time. Payloads are described in the [event reference](/docs/webhooks/events). # dispute.created (/docs/api/webhooks/dispute-created) ## Webhook `dispute.created` Sent to your endpoint, signed with `RunePay-Signature`. The full object is snapshotted at emit time. Payloads are described in the [event reference](/docs/webhooks/events). # dispute.updated (/docs/api/webhooks/dispute-updated) ## Webhook `dispute.updated` Sent to your endpoint, signed with `RunePay-Signature`. The full object is snapshotted at emit time. Payloads are described in the [event reference](/docs/webhooks/events). # dispute.closed (/docs/api/webhooks/dispute-closed) ## Webhook `dispute.closed` Sent to your endpoint, signed with `RunePay-Signature`. The full object is snapshotted at emit time. Payloads are described in the [event reference](/docs/webhooks/events). # payout.created (/docs/api/webhooks/payout-created) ## Webhook `payout.created` Sent to your endpoint, signed with `RunePay-Signature`. The full object is snapshotted at emit time. Payloads are described in the [event reference](/docs/webhooks/events). # payout.paid (/docs/api/webhooks/payout-paid) ## Webhook `payout.paid` Sent to your endpoint, signed with `RunePay-Signature`. The full object is snapshotted at emit time. Payloads are described in the [event reference](/docs/webhooks/events). # payout.failed (/docs/api/webhooks/payout-failed) ## Webhook `payout.failed` Sent to your endpoint, signed with `RunePay-Signature`. The full object is snapshotted at emit time. Payloads are described in the [event reference](/docs/webhooks/events). # payment_link.created (/docs/api/webhooks/payment-link-created) ## Webhook `payment_link.created` Sent to your endpoint, signed with `RunePay-Signature`. The full object is snapshotted at emit time. Payloads are described in the [event reference](/docs/webhooks/events). # payment_link.updated (/docs/api/webhooks/payment-link-updated) ## Webhook `payment_link.updated` Sent to your endpoint, signed with `RunePay-Signature`. The full object is snapshotted at emit time. Payloads are described in the [event reference](/docs/webhooks/events).