Create a payment
const url = 'https://hub.stablezact.com/api/v1/payments/create';const options = { method: 'POST', headers: {'X-Public-Key': '<X-Public-Key>', 'Content-Type': 'application/json'}, body: '{"amount":1,"currency":"USDT","network":"ethereum","customerEmail":"hello@example.com","callbackUrl":"https://example.com","orderId":"example","metadata":{"additionalProperty":"example"},"agentId":"example","agentOwner":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://hub.stablezact.com/api/v1/payments/create \ --header 'Content-Type: application/json' \ --header 'X-Public-Key: <X-Public-Key>' \ --data '{ "amount": 1, "currency": "USDT", "network": "ethereum", "customerEmail": "hello@example.com", "callbackUrl": "https://example.com", "orderId": "example", "metadata": { "additionalProperty": "example" }, "agentId": "example", "agentOwner": "example" }'Idempotent. The server recognises a repeat using the first of these it
finds: an Idempotency-Key header, an orderId in the body, or a
fingerprint of the whole body. The versioned and unversioned paths share
a key, so retrying against either does not create a second payment.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”Preferred way to make a retry safe.
Request Bodyrequired
Section titled “Request Bodyrequired”object
Validation accepts four values, but only USDC and USDT are configured on any network. DAI and BUSD pass validation and then fail with “Currency DAI is not supported on the base network”.
Case-insensitive. You must have a settlement wallet configured for the network, or the request is rejected naming it.
Optional. Normalised before storage.
Where webhooks for this payment are delivered.
Your own reference. Also used to recognise a retry when no Idempotency-Key header is sent, so keep it at the top level rather than inside metadata, which is ignored for that purpose.
Arbitrary key/value data returned on reads and included in webhooks. Must be an object, not an array. Values may be strings, numbers, booleans or null.
object
For agent-initiated payments. Must be sent with agentOwner.
Must be sent with agentId. Sending one without the other is rejected.
Responses
Section titled “Responses”Payment created.
object
Includes a contractCall block with everything needed to submit the payment on chain: contract address, function name, parameters and whether an approval is required.
object
Examplegenerated
{ "success": true, "requestId": "example", "amount": 1, "payment": {}}The request was rejected. Read error and message.
object
Short machine-ish reason.
Longer explanation, when there is one.
Example
{ "success": false, "error": "Validation failed", "message": "Unsupported currency: GBP"}Missing or invalid credentials.
object
Short machine-ish reason.
Longer explanation, when there is one.
Example
{ "error": "API credentials required. Use x-public-key header or x-api-key and x-api-secret headers."}