Guide
Ordering
Use this guide to build a complete ordering flow: create orders, track status, update details, and cancel when needed.
Endpoints
Order lifecycle
Overview
What this guide covers
You will learn how to create an order with the Create order endpoint, track it with Get an order, and adjust details with Update an order. Use Cancel an order to stop processing before the order leaves the kitchen.
Key identifiers
customer_idties the order to a customer.order_idis required for updates, status checks, and cancellation.- Order statuses move from
queuedtodelivered.
Order flow
- Call POST /orders with bread, peanut butter, and jelly.
- Read the
order_idfrom the response. - Poll GET /orders/{order_id} for status updates.
- Use PUT /orders/{order_id} to change a recently placed order while it remains in queued or prepping status.
- Cancel with DELETE /orders/{order_id} if needed.
queued
prepping
toasting
ready
delivered
Best practices
- Store the
order_idin your order confirmation screen. - Refresh status every 15 to 30 seconds to avoid rate limits.
- Allow cancellation only when the status is
queuedorprepping. - Show a friendly fallback if the order is
canceledor not found. - Use
extrasfor add-ons likebanana_slices.
Example request and response
Requests
curl -X POST https://api.pbandj.io/v1/orders \
-H "Content-Type: application/json" \
-H "X-API-Key: pbj_test_8dd1f2" \
-d '{
"customer_id": "cus_2048",
"bread": "brioche",
"peanut_butter": "smooth",
"jelly": "grape",
"toast": "light",
"cut": "halves",
"extras": ["banana_slices"]
}'
const response = await fetch('https://api.pbandj.io/v1/orders', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': 'pbj_test_8dd1f2',
},
body: JSON.stringify({
customer_id: 'cus_2048',
bread: 'brioche',
peanut_butter: 'smooth',
jelly: 'grape',
toast: 'light',
cut: 'halves',
extras: ['banana_slices'],
}),
});
const data = await response.json();
console.log(data);
import requests
response = requests.post(
"https://api.pbandj.io/v1/orders",
headers={"X-API-Key": "pbj_test_8dd1f2"},
json={
"customer_id": "cus_2048",
"bread": "brioche",
"peanut_butter": "smooth",
"jelly": "grape",
"toast": "light",
"cut": "halves",
"extras": ["banana_slices"],
},
)
print(response.json())
Responses
{
"order_id": "ord_55c1",
"customer_id": "cus_2048",
"status": "queued",
"eta_minutes": 6,
"choices": {
"bread": "brioche",
"peanut_butter": "smooth",
"jelly": "grape",
"extras": ["banana_slices"]
}
}
{
"error": "out_of_stock",
"message": "Grape jelly is out of stock.",
"item": {
"type": "jelly",
"option": "grape"
}
}