Accept payments
Customers
Create and manage the customer records that payments, invoices, and subscriptions reference.
Overview
The Customer object represents a payer in your account. Payments, invoices, and subscriptions reference it by id (format ph_cus_<32 hex>). Customers are scoped to your merchant account and email addresses are unique within it. All requests use Authorization: Bearer phk_live_... and return the { data, error } envelope.
Create a customer
curl -X POST https://paymenthooks.com/api/v1/customers \
-H "Content-Type: application/json" \
-H "Authorization: Bearer phk_live_..." \
-d '{"name":"Jane Doe","email":"[email protected]","country":"US"}'Errors: 400 VALIDATION_ERROR (with per-field messages in error.fields), 401 UNAUTHORIZED, 409 DUPLICATE_EMAIL, 500 INTERNAL_ERROR.
Parameters
| Field | Type | Description |
|---|---|---|
name | string | Customer's full name or business name. 1-255 characters. |
email | string | Valid email address, max 254 characters, checked with the same rules as the hosted checkout; the domain is stored lower-cased. Unique per merchant (case-insensitive); an existing email returns 409 DUPLICATE_EMAIL. |
phone | string | Phone number, validated against the numbering plan of its country (worldwide). Send it international (+91 97461 02494; spaces, dots, dashes and brackets are accepted) or as a national number together with country. Stored and returned in E.164 (+919746102494). An invalid number returns 400 VALIDATION_ERROR naming phone. The hosted checkout splits it into its country and number and does not ask the customer again. |
country | stringDefault: | Country code, max 5 characters (use ISO 3166-1 alpha-2, e.g. US, GB, IN). |
metadata | object | String-to-string key-value pairs for your internal reference. |
New customers are created with status: "active", totalSpendAmountUsdCents: 0 and paymentCount: 0. A customer has no currency field: one customer can pay in many currencies.
| Field | Type | Description |
|---|---|---|
name | string | New name, 1-255 characters. |
email | string | New email address (same rules as on create). |
phone | string | New phone number (same rules as on create: international, or national with country; stored in E.164). Pass null to clear it. |
country | string | New country code, 2-5 characters (ISO 3166-1 alpha-2 recommended). |
metadata | object | Replaces the stored metadata object entirely (it is not merged). |
Only the fields above can be updated. Any other field, including server-managed ones such as status, totalSpendAmountUsdCents, paymentCount or merchantId, returns 400 VALIDATION_ERROR and nothing is updated. Creating a customer is equally strict: a field other than name, email, phone, country or metadata returns 400 VALIDATION_ERROR.
List parameters
| Field | Type | Description |
|---|---|---|
search | string | Case-insensitive substring match on name, email or id, or an exact two-letter country code. Max 200 characters. |
status | string | Exact match on customer status (e.g. active, inactive). Archived customers are left out of every list unless status=archived, which lists only them. |
page | integerDefault: | 1-based page number. |
pageSize | integerDefault: | Items per page, 1-100. limit is accepted as the same parameter. |
sortField | stringDefault: | One of createdAt, name, email, totalSpendAmountUsdCents, status. Any other value sorts newest first. |
sortDirection | stringDefault: | asc or desc. |
dateFrom / dateTo | string | Created on or after / on or before this UTC day (YYYY-MM-DD). |
There is no dedicated email filter; use search. Any other query parameter returns 400 VALIDATION_ERROR naming it (it is never ignored). When pageSize is omitted the API returns 25 items.
Archiving a customer
Customers are archived, never deleted, so their payment, invoice and subscription history stays intact. Cancel the customer's active, trialing or past-due subscriptions first. To remove personal data, use GDPR erasure (see Related endpoints).
| Field | Type | Description |
|---|---|---|
POST /api/v1/customers/:customerId/archive | endpoint | Archives the customer (customers:write). Payments, invoices and subscriptions are kept. The customer is left out of lists unless status=archived, and new checkout sessions, payments, subscriptions and invoices for it are refused with 409 CUSTOMER_ARCHIVED. Refused with 409 CUSTOMER_HAS_ACTIVE_SUBSCRIPTIONS (listing them in error.details.subscriptions) while a subscription is active, trialing or past_due. Archiving an archived customer returns it unchanged. Returns the customer with archived: true and archivedAt. |
POST /api/v1/customers/:customerId/unarchive | endpoint | Restores an archived customer (customers:write): it is listed again and can be charged and invoiced. Both actions are recorded in the activity log (customer.archived, customer.unarchived) and send customer.updated with previous_attributes.archived. |
Endpoints & Responses
Customers support create, list, retrieve, update, archive and unarchive. There is no endpoint that deletes a customer; archive it (Archiving a customer) or use the GDPR erasure endpoint under Related endpoints to anonymise one. totalSpendAmountUsdCents (what the customer paid and kept, captured less refunded, in USD cents across every currency) and paymentCount are maintained by PaymentHooks as payments succeed or are refunded. Retrieving or updating a customer that does not belong to your account returns 404 NOT_FOUND.
/api/v1/customersCreate a customer (201). An email that already exists in your account (case-insensitive) returns 409 DUPLICATE_EMAIL.{
"name": "Jane Doe",
"email": "[email protected]",
"phone": "+14155552671",
"country": "US",
"metadata": { "crmId": "hubspot-90827" }
}{
"data": {
"id": "ph_cus_8f14e45fceea167a5a36dedd4bea2543",
"merchantId": "ph_mrc_c9f0f895fb98ab9159f51fd0297e236d",
"name": "Jane Doe",
"email": "[email protected]",
"phone": "+14155552671",
"country": "US",
"totalSpendAmountUsdCents": 0,
"paymentCount": 0,
"status": "active",
"defaultPaymentMethodId": null,
"metadata": { "crmId": "hubspot-90827" },
"createdAt": "2026-05-16T10:30:00.000Z"
},
"error": null
}/api/v1/customers?search=jane&page=1&pageSize=10List customers (newest first by default){
"data": [
{
"id": "ph_cus_8f14e45fceea167a5a36dedd4bea2543",
"merchantId": "ph_mrc_c9f0f895fb98ab9159f51fd0297e236d",
"name": "Jane Doe",
"email": "[email protected]",
"phone": "+14155552671",
"country": "US",
"totalSpendAmountUsdCents": 12450,
"paymentCount": 3,
"status": "active",
"metadata": { "crmId": "hubspot-90827" },
"createdAt": "2026-05-16T10:30:00.000Z"
}
],
"meta": { "total": 1, "page": 1, "pageSize": 10 },
"error": null,
"livemode": true
}/api/v1/customers/:customerIdRetrieve a customer (normalised shape with camelCase and snake_case aliases){
"data": {
"id": "ph_cus_8f14e45fceea167a5a36dedd4bea2543",
"customer_id": "ph_cus_8f14e45fceea167a5a36dedd4bea2543",
"name": "Jane Doe",
"email": "[email protected]",
"phone": "+14155552671",
"status": "active",
"country": "US",
"totalSpendAmountUsdCents": 12450,
"paymentCount": 3,
"metadata": { "crmId": "hubspot-90827" },
"meta_data": { "crmId": "hubspot-90827" },
"createdAt": "2026-05-16T10:30:00.000Z",
"created_at": "2026-05-16T10:30:00.000Z",
"billing_email": null,
"company": null,
"customer_tier": null,
"country_iso2": null,
"timezone": null
},
"error": null
}/api/v1/customers/:customerIdUpdate a customer (returns the stored record). Only name, email, phone, country and metadata are accepted; other fields return 400 VALIDATION_ERROR.{
"name": "Jane Doe-Smith",
"phone": "+12025550173",
"metadata": { "crmId": "hubspot-90827", "vip": "true" }
}{
"data": {
"id": "ph_cus_8f14e45fceea167a5a36dedd4bea2543",
"merchantId": "ph_mrc_c9f0f895fb98ab9159f51fd0297e236d",
"name": "Jane Doe-Smith",
"email": "[email protected]",
"phone": "+12025550173",
"country": "US",
"status": "active",
"metadata": { "crmId": "hubspot-90827", "vip": "true" },
"createdAt": "2026-05-16T10:30:00.000Z"
},
"error": null
}Addresses
A customer can have multiple addresses (typically billing and shipping). The default address is printed on invoice PDFs. Address IDs use the ph_adr_ prefix. Create and list return a snake_case representation; update returns the stored camelCase record. On create, a missing type, line1, city, postalCode or country, a type other than billing or shipping, or any unknown field returns 400 VALIDATION_ERROR. Update (PUT) accepts any subset of the same fields; send at least one. Unknown or server-managed fields (such as customerId) return 400 VALIDATION_ERROR.
| Field | Type | Description |
|---|---|---|
type | string | Address purpose: billing or shipping. |
line1 | string | Street address. |
city | string | City. |
postalCode | string | Postal / ZIP code. |
country | string | Country code, 2-3 characters (ISO 3166-1 alpha-2 recommended). |
line2 | string | Apartment, suite, unit. |
state | string | State / region code. Returned as region_code. |
isDefault | booleanDefault: | Marks the address as the customer's default (used on invoice PDFs). |
/api/v1/customers/:customerId/addressesAdd an address to a customer (201){
"type": "billing",
"line1": "123 Market Street",
"line2": "Suite 400",
"city": "San Francisco",
"state": "CA",
"postalCode": "94103",
"country": "US"
}{
"data": {
"id": "ph_adr_45c48cce2e2d7fbdea1afc51c7c6ad26",
"customer_id": "ph_cus_8f14e45fceea167a5a36dedd4bea2543",
"address_type": "billing",
"region_code": "CA",
"region_name": null,
"city": "San Francisco",
"postal_code": "94103",
"address_line1": "123 Market Street",
"address_line2": "Suite 400",
"country_iso2": "US",
"country_iso3": null,
"country_name": "US",
"latitude": null,
"longitude": null,
"created_at": "2026-05-16T10:30:00.000Z",
"updated_at": null
},
"error": null
}/api/v1/customers/:customerId/addressesList a customer's addresses (newest first, same shape as create, not paginated){
"data": [
{ "id": "ph_adr_45c48cce2e2d7fbdea1afc51c7c6ad26", "customer_id": "ph_cus_8f14e45fceea167a5a36dedd4bea2543", "address_type": "billing", "city": "San Francisco" }
],
"error": null
}/api/v1/customers/:customerId/addresses/:addressIdUpdate an address with any subset of the create fields (returns the stored camelCase record). Unknown fields return 400 VALIDATION_ERROR.{
"line2": "Suite 500",
"isDefault": true
}{
"data": {
"id": "ph_adr_45c48cce2e2d7fbdea1afc51c7c6ad26",
"customerId": "ph_cus_8f14e45fceea167a5a36dedd4bea2543",
"type": "billing",
"line1": "123 Market Street",
"line2": "Suite 500",
"city": "San Francisco",
"state": "CA",
"postalCode": "94103",
"country": "US",
"isDefault": true,
"createdAt": "2026-05-16T10:30:00.000Z"
},
"error": null
}/api/v1/customers/:customerId/addresses/:addressIdDelete an address{
"data": { "deleted": true },
"error": null
}Tax IDs
Store a customer's tax registration numbers (IDs use the ph_tid_ prefix). type and value are required, and type must be one of the values below; anything else returns 400 VALIDATION_ERROR.
eu_vat, us_ein, gb_vat, au_abn, in_gst, ca_gst/api/v1/customers/:customerId/tax-idsAdd a tax ID to a customer (201). Numbers with a registry are checked before the response (EU and Monaco VAT with VIES; UK and Isle of Man VAT with HMRC; Norway with Brreg; Switzerland with the UID register; Australian ABNs with ABN Lookup): verificationStatus is verified, invalid, unavailable (the registry could not answer now) or not_checked (no registry for the type, the platform cannot ask that registry, or a UK GD / HA number, which is never reverse charged). Only a verified number of those types is reverse charged. A verified answer counts for 30 days: after that it is checked again when tax is next calculated with it, and the new answer replaces verificationStatus. A verified tax ID is used before an unverified one, then the most recently added.{
"type": "eu_vat",
"value": "IE6388047V"
}{
"data": {
"id": "ph_tid_d3d9446802a44259755d38e6d163e820",
"customerId": "ph_cus_8f14e45fceea167a5a36dedd4bea2543",
"type": "eu_vat",
"value": "IE6388047V",
"country": "IE",
"verificationStatus": "verified",
"verification": {
"status": "verified", "source": "vies", "checkedAt": "2026-11-25T09:11:02.431Z",
"name": "GOOGLE IRELAND LIMITED", "address": "3RD FLOOR, GORDON HOUSE, BARROW STREET, DUBLIN 4",
"message": null, "consultationNumber": "WAPIAAAAaIR-QXJY"
},
"createdAt": "2026-11-25T09:11:02.500Z"
},
"error": null
}/api/v1/customers/:customerId/tax-idsList a customer's tax IDs{
"data": [
{ "id": "ph_tid_d3d9446802a44259755d38e6d163e820", "customerId": "ph_cus_8f14e45fceea167a5a36dedd4bea2543", "type": "eu_vat", "value": "DE123456789", "verificationStatus": "pending", "createdAt": "2026-05-16T10:30:00.000Z" }
],
"error": null
}/api/v1/customers/:customerId/tax-ids?taxIdId=:taxIdDelete a tax ID (the tax ID is passed as the taxIdId query parameter){
"data": { "deleted": true },
"error": null
}The value is stored as provided. PaymentHooks does not validate the format or check it against an external registry (such as VIES), and new tax IDs are stored with verificationStatus: "pending".