Customers
The customers endpoints of the Kashu API, with their parameters, objects, errors and examples. The guide explains how they fit together.
The customer object
| Field | Type | About |
|---|
id | string | An id that starts cu_. |
object | string | Always "customer". |
email | string or null | |
name | string or null | |
phone | string or null | |
address | object or null | |
address.line1 | string or null | |
address.line2 | string or null | |
address.city | string or null | |
address.state | string or null | |
address.postal_code | string or null | |
address.country | string or null | |
metadata | map of strings | |
livemode | boolean | |
created | integer | Unix seconds. |
{
"id": "cu_1a2B3c4D5e6F7g8H9i0J1k2L",
"object": "customer",
"email": "jenny@example.com",
"name": "Jenny Rosen",
"phone": "+15555550123",
"address": {
"line1": "1 Market Street",
"line2": "line2",
"city": "San Francisco",
"state": "CA",
"postal_code": "94105",
"country": "US"
},
"metadata": {
"order": "1001"
},
"livemode": false,
"created": 1762473600
}
POST /v1/customers
Create a customer.
- Scope
customers:write
- Keys
- Secret, or restricted with the scope below.
- Idempotency-Key
- Optional. Without one, Kashu makes one and returns it. See Idempotency.
Parameters
| Name | In | Type | Required | About |
|---|
Idempotency-Key | header | string | Optional | Optional. When absent, Kashu mints one and returns it. Up to 255 characters. |
Kashu-Version | header | string | Optional | The API version to answer in. Defaults to the key's pinned version. |
Request body
| Field | Type | Required | About |
|---|
email | string | Optional | An email address. Up to 254 characters. |
name | string | Optional | Up to 200 characters. |
phone | string | Optional | Up to 40 characters. |
address | object | Optional | |
address.line1 | string | Optional | Up to 200 characters. |
address.line2 | string | Optional | Up to 200 characters. |
address.city | string | Optional | Up to 100 characters. |
address.state | string | Optional | Up to 100 characters. |
address.postal_code | string | Optional | Up to 20 characters. |
address.country | string | Optional | Two capital letters, such as US. |
metadata | map of strings | Optional | Keys up to 40 characters, values up to 500. |
Errors
| Status | Codes |
|---|
| 400 | invalid_json, parameter_missing, parameter_invalid, parameter_unknown, api_version_invalid, idempotency_key_invalid, idempotency_key_reused |
| 401 | api_key_missing, api_key_invalid, api_key_expired |
| 403 | livemode_unavailable, insufficient_scope, publishable_key_not_allowed |
| 409 | idempotency_key_in_use |
| 429 | rate_limited |
| 500 | api_error |
Examples
curl https://api.kashupay.com/v1/customers \
-H "Authorization: Bearer $KASHU_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{"email":"jenny@example.com","name":"Jenny Rosen"}'
const customer = await kashu("POST", "/v1/customers", {
"email": "jenny@example.com",
"name": "Jenny Rosen"
});
console.log(customer.id);
GET /v1/customers
List customers, newest first.
- Scope
customers:read
- Keys
- Secret, or restricted with the scope below.
- Idempotency-Key
- Not used. A read changes nothing.
Parameters
| Name | In | Type | Required | About |
|---|
email | query | string | Optional | Up to 254 characters. |
limit | query | integer | Optional | At least 1. Up to 100. Defaults to 10. |
cursor | query | string | Optional | |
Kashu-Version | header | string | Optional | The API version to answer in. Defaults to the key's pinned version. |
Errors
Examples
curl "https://api.kashupay.com/v1/customers?limit=3" \
-H "Authorization: Bearer $KASHU_SECRET_KEY"
const list = await kashu("GET", "/v1/customers?limit=3");
console.log(list.has_more);
GET /v1/customers/{id}
Retrieve a customer.
- Scope
customers:read
- Keys
- Secret, or restricted with the scope below.
- Idempotency-Key
- Not used. A read changes nothing.
Parameters
| Name | In | Type | Required | About |
|---|
id | path | string | Required | An id that starts cu_. |
Kashu-Version | header | string | Optional | The API version to answer in. Defaults to the key's pinned version. |
Errors
Examples
curl https://api.kashupay.com/v1/customers/cu_1a2B3c4D5e6F7g8H9i0J1k2L \
-H "Authorization: Bearer $KASHU_SECRET_KEY"
const customer = await kashu("GET", "/v1/customers/cu_1a2B3c4D5e6F7g8H9i0J1k2L");
console.log(customer.id);
POST /v1/customers/{id}
Update a customer. A field sent as null is cleared; an address replaces the one held.
- Scope
customers:write
- Keys
- Secret, or restricted with the scope below.
- Idempotency-Key
- Optional. Without one, Kashu makes one and returns it. See Idempotency.
Parameters
| Name | In | Type | Required | About |
|---|
id | path | string | Required | An id that starts cu_. |
Idempotency-Key | header | string | Optional | Optional. When absent, Kashu mints one and returns it. Up to 255 characters. |
Kashu-Version | header | string | Optional | The API version to answer in. Defaults to the key's pinned version. |
Request body
| Field | Type | Required | About |
|---|
email | string or null | Optional | An email address. Up to 254 characters. |
name | string or null | Optional | Up to 200 characters. |
phone | string or null | Optional | Up to 40 characters. |
address | object or null | Optional | |
address.line1 | string | Optional | Up to 200 characters. |
address.line2 | string | Optional | Up to 200 characters. |
address.city | string | Optional | Up to 100 characters. |
address.state | string | Optional | Up to 100 characters. |
address.postal_code | string | Optional | Up to 20 characters. |
address.country | string | Optional | Two capital letters, such as US. |
metadata | map of strings | Optional | Keys up to 40 characters, values up to 500. |
Errors
| Status | Codes |
|---|
| 400 | invalid_json, parameter_missing, parameter_invalid, parameter_unknown, api_version_invalid, idempotency_key_invalid, idempotency_key_reused |
| 401 | api_key_missing, api_key_invalid, api_key_expired |
| 403 | livemode_unavailable, insufficient_scope, publishable_key_not_allowed |
| 404 | resource_missing |
| 409 | idempotency_key_in_use |
| 429 | rate_limited |
| 500 | api_error |
Examples
curl https://api.kashupay.com/v1/customers/cu_1a2B3c4D5e6F7g8H9i0J1k2L \
-H "Authorization: Bearer $KASHU_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"Jenny Rosen"}'
const customer = await kashu("POST", "/v1/customers/cu_1a2B3c4D5e6F7g8H9i0J1k2L", {
"name": "Jenny Rosen"
});
console.log(customer.id);