Customers
Manage customer data, payment methods, balances, and portal sessions with comprehensive CRUD operations
Customers
Customers represent your end users in GetPaidHQ. Each customer can have multiple subscriptions, payment methods, and invoices. Customer data is automatically isolated by organization for multi-tenancy.
The customer object
{
"id": "cus_1234567890abcdef",
"email": "customer@example.com",
"name": "John Doe",
"phone": "+1-555-123-4567",
"address": {
"line1": "123 Main St",
"line2": "Apt 4B",
"city": "San Francisco",
"state": "CA",
"postal_code": "94105",
"country": "US"
},
"currency": "USD",
"timezone": "America/Los_Angeles",
"language": "en",
"tax_id": "123-45-6789",
"tax_exempt": false,
"metadata": {
"user_id": "12345",
"source": "signup_form"
},
"payment_methods": [
{
"id": "pm_1234567890",
"type": "card",
"card": {
"brand": "visa",
"last4": "4242",
"exp_month": 12,
"exp_year": 2025
},
"is_default": true
}
],
"balance": 0,
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}Attributes
idstring - Unique identifier for the customeremailstring - Customer's email address (required, must be unique)namestring - Customer's full namephonestring - Customer's phone numberaddressobject - Customer's billing addresscurrencystring - Customer's preferred currency (3-letter ISO code)timezonestring - Customer's timezone (IANA timezone identifier)languagestring - Customer's preferred language (2-letter ISO code)tax_idstring - Customer's tax identification numbertax_exemptboolean - Whether the customer is exempt from taxesmetadataobject - Custom key-value pairs for additional datapayment_methodsarray - List of customer's payment methodsbalanceinteger - Customer's account balance in centscreated_atstring - ISO 8601 timestamp when customer was createdupdated_atstring - ISO 8601 timestamp when customer was last updated
Create a customer
Creates a new customer in your organization.
POST https://api.getpaidhq.com/api/customersParameters
emailstring required - Customer's email address (must be unique)namestring - Customer's full namephonestring - Customer's phone numberaddressobject - Customer's billing addressline1string - Address line 1line2string - Address line 2citystring - Citystatestring - State/provincepostal_codestring - ZIP/postal codecountrystring - Country code (2-letter ISO)
currencystring - Preferred currency (defaults to organization currency)timezonestring - Customer's timezonelanguagestring - Preferred languagetax_idstring - Tax identification numbertax_exemptboolean - Whether customer is tax exemptmetadataobject - Custom key-value pairs
Example request
curl https://api.getpaidhq.com/api/customers \
-H "Authorization: Bearer pk_live_..." \
-H "Content-Type: application/json" \
-d '{
"email": "customer@example.com",
"name": "John Doe",
"phone": "+1-555-123-4567",
"address": {
"line1": "123 Main St",
"city": "San Francisco",
"state": "CA",
"postal_code": "94105",
"country": "US"
},
"currency": "USD",
"metadata": {
"user_id": "12345",
"plan": "pro"
}
}'Example response
{
"id": "cus_1234567890abcdef",
"email": "customer@example.com",
"name": "John Doe",
"phone": "+1-555-123-4567",
"address": {
"line1": "123 Main St",
"city": "San Francisco",
"state": "CA",
"postal_code": "94105",
"country": "US"
},
"currency": "USD",
"timezone": "America/Los_Angeles",
"language": "en",
"tax_exempt": false,
"metadata": {
"user_id": "12345",
"plan": "pro"
},
"payment_methods": [],
"balance": 0,
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}Retrieve a customer
Retrieves an existing customer by ID.
GET https://api.getpaidhq.com/api/customers/{customer_id}Parameters
customer_idstring required - The ID of the customer to retrieve
Example request
curl https://api.getpaidhq.com/api/customers/cus_1234567890abcdef \
-H "Authorization: Bearer pk_live_..."Example response
{
"id": "cus_1234567890abcdef",
"email": "customer@example.com",
"name": "John Doe",
"currency": "USD",
"payment_methods": [
{
"id": "pm_1234567890",
"type": "card",
"card": {
"brand": "visa",
"last4": "4242"
},
"is_default": true
}
],
"balance": 0,
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}Update a customer
Updates an existing customer. Only provided fields will be updated.
PUT https://api.getpaidhq.com/api/customers/{customer_id}Parameters
customer_idstring required - The ID of the customer to updateemailstring - Customer's email addressnamestring - Customer's full namephonestring - Customer's phone numberaddressobject - Customer's billing addresscurrencystring - Preferred currencytimezonestring - Customer's timezonelanguagestring - Preferred languagetax_idstring - Tax identification numbertax_exemptboolean - Whether customer is tax exemptmetadataobject - Custom key-value pairs
Example request
curl https://api.getpaidhq.com/api/customers/cus_1234567890abcdef \
-X PUT \
-H "Authorization: Bearer pk_live_..." \
-H "Content-Type: application/json" \
-d '{
"name": "John Smith",
"phone": "+1-555-987-6543",
"metadata": {
"user_id": "12345",
"plan": "enterprise"
}
}'Example response
{
"id": "cus_1234567890abcdef",
"email": "customer@example.com",
"name": "John Smith",
"phone": "+1-555-987-6543",
"currency": "USD",
"metadata": {
"user_id": "12345",
"plan": "enterprise"
},
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T14:22:00Z"
}Delete a customer
Permanently deletes a customer. This action cannot be undone.
DELETE https://api.getpaidhq.com/api/customers/{customer_id}Parameters
customer_idstring required - The ID of the customer to delete
Notes
- Customers with active subscriptions cannot be deleted
- All payment methods will be detached before deletion
- Customer data in invoices and payments will be preserved for record-keeping
Example request
curl https://api.getpaidhq.com/api/customers/cus_1234567890abcdef \
-X DELETE \
-H "Authorization: Bearer pk_live_..."Example response
{
"id": "cus_1234567890abcdef",
"deleted": true
}List customers
Returns a paginated list of customers for your organization.
GET https://api.getpaidhq.com/api/customersParameters
limitinteger - Number of customers to return (1-100, default: 25)pageinteger - Page number for pagination (default: 1)cursorstring - Cursor for cursor-based paginationemailstring - Filter by email addresscreated_afterstring - Filter customers created after this date (ISO 8601)created_beforestring - Filter customers created before this date (ISO 8601)has_payment_methodboolean - Filter by whether customer has payment methodscurrencystring - Filter by customer currencyorder_bystring - Sort field (created_at,updated_at,name,email)order_dirstring - Sort direction (ascordesc)
Example request
curl "https://api.getpaidhq.com/api/customers?limit=50&order_by=created_at&order_dir=desc" \
-H "Authorization: Bearer pk_live_..."Example response
{
"items": [
{
"id": "cus_1234567890abcdef",
"email": "customer1@example.com",
"name": "John Doe",
"currency": "USD",
"created_at": "2024-01-15T10:30:00Z"
},
{
"id": "cus_1234567890abcdeg",
"email": "customer2@example.com",
"name": "Jane Smith",
"currency": "USD",
"created_at": "2024-01-15T09:15:00Z"
}
],
"total_count": 247,
"page": 1,
"page_size": 50,
"has_more": true,
"next_cursor": "eyJpZCI6ImN1c18xMjM0NTY3ODkwYWJjZGVnIn0="
}Search customers
Search customers by name, email, or metadata.
GET https://api.getpaidhq.com/api/customers/searchParameters
querystring required - Search querylimitinteger - Number of results to return (1-100, default: 25)fieldsarray - Fields to search (name,email,metadata)
Example request
curl "https://api.getpaidhq.com/api/customers/search?query=john&fields[]=name&fields[]=email" \
-H "Authorization: Bearer pk_live_..."Example response
{
"items": [
{
"id": "cus_1234567890abcdef",
"email": "john@example.com",
"name": "John Doe",
"score": 0.95
}
],
"total_count": 1
}Payment methods
Add payment method
Adds a payment method to a customer.
POST https://api.getpaidhq.com/api/customers/{customer_id}/payment_methodsParameters
customer_idstring required - The customer IDtypestring required - Payment method type (card,bank_account)tokenstring required - Payment method token from your payment processoris_defaultboolean - Whether to set as default payment method
Example request
curl https://api.getpaidhq.com/api/customers/cus_1234567890abcdef/payment_methods \
-H "Authorization: Bearer pk_live_..." \
-H "Content-Type: application/json" \
-d '{
"type": "card",
"token": "tok_visa_4242",
"is_default": true
}'List payment methods
GET https://api.getpaidhq.com/api/customers/{customer_id}/payment_methodsExample request
curl https://api.getpaidhq.com/api/customers/cus_1234567890abcdef/payment_methods \
-H "Authorization: Bearer pk_live_..."Example response
{
"items": [
{
"id": "pm_1234567890",
"type": "card",
"card": {
"brand": "visa",
"last4": "4242",
"exp_month": 12,
"exp_year": 2025
},
"is_default": true,
"created_at": "2024-01-15T10:30:00Z"
}
]
}Update payment method
PUT https://api.getpaidhq.com/api/customers/{customer_id}/payment_methods/{payment_method_id}Parameters
is_defaultboolean - Whether to set as defaultmetadataobject - Custom metadata
Delete payment method
DELETE https://api.getpaidhq.com/api/customers/{customer_id}/payment_methods/{payment_method_id}Customer balance
Retrieve balance
GET https://api.getpaidhq.com/api/customers/{customer_id}/balanceExample response
{
"balance": -500,
"currency": "USD",
"transactions": [
{
"id": "txn_1234567890",
"amount": -500,
"description": "Credit applied",
"created_at": "2024-01-15T10:30:00Z"
}
]
}Adjust balance
POST https://api.getpaidhq.com/api/customers/{customer_id}/balanceParameters
amountinteger required - Amount to adjust in cents (positive for credit, negative for debit)descriptionstring required - Description of the adjustmentmetadataobject - Custom metadata
Example request
curl https://api.getpaidhq.com/api/customers/cus_1234567890abcdef/balance \
-H "Authorization: Bearer pk_live_..." \
-H "Content-Type: application/json" \
-d '{
"amount": -1000,
"description": "Account credit for referral"
}'Customer portal
Create portal session
Creates a secure session for customers to manage their subscriptions and payment methods.
POST https://api.getpaidhq.com/api/customers/{customer_id}/portal_sessionParameters
return_urlstring required - URL to redirect after sessionfeaturesobject - Available features in the portalsubscription_managementboolean - Allow subscription changespayment_method_managementboolean - Allow payment method updatesinvoice_historyboolean - Show invoice history
Example request
curl https://api.getpaidhq.com/api/customers/cus_1234567890abcdef/portal_session \
-H "Authorization: Bearer pk_live_..." \
-H "Content-Type: application/json" \
-d '{
"return_url": "https://your-app.com/account",
"features": {
"subscription_management": true,
"payment_method_management": true,
"invoice_history": true
}
}'Example response
{
"id": "ps_1234567890abcdef",
"url": "https://portal.getpaidhq.com/session/ps_1234567890abcdef",
"customer_id": "cus_1234567890abcdef",
"expires_at": "2024-01-15T11:30:00Z",
"created_at": "2024-01-15T10:30:00Z"
}Webhooks
The following webhook events are available for customers:
customer.created- New customer createdcustomer.updated- Customer information updatedcustomer.deleted- Customer deletedcustomer.payment_method.added- Payment method addedcustomer.payment_method.updated- Payment method updatedcustomer.payment_method.removed- Payment method removed
Example webhook payload
{
"id": "evt_1234567890abcdef",
"type": "customer.created",
"created_at": "2024-01-15T10:30:00Z",
"data": {
"id": "cus_1234567890abcdef",
"email": "customer@example.com",
"name": "John Doe",
"created_at": "2024-01-15T10:30:00Z"
}
}Error codes
Common error codes when working with customers:
| Code | Description |
|---|---|
customer_not_found | Customer ID doesn't exist |
email_already_exists | Email address is already in use |
invalid_email_format | Email format is invalid |
customer_has_active_subscriptions | Cannot delete customer with active subscriptions |
payment_method_not_found | Payment method ID doesn't exist |
invalid_currency | Currency code is not supported |
Integration Examples
Using cURL
# Create customer
curl -X POST https://api.getpaidhq.co/api/customers \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"email": "customer@example.com",
"firstName": "John",
"lastName": "Doe"
}'
# Retrieve customer
curl -X GET https://api.getpaidhq.co/api/customers/cus_1234567890abcdef \
-H "Authorization: Bearer YOUR_API_KEY"
# List customers
curl -X GET "https://api.getpaidhq.co/api/customers?limit=50" \
-H "Authorization: Bearer YOUR_API_KEY"
# Update customer
curl -X PATCH https://api.getpaidhq.co/api/customers/cus_1234567890abcdef \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"firstName": "John",
"lastName": "Smith"
}'