Skip to content

User API

The User API is called by the checkout frontend running in the user's browser. All requests require a signed checkout URL generated by your application backend.

Base path: /api/v1/user
Authentication: Ocrch-Signed-Url + Ocrch-Signature headers — see Authentication

Every User API request must include these two headers:

HeaderValue
Ocrch-Signed-UrlThe full checkout URL that was signed by your backend
Ocrch-Signature{timestamp}.{base64_hmac} computed over the URL

List all available chain/coin pairs (based on your wallet configuration).

No request body.

Response — 200 OK:

[
{
"blockchain": "eth",
"stablecoin": "USDT",
"wallet_address": "0xYourEthereumWalletAddress"
},
{
"blockchain": "eth",
"stablecoin": "USDC",
"wallet_address": "0xYourEthereumWalletAddress"
},
{
"blockchain": "tron",
"stablecoin": "USDT",
"wallet_address": "TYourTronWalletAddress"
}
]

Each element represents one selectable payment option. Display these to the user so they can choose how to pay.

FieldTypeDescription
blockchainstringChain identifier (see blockchain identifiers)
stablecoinstringStablecoin identifier ("USDT", "USDC", "DAI")
wallet_addressstringReceiving wallet address for this chain

Select a payment method (chain + stablecoin) for an order. Creates a pending deposit and returns the wallet address and expected amount.

Path parameter: order_id — the Ocrch order UUID.

Request headers:

HeaderValue
Content-Typeapplication/json
Ocrch-Signed-UrlSigned checkout URL
Ocrch-Signature{timestamp}.{base64_hmac}

Request body:

{
"blockchain": "eth",
"stablecoin": "USDT"
}
FieldTypeRequiredDescription
blockchainstringYesChain to pay on.
stablecoinstringYesCoin to pay with.

Response — 201 Created:

{
"order_id": "550e8400-e29b-41d4-a716-446655440000",
"wallet_address": "0xYourEthereumWalletAddress",
"amount": "19.99",
"blockchain": "eth",
"stablecoin": "USDT"
}
FieldTypeDescription
order_idUUID stringInternal order ID
wallet_addressstringAddress the user must send funds to
amountdecimal stringExact amount the user must send
blockchainstringSelected chain
stablecoinstringSelected stablecoin

Error responses:

StatusBodyCause
404 Not Foundorder not foundOrder UUID does not exist
409 Conflictorder is not pendingOrder already paid, expired, or cancelled
400 Bad Requestno wallet available for the selected chain and coinNo configured wallet supports this combination
400 Bad Requestinvalid blockchain selectionChain value unrecognized

Cancel an order. Only pending orders can be cancelled.

Path parameter: order_id — the Ocrch order UUID.

Request headers:

HeaderValue
Ocrch-Signed-UrlSigned checkout URL
Ocrch-Signature{timestamp}.{base64_hmac}

No request body.

Response — 200 OK (empty body on success).

Error responses:

StatusBodyCause
404 Not Foundorder not foundOrder UUID does not exist
409 Conflictorder is not pendingOrder already in terminal state

Poll the current status of an order.

Path parameter: order_id — the Ocrch order UUID.

Response — 200 OK:

{
"order_id": "550e8400-e29b-41d4-a716-446655440000",
"merchant_order_id": "your-order-reference-123",
"amount": "19.99",
"status": "pending",
"created_at": 1711900800
}

Use this as a fallback when WebSocket connections are not available.


Upgrade to a WebSocket connection and receive real-time order status updates.

Path parameter: order_id — the Ocrch order UUID.

Authentication: The Ocrch-Signed-Url and Ocrch-Signature headers must be sent during the HTTP upgrade request.

  1. Immediately after upgrade, the server sends a status_update frame with the current order state.
  2. Subsequent status_update frames are sent whenever the order status changes.
  3. After a terminal status (paid, expired, cancelled) the server sends a close frame with code 1000.

Messages are JSON text frames:

Status update:

{
"type": "status_update",
"order": {
"order_id": "550e8400-e29b-41d4-a716-446655440000",
"merchant_order_id": "your-order-reference-123",
"amount": "19.99",
"status": "pending",
"created_at": 1711900800
}
}

Error (non-closing):

{
"type": "error",
"code": 4004,
"reason": "order not found"
}
CodeMeaning
1000Normal closure — terminal status delivered
1011Internal server error
4004Order not found
import WebSocket from "ws";
const ws = new WebSocket(
`wss://checkout-api.example.com/api/v1/user/orders/${orderId}/ws`,
{
headers: {
"Ocrch-Signed-Url": signedUrl,
"Ocrch-Signature": signature,
},
}
);
ws.on("message", (data) => {
const msg = JSON.parse(data.toString());
if (msg.type === "status_update") {
console.log("Order status:", msg.order.status);
}
});
ws.on("close", (code) => {
console.log("WebSocket closed with code:", code);
});

ValueMeaning
"pending"Awaiting payment
"paid"Payment confirmed on-chain
"expired"Timed out before payment
"cancelled"Cancelled by user or merchant