API Reference

Complete reference for the PayDirect REST API. All endpoints require authentication via API key.

Authentication
All API requests must include an authorization header
Authorization: Bearer <YOUR_API_KEY>
HeaderTypeDescription
AuthorizationstringBearer token with your API key
Content-Typestringapplication/json
Idempotency-Keystring (optional)Unique key to prevent duplicate requests
POST
/payments
Create a new payment intent

Request Body Parameters

FieldTypeRequiredDescription
amountstringYesPayment amount (e.g. "15.00")
currencystringYesCurrency code (USDC, ETH, etc.)
descriptionstringNoHuman-readable description
metadataobjectNoCustom key-value metadata
typestringNoPayment type: immediate, escrow, time-locked

Request Example

curl -X POST https://paydirect.com/api/payments \
  -H "Authorization: Bearer $PAYDIRECT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": "15.00",
    "currency": "USDC",
    "description": "API billing payment",
    "metadata": { "orderId": "ORD_123" }
  }'

Response (201 Created)

{
  "id": "pay_01GX5K...",
  "status": "pending",
  "amount": "15.00",
  "currency": "USDC",
  "description": "API billing payment",
  "metadata": { "orderId": "ORD_123" },
  "createdAt": "2025-08-11T14:36:22Z",
  "paymentUrl": "https://paydirect.com/pay/pay_01GX5K..."
}
GET
/payments/{id}
Retrieve a payment by ID

Path Parameters

ParameterTypeDescription
idstringPayment ID (e.g. pay_01GX5K...)

Response (200 OK)

{
  "id": "pay_01GX5K...",
  "status": "completed",
  "amount": "15.00",
  "currency": "USDC",
  "description": "API billing payment",
  "metadata": { "orderId": "ORD_123" },
  "createdAt": "2025-08-11T14:36:22Z",
  "completedAt": "2025-08-11T14:36:45Z",
  "transactionHash": "0xabc123..."
}

Status Enum

StatusDescription
pendingPayment created, awaiting settlement
completedSettlement confirmed on-chain
failedSettlement failed (insufficient funds, chain error)
cancelledPayment cancelled by user or expired
POST
/webhooks
Register a webhook endpoint

Request Body Parameters

FieldTypeRequiredDescription
urlstringYesHTTPS endpoint URL
eventsstring[]YesEvent types to subscribe to

Request Example

{
  "url": "https://yourapp.com/webhooks/paydirect",
  "events": ["payment.completed", "payment.failed"]
}

Response (201 Created)

{
  "id": "wh_01ABC...",
  "url": "https://yourapp.com/webhooks/paydirect",
  "events": ["payment.completed", "payment.failed"],
  "secret": "whsec_...",
  "createdAt": "2025-08-11T14:36:22Z"
}
Error Codes
Standard error responses returned by the API
HTTP StatusError CodeMeaning
40040001Missing required fields
40140102Invalid or missing API key
40240203Invalid payment request
40440400Resource not found
42942900Rate limit exceeded
50050000Internal server error