Guide
Customer accounts
Create customer profiles and tie every order to a consistent customer_id for history and
reorders.
Endpoints
Customer flow
Overview
What this guide covers
Use POST /customers to create profiles, then pass
customer_id to POST /orders to keep order history intact.
You can list recent activity with GET /customers/{customer_id}/orders.
Profile essentials
- Store a display name and preferred pickup location.
- Save preferences like favorite bread and jelly.
- Reuse
customer_idacross apps and kiosks.
Account flow
- Create a customer profile with POST /customers.
- Store the returned
customer_idin your customer record. - Use
customer_idfor every order. - List order history with GET /customers/{customer_id}/orders.
Best practices
- Validate emails on the client before sending requests.
- Keep
customer_idin a secure profile store. - Let customers update preferences to speed up checkout.
Example request and response
Requests
curl -X POST https://api.pbandj.io/v1/customers \
-H "Content-Type: application/json" \
-H "X-API-Key: pbj_test_8dd1f2" \
-d '{
"name": "Avery Simmons",
"email": "avery@diner.dev",
"favorite_bread": "sourdough",
"favorite_jelly": "strawberry"
}'
const response = await fetch('https://api.pbandj.io/v1/customers', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': 'pbj_test_8dd1f2',
},
body: JSON.stringify({
name: 'Avery Simmons',
email: 'avery@diner.dev',
favorite_bread: 'sourdough',
favorite_jelly: 'strawberry',
}),
});
const data = await response.json();
console.log(data);
import requests
response = requests.post(
"https://api.pbandj.io/v1/customers",
headers={"X-API-Key": "pbj_test_8dd1f2"},
json={
"name": "Avery Simmons",
"email": "avery@diner.dev",
"favorite_bread": "sourdough",
"favorite_jelly": "strawberry",
},
)
print(response.json())
Responses
{
"customer_id": "cus_2048",
"name": "Avery Simmons",
"email": "avery@diner.dev",
"favorite_bread": "sourdough",
"favorite_jelly": "strawberry"
}
{
"error": "invalid_email",
"message": "Email address must be valid.",
"field": "email"
}