API Reference
Complete API reference for GetPaidHQ's REST API
Welcome to the GetPaidHQ API Reference. This section provides comprehensive documentation for our REST API, including endpoints, parameters, responses, and examples.
API Overview
GetPaidHQ provides a RESTful API that allows you to manage all aspects of your billing and subscription operations programmatically.
Base URL
https://api.getpaidhq.com/v1
Authentication
All API requests require authentication using an API key passed in the Authorization
header:
Authorization: Bearer your_api_key_here
Core Resources
Customers
Manage customer profiles, payment methods, and billing information
Subscriptions
Create and manage recurring subscriptions and billing cycles
Usage Records
Record and track usage data for metered billing
Webhooks
Configure and manage webhook endpoints for real-time events
Quick Reference
Common Endpoints
Customers
POST /customers
- Create a new customerGET /customers/{id}
- Retrieve customer detailsPUT /customers/{id}
- Update customer informationDELETE /customers/{id}
- Delete a customer
Subscriptions
POST /subscriptions
- Create a new subscriptionGET /subscriptions/{id}
- Get subscription detailsPUT /subscriptions/{id}
- Update subscriptionPOST /subscriptions/{id}/cancel
- Cancel subscription
Usage Records
POST /usage-records
- Record usage dataPOST /usage-records/batch
- Batch record usageGET /usage-records
- List usage recordsGET /subscriptions/{id}/usage-summary
- Get usage summary
HTTP Status Codes
Code | Description |
---|---|
200 | Success |
201 | Created |
204 | No Content |
400 | Bad Request |
401 | Unauthorized |
403 | Forbidden |
404 | Not Found |
422 | Unprocessable Entity |
429 | Too Many Requests |
500 | Internal Server Error |
API Features
Pagination
List endpoints support cursor-based pagination:
{
"data": [...],
"has_more": true,
"next_cursor": "cursor_string"
}
Filtering & Sorting
Many endpoints support filtering and sorting:
GET /customers?status=active&sort=created_at&order=desc
Idempotency
Prevent duplicate operations using idempotency keys:
POST /subscriptions
Idempotency-Key: unique-key-123
Rate Limiting
API requests are rate limited by organization:
- Standard: 100 requests per minute
- Premium: 1000 requests per minute
Rate limit headers are included in responses:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1234567890
Request & Response Format
Request Format
- Content-Type:
application/json
- All dates in ISO 8601 format
- Amounts in smallest currency unit (cents)
Response Format
{
"object": "customer",
"id": "cus_123",
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-01T00:00:00Z",
// ... other fields
}
Error Format
{
"error": {
"type": "invalid_request_error",
"code": "missing_required_param",
"message": "Missing required parameter: email",
"param": "email"
}
}
Code Examples
Create a Customer
curl -X POST https://api.getpaidhq.com/v1/customers \
-H "Authorization: Bearer your_api_key" \
-H "Content-Type: application/json" \
-d '{
"email": "customer@example.com",
"name": "John Doe",
"metadata": {
"user_id": "123"
}
}'
Create a Subscription
curl -X POST https://api.getpaidhq.com/v1/subscriptions \
-H "Authorization: Bearer your_api_key" \
-H "Content-Type: application/json" \
-d '{
"customer_id": "cus_123",
"items": [{
"price_id": "price_monthly",
"quantity": 1
}],
"trial_period_days": 14
}'
Record Usage
curl -X POST https://api.getpaidhq.com/v1/usage-records \
-H "Authorization: Bearer your_api_key" \
-H "Content-Type: application/json" \
-d '{
"subscription_item_id": "si_123",
"quantity": 100,
"timestamp": "2024-01-01T12:00:00Z",
"action": "increment"
}'
Integration
The API accepts standard HTTP requests and can be integrated using any HTTP client library in your preferred programming language.
Testing
Test Environment
Use the test environment for development and testing:
https://api-test.getpaidhq.co
Test Data
We provide test data for common scenarios:
- Test customer IDs
- Test payment methods
- Test webhook events
API Collection
Download our Postman collection for easy API testing: Download Postman Collection
Webhooks
GetPaidHQ sends webhooks for important events:
customer.created
- New customer createdsubscription.created
- New subscription createdinvoice.payment_succeeded
- Payment successfulinvoice.payment_failed
- Payment failed
Configure webhook endpoints in your dashboard and verify signatures for security.
Need Help?
- Interactive API Explorer - Try endpoints directly in your browser
- Support - Contact our technical support team
- Status Page - Check API status and uptime
- Changelog - Stay updated with API changes