Guide

Ordering

Use this guide to build a complete ordering flow: create orders, track status, update details, and cancel when needed.

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_id ties the order to a customer.
  • order_id is required for updates, status checks, and cancellation.
  • Order statuses move from queued to delivered.

Order flow

  1. Call POST /orders with bread, peanut butter, and jelly.
  2. Read the order_id from the response.
  3. Poll GET /orders/{order_id} for status updates.
  4. Use PUT /orders/{order_id} to change a recently placed order while it remains in queued or prepping status.
  5. Cancel with DELETE /orders/{order_id} if needed.
queued prepping toasting ready delivered

Best practices

  • Store the order_id in your order confirmation screen.
  • Refresh status every 15 to 30 seconds to avoid rate limits.
  • Allow cancellation only when the status is queued or prepping.
  • Show a friendly fallback if the order is canceled or not found.
  • Use extras for add-ons like banana_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"
  }
}