Return domains

Register the HTTPS origins checkout may send payers back to and the websites allowed to embed the payment form. The same list checks return_url, cancel_url, payment-link redirects and every ancestor origin framing an embedded checkout.

Each MerchantOrg has separate test and live lists. Your API key selects the list: ak_test_… changes test; ak_live_… changes live. Register an origin in both modes if both integrations need it. Each list holds at most 20 entries.

All four endpoints use server-side HMAC signing. Reads need return_domains:read. Adding or removing needs return_domains:write granted explicitly. A legacy key issued without scopes can read but cannot change domains. Domain management does not register a webhook endpoint.

The Return Domain object

idstring
Unique identifier, prefixed rdom_.
objectstring
Always return_domain.
originstring
Canonical HTTPS origin or wildcard origin.
livemodeboolean
true for the live list; false for test.
created_atstring
ISO-8601 creation timestamp.
created_byobject
Actor type: api_key, user, staff or migration. API-key actors include key_id; merchant dashboard users include user_id. Staff identities are omitted.
THE RETURN DOMAIN OBJECT
JSON
1{
2 "id": "rdom_01k8zq1g36yqd6x7c8bn23j9tv",
3 "object": "return_domain",
4 "origin": "https://shop.example.com",
5 "livemode": false,
6 "created_at": "2026-11-11T17:00:00.000Z",
7 "created_by": { "type": "api_key", "key_id": "ak_test_..." }
8}

Was this section helpful?

Existing API keys

A legacy secret key with no explicit scope list keeps its existing checkout access and can read return domains. It does not automatically gain return_domains:write: adding or removing a domain returns 403 INSUFFICIENT_PERMISSIONS. This rule applies in both test and live. The explicit grant matters, rather than the age of the key.

An API key cannot change its own scopes. Scopes are set when a key is issued; renaming it or changing its IP restrictions does not grant new permissions. Rotation preserves its existing scopes.

For automated domain registration, an authorized dashboard user or CX Pay can issue a separate key with return_domains:read and return_domains:write. Keep your existing checkout key in use. If the new key will also create payments, include its required payment scopes; a key with an explicit scope list holds only those permissions. Issue the key in each test or live mode that needs automated domain management.

DOMAIN-MANAGEMENT KEY SCOPES
JSON
1["return_domains:read", "return_domains:write"]

Was this section helpful?

Accepted origins

Both test and live require public HTTPS domain names. Use a registered HTTPS tunnel such as ngrok for local development. HTTP, localhost, loopback and IP addresses are refused in both modes. The edge may return 403 before API validation returns 400.

https://shop.example.comexact origin
Allows paths and query strings on this origin. Register the origin alone; put /thanks?order=123 in the checkout URL.
https://shop.example.com:8443exact origin with port
Matches only this host and port.
https://*.example.comwildcard origin
Matches a.example.com and deeper subdomains, but not example.com. A wildcard cannot name a port.

Letter case and a trailing slash are normalized. Paths, queries, fragments, credentials, backslashes and trailing dots are refused. Wildcards on public or shared suffixes such as *.com and *.github.ioare refused. CX Pay domains (cxpay.net, cxpaygo.com, cxpay.globaland their subdomains) cannot be return domains.

SERVER-SIDE NODE HELPER · USED BELOW
JavaScript
1import crypto from "node:crypto";
2
3// Server only. Set CXPAY_KEY_ID and CXPAY_SECRET in your environment.
4async function request(method, path, value, idempotencyKey) {
5 const body = value === undefined ? "" : JSON.stringify(value);
6 const timestamp = new Date().toISOString();
7 const nonce = crypto.randomUUID();
8 const bodyHash = crypto.createHash("sha256").update(body).digest("hex");
9 const canonical = [method, path, "", timestamp, nonce, bodyHash].join("\n");
10 const signature = crypto.createHmac(
11 "sha256", Buffer.from(process.env.CXPAY_SECRET, "base64")
12 ).update(canonical).digest("base64");
13 const response = await fetch(`https://api.cxpay.net${path}`, {
14 method,
15 headers: {
16 "X-Key-Id": process.env.CXPAY_KEY_ID,
17 "X-Timestamp": timestamp,
18 "X-Nonce": nonce,
19 "X-Body-Hash": bodyHash,
20 "X-Signature": signature,
21 ...(body ? { "Content-Type": "application/json" } : {}),
22 ...(idempotencyKey ? { "Idempotency-Key": idempotencyKey } : {}),
23 },
24 ...(body ? { body } : {}),
25 signal: AbortSignal.timeout(30_000),
26 });
27 const result = await response.json();
28 if (response.status === 202) {
29 throw new Error("Still processing; retry with the same idempotency key.");
30 }
31 if (!response.ok) throw new Error(JSON.stringify(result));
32 return result;
33}

Was this section helpful?

Add a return domain

POST/v1/return-domains

Requires return_domains:write and an Idempotency-Key. Reuse that key and body when retrying. Adding an already registered canonical origin returns its existing entry with 200; it emits no second change event.

A repeated create may return 202 while the first request is still processing. Retry with the same key and body; wait for 200 before using the returned domain.

originstringRequired
HTTPS origin, up to 300 characters. For example, https://shop.example.com.

Errors: 400 INVALID_ALLOWED_DOMAIN_PATTERN with the refusal reason in error.details[]; 400 RETURN_DOMAIN_LIMIT_REACHED at 20 entries; 403 INSUFFICIENT_PERMISSIONS without the write scope. 409 RETURN_DOMAINS_MIGRATION_REQUIRED means CX Pay must finish the account's one-time migration before domains can be changed.

Changes emit return_domain.created to the activity feed and subscribed webhooks, and record the actor in the audit history. Admin email alerts are not sent by this release.

REQUEST · NODE
JavaScript
1const idempotencyKey = crypto.randomUUID();
2const { data: domain } = await request(
3 "POST", "/v1/return-domains",
4 { origin: "https://shop.example.com" }, idempotencyKey
5);
RESPONSE · 200
JSON
1{
2 "data": {
3 "id": "rdom_01k8zq1g36yqd6x7c8bn23j9tv",
4 "object": "return_domain",
5 "origin": "https://shop.example.com",
6 "livemode": false,
7 "created_at": "2026-11-11T17:00:00.000Z",
8 "created_by": { "type": "api_key", "key_id": "ak_test_..." }
9 }
10}

Was this section helpful?

List return domains

GET/v1/return-domains

Returns this key's mode only, oldest first. The entire list fits in one response: has_more is always false and next_cursor is always null. An empty list permits no external return or embed origins.

REQUEST · NODE
JavaScript
1const { data: domains } = await request("GET", "/v1/return-domains");
RESPONSE · 200
JSON
1{
2 "data": [{
3 "id": "rdom_01k8zq1g36yqd6x7c8bn23j9tv",
4 "object": "return_domain",
5 "origin": "https://shop.example.com",
6 "livemode": false,
7 "created_at": "2026-11-11T17:00:00.000Z",
8 "created_by": { "type": "api_key", "key_id": "ak_test_..." }
9 }],
10 "has_more": false,
11 "next_cursor": null
12}

Was this section helpful?

Retrieve a return domain

GET/v1/return-domains/:id

Returns one entry in this mode. An unknown id or an id from the other mode returns 404 RETURN_DOMAIN_NOT_FOUND.

REQUEST · NODE
JavaScript
1const result = await request("GET", `/v1/return-domains/${domain.id}`);
RESPONSE · 200
JSON
1{
2 "data": {
3 "id": "rdom_01k8zq1g36yqd6x7c8bn23j9tv",
4 "object": "return_domain",
5 "origin": "https://shop.example.com",
6 "livemode": false,
7 "created_at": "2026-11-11T17:00:00.000Z",
8 "created_by": { "type": "api_key", "key_id": "ak_test_..." }
9 }
10}

Was this section helpful?

Remove a return domain

DELETE/v1/return-domains/:id

Requires return_domains:write. Returns the removed entry with 200. An Idempotency-Key is not required: a second delete returns 404 RETURN_DOMAIN_NOT_FOUNDand writes nothing. There is no update endpoint; add the replacement origin and remove the old entry.

New checkout URLs and embed initialization use the current list. Existing checkout sessions keep their saved return and cancel URLs until expiry; removing a domain does not cancel those sessions. If necessary, cancel affected open sessions separately.

Payment links still take payments after their saved redirect loses permission; newly created checkouts stay on the hosted status page. Supplying a redirect on link create or update validates it against the current list. A deletion emits return_domain.deleted.

REQUEST · NODE
JavaScript
1const removed = await request("DELETE", `/v1/return-domains/${domain.id}`);
RESPONSE · 200
JSON
1{
2 "data": {
3 "id": "rdom_01k8zq1g36yqd6x7c8bn23j9tv",
4 "object": "return_domain",
5 "origin": "https://shop.example.com",
6 "livemode": false,
7 "created_at": "2026-11-11T17:00:00.000Z",
8 "created_by": { "type": "api_key", "key_id": "ak_test_..." }
9 }
10}

Was this section helpful?

Powered by CX Pay