For the complete documentation index, see llms.txt. This page is also available as Markdown.

Create Payment

Creates a new crypto payment and returns a hosted checkout URL.

POST /v1/api/payments

Required scope: payments:create


Request body

Field
Type
Required
Description

amount

number

Conditional

Amount in USD. Required if product_id is not provided. Min: 0.01.

product_id

string

Conditional

Product ID to charge for. Required if amount is not provided.

token

string

Yes

Crypto token to accept. See Supported Tokens.

network

string

Yes

Blockchain network. See Supported Tokens.

customer_email

string

No

Customer's email address.

customer_name

string

No

Customer's name.

redirect_url

string

No

URL to redirect the customer after successful payment.

cancel_url

string

No

URL to redirect if the customer cancels.

metadata

object

No

Custom key-value pairs stored with the payment. Returned in webhook payloads.


Example

curl -X POST https://apipay.byastra.ai/v1/api/payments \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: ap_live_your_api_key" \
  -H "Idempotency-Key: order_12345" \
  -d '{
    "amount": 49.99,
    "token": "USDC",
    "network": "BASE",
    "customer_email": "john@example.com",
    "redirect_url": "https://yourapp.com/success",
    "metadata": {
      "order_id": "ORD-12345",
      "plan": "pro"
    }
  }'
const res = await fetch("https://apipay.byastra.ai/v1/api/payments", {
  method: "POST",
  headers: {
    "X-Api-Key": "ap_live_your_api_key",
    "Content-Type": "application/json",
    "Idempotency-Key": "order_12345",
  },
  body: JSON.stringify({
    amount: 49.99,
    token: "USDC",
    network: "BASE",
    redirect_url: "https://yourapp.com/success",
    metadata: { order_id: "ORD-12345" },
  }),
});

const { data } = await res.json();
window.location.href = data.checkout_url;

Response 201 Created

Use the Idempotency-Key header with your order ID to safely retry failed requests without creating duplicate payments. See Idempotency.

Last updated