DocsREST API
REST API Reference
Complete reference for the PayHub REST API. All endpoints, parameters, and response formats.
Base URL
Production
https://api.payhub.work/v1Sandbox
https://sandbox.api.payhub.work/v1Authentication
Include your API key in the Authorization header:
Authorization: Bearer sk_live_your-api-key
Payments
POST
/paymentsAuth requiredCreate 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 unitscurrencystring, required - Token symbol (USDC, ETH, etc.)networkstring, required - Blockchain networkdescriptionstring, optional - Payment descriptionexpiresInnumber, optional - Expiry in seconds (default: 3600)metadataobject, optional - Custom metadataResponse
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 requiredRetrieve a payment by ID
Returns the payment object with the specified ID.
GET
/paymentsAuth requiredList all payments with optional filters
Query Parameters
limitnumber - Results per page (default: 20, max: 100)offsetnumber - Pagination offsetstatusstring - Filter by statusfromstring - 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 requiredList configured webhook endpoints
POST
/webhooksAuth requiredCreate a new webhook endpoint
DELETE
/webhooks/:idAuth requiredDelete a webhook endpoint
POST
/webhooks/:id/testAuth requiredSend a test webhook event
Networks
GET
/networksList all supported networks and their status
GET
/networks/:slugGet 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:
| Plan | Requests/min | Burst |
|---|---|---|
| Sandbox | 60 | 10 |
| Starter | 120 | 20 |
| Growth | 300 | 50 |
| Enterprise | Custom | Custom |
Rate Limit Headers
Check response headers for your current rate limit status:
X-RateLimit-Limit- Max requests per minuteX-RateLimit-Remaining- Remaining requestsX-RateLimit-Reset- Reset timestamp