DocsREST API

REST API Reference

Complete reference for the PayHub REST API. All endpoints, parameters, and response formats.

Base URL

Productionhttps://api.payhub.work/v1
Sandboxhttps://sandbox.api.payhub.work/v1

Authentication

Include your API key in the Authorization header:

Authorization: Bearer sk_live_your-api-key

Payments

POST/paymentsAuth required

Create a new payment request

Request Body

JSON
{
  "amount": "100.00",
  "currency": "USDC",
  "network": "polygon",
  "description": "Order #12345",
  "expiresIn": 3600,
  "metadata": {
    "orderId": "12345"
  },
  "callbackUrl": "https://example.com/webhooks",
  "redirectUrl": "https://example.com/thank-you"
}

Parameters

amountstring, required - Amount in token units
currencystring, required - Token symbol (USDC, ETH, etc.)
networkstring, required - Blockchain network
descriptionstring, optional - Payment description
expiresInnumber, optional - Expiry in seconds (default: 3600)
metadataobject, optional - Custom metadata

Response

JSON
{
  "id": "pay_abc123xyz",
  "status": "pending",
  "amount": "100.00",
  "currency": "USDC",
  "network": "polygon",
  "address": "0x1234...abcd",
  "checkoutUrl": "https://checkout.payhub.work/pay_abc123xyz",
  "expiresAt": "2024-01-15T12:00:00Z",
  "createdAt": "2024-01-15T11:00:00Z",
  "metadata": {
    "orderId": "12345"
  }
}
GET/payments/:idAuth required

Retrieve a payment by ID

Returns the payment object with the specified ID.

GET/paymentsAuth required

List all payments with optional filters

Query Parameters

limitnumber - Results per page (default: 20, max: 100)
offsetnumber - Pagination offset
statusstring - Filter by status
fromstring - Start date (ISO 8601)
tostring - End date (ISO 8601)

Response

JSON
{
  "data": [
    {
      "id": "pay_abc123xyz",
      "status": "completed",
      "amount": "100.00",
      "currency": "USDC",
      "network": "polygon",
      "createdAt": "2024-01-15T11:00:00Z"
    }
  ],
  "pagination": {
    "total": 42,
    "limit": 20,
    "offset": 0,
    "hasMore": true
  }
}

Webhooks

GET/webhooksAuth required

List configured webhook endpoints

POST/webhooksAuth required

Create a new webhook endpoint

DELETE/webhooks/:idAuth required

Delete a webhook endpoint

POST/webhooks/:id/testAuth required

Send a test webhook event

Networks

GET/networks

List all supported networks and their status

GET/networks/:slug

Get details for a specific network

Errors

The API uses standard HTTP status codes. Error responses include a JSON body with details:

JSON
{
  "error": {
    "code": "invalid_request",
    "message": "The amount must be a positive number",
    "param": "amount"
  }
}
200Success
400Bad Request - Invalid parameters
401Unauthorized - Invalid API key
404Not Found - Resource doesn't exist
429Too Many Requests - Rate limit exceeded
500Internal Error - Something went wrong

Rate Limits

API requests are rate limited to ensure fair usage:

PlanRequests/minBurst
Sandbox6010
Starter12020
Growth30050
EnterpriseCustomCustom

Rate Limit Headers

Check response headers for your current rate limit status:

  • X-RateLimit-Limit - Max requests per minute
  • X-RateLimit-Remaining - Remaining requests
  • X-RateLimit-Reset - Reset timestamp