Guide

Customer accounts

Create customer profiles and tie every order to a consistent customer_id for history and reorders.

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_id across apps and kiosks.

Account flow

  1. Create a customer profile with POST /customers.
  2. Store the returned customer_id in your customer record.
  3. Use customer_id for every order.
  4. List order history with GET /customers/{customer_id}/orders.

Best practices

  • Validate emails on the client before sending requests.
  • Keep customer_id in 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"
}