@dunbackmeadow/commerce-sdk 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,429 +1,467 @@
1
- # Dunback Meadow Partner API v1
2
-
3
- | | |
4
- | --- | --- |
5
- | Base URL | `https://dunbackmeadow.com/api/partner/v1` |
6
- | Sandbox | `https://sandbox.dunbackmeadow.com/api/partner/v1` |
7
- | Auth | `Authorization: Bearer dbk_live_<appId>_<secret>` (server-to-server only) |
8
- | Keys | Created per app and environment in the Developer Dashboard: <https://dunbackmeadow.com/developer> |
9
- | Format | JSON in and out. Money is in USD; USDC is 1:1. |
10
-
11
- Each environment accepts only its own keys: `dbk_test_` in the sandbox,
12
- `dbk_live_` in production. Anything else gets `401 wrong_environment`.
13
-
14
- | Status | code | Meaning |
15
- | --- | --- | --- |
16
- | 401 | `unauthorized` | Missing, malformed or deleted key |
17
- | 401 | `wrong_environment` | A key from the other environment |
18
- | 403 | `partner_disabled` | The app was deleted or the account isn't active |
19
-
20
- **Errors** use one shape:
21
-
22
- ```json
23
- { "error": { "code": "invalid_request", "message": "…", "details": {} } }
24
- ```
25
-
26
- **Idempotency.** For POST requests, send `Idempotency-Key: <unique>`.
27
- Replays return the original response with `Idempotent-Replayed: true`. Reusing a
28
- key with a different body returns `422 idempotency_mismatch`. Keys are kept for
29
- 24 h.
30
-
31
- ---
32
-
33
- ## App
34
-
35
- ### `GET /me`
36
-
37
- The app and environment the key belongs to.
38
-
39
- ```json
40
- { "object": "app", "id": "app-k3m9x2q7w4ze", "name": "Event catering", "mode": "test",
41
- "webhookUrl": "https://api.example.com/webhooks/dunback", "allowedReturnHosts": ["example.com"] }
42
- ```
43
-
44
- ---
45
-
46
- ## Catalog
47
-
48
- ### `GET /catalog/restaurants?city=&state=&zip=&q=`
49
-
50
- Restaurants a host can name (`restaurantName` on a catering request) instead of
51
- choosing a cuisine. With the venue, only restaurants in its metro area; `q`
52
- filters by name. Returns `{ data: [{ name, cuisine, secondaryCuisine }], scope, metro }`.
53
- When the host names a restaurant, don't offer a cuisine picker: every option
54
- comes from that restaurant.
55
-
56
- ### `GET /catalog/cuisines?city=&state=&zip=&guests=&serviceStyle=`
57
-
58
- Pass the event venue (`zip`, or `city` + `state`) to count only restaurants in
59
- the venue's metro area, the ones that can cater there. Without it, counts
60
- cover the whole platform. Pass `guests` (expected guests, a whole number) to
61
- count only restaurants whose catering policies allow that many (and
62
- `serviceStyle` to count only those serving catering that way): most guests
63
- per order, and a minimum order that many guests are likely to reach. The
64
- response then includes `"guests"`, and each cuisine a `noticeHours`: the least
65
- advance notice one of its restaurants needs for that many guests (0: none;
66
- `null`: no restaurant). SDK: `listCuisines(venue?, { guests? })`,
67
- or `cuisineCatalog(venue?, { guests? })` for the metro too.
68
-
69
- ```json
70
- {
71
- "object": "list",
72
- "data": [
73
- { "id": "mexican", "label": "Mexican", "restaurants": 4 },
74
- { "id": "custom:peruvian", "label": "Peruvian", "restaurants": 1, "custom": true }
75
- ],
76
- "scope": "metro",
77
- "metro": { "id": "sf-bay-area", "name": "San Francisco Bay Area" }
78
- }
79
- ```
80
-
81
- | Field | Notes |
82
- | --- | --- |
83
- | `scope` | `metro` with a venue, `platform` without |
84
- | `metro` | The venue's metro area. `null` without a venue, or when Dunback doesn't serve that area (then every count is 0) |
85
-
86
- Standard cuisine ids, always listed: `american`, `chinese`, `mexican`,
87
- `italian`, `japanese`, `indian`, `thai`, `mediterranean`, `korean`,
88
- `vietnamese`.
89
-
90
- Restaurants can also declare a cuisine of their own. Such cuisines are listed
91
- after the standard ones as `custom:<name>` (e.g. `custom:peruvian`, label
92
- "Peruvian", `custom: true`), and only where at least one restaurant in scope
93
- serves them. Hosts can pick them like any other: send the `id` as `cuisine`.
94
-
95
- ---
96
-
97
- ## Catering requests
98
-
99
- ### `POST /catering/requests` → `202` CateringRequest (status `COMPOSING`)
100
-
101
- | Field | Type | Notes |
102
- | --- | --- | --- |
103
- | `partnerReference` | string, required | Your id, e.g. `luma:evt-AbC123` |
104
- | `event.name` | string, required | |
105
- | `event.startsAt` | ISO 8601, required | Must be in the future |
106
- | `event.timeZone` | IANA, required | Venue time zone |
107
- | `event.url` | URL | |
108
- | `deliveryDeadlineLocal` | `YYYY-MM-DDTHH:mm` | Default: `startsAt` minus 30 min, venue-local |
109
- | `restaurantName` | string | A restaurant the host prefers (`/catalog/restaurants`): all options come from it. Part of a name matches every location; small misspellings are tolerated when no restaurant matches exactly (`restaurant.closeMatch: true`). Send it or `cuisine`, not both. If it can't cater, `restaurant.available` is false and `restaurant.reason` says why; the options are from other restaurants |
110
- | `cuisine` | cuisine id | A standard id or a `custom:…` id from `/catalog/cuisines`. Required unless you send `restaurantName`, `dishPreferences` or `mealType: "breakfast"` (then any cuisine) |
111
- | `serviceStyle` | `buffet` or `meal_boxes` | How food is served. `buffet`: trays and platters to share, from restaurants with catering dishes. `meal_boxes`: one packed meal per guest from restaurants' regular dishes (more dishes, usually more restaurants). Default `meal_boxes`. |
112
- | `includeDrinks` | bool | Default true. Non-alcoholic only. |
113
- | `dishPreferences` | string[], up to 8 | Kinds of dishes the host wants: `"sushi"`, `"seafood"`, `"pastries"`, `"bagels"`, `"tacos"`… The mains come from dishes that match (name, description, category, tags; `"seafood"` also by a fish or shellfish allergen), and only restaurants with such dishes take part. A guest none of them is safe for gets another safe main (`allergyCoverage[].outsidePreferences: true`) |
114
- | `mealType` | `breakfast`, `lunch` or `dinner` | The kind of food, whatever the delivery time. Breakfast food: dishes in the restaurant's breakfast or brunch menu, or that read like breakfast (pastries, bagels, egg dishes, oatmeal, fruit platters…). Without it, a delivery before 10:30 prefers breakfast food without requiring it |
115
- | `spicyShare` | number 0–1 | About this share of the main servings spicy (`0.33` = a third; `0` = nothing spicy). Spicy: the restaurant's spice level 2 or more, or, without a level, the dish's wording ("spicy", "Sichuan", "jalapeño"…) |
116
- | `partyDiet` | array of `vegetarian`, `vegan`, `halal`, `kosher`, `gluten_free`, `dairy_free`, `pescatarian` | Every guest's food must fit, as if each guest had said so (an all-vegetarian event) |
117
- | `maxTotal` | number, USD | Hard budget for the order: options priced above it are not offered. Compared with what the host would pay (the card total; the USDC total at a restaurant that takes no card). See `budget` below |
118
- | `maxPerGuest` | number, USD | Hard budget per guest, like `maxTotal` |
119
- | `budgetPerGuest` | number | Soft: only flags options above it (`withinBudget: false`) |
120
- | `deliveryAddress` | `{address1, address2?, city, state?, zip, country?}`, required | |
121
- | `onsiteContact` | `{name, phone, email?}`, required | Receives the delivery |
122
- | `deliveryNotes` | string | |
123
- | `host` | `{name, email, phone?}`, required | |
124
- | `attendees[]` | 1–1000, required | `{externalId?, name, email?, phone?, allergies?, dietaryPreferences?, allergyConsent?}` |
125
-
126
- A request may list up to 1000 guests; more fails with `400 invalid_request`.
127
-
128
- `email` and `phone` are optional for every guest. `allergyConsent: true` is
129
- required for each guest whose `allergies` or `dietaryPreferences` says more than
130
- "none": it records that the guest agreed to share those notes with Dunback and
131
- the restaurant. Otherwise the request fails with `400 allergy_consent_required`,
132
- and `error.details.guests` lists `{ index, externalId, name }` for each guest
133
- concerned.
134
-
135
- Dunback delivers only where it has launched. A delivery address outside the
136
- launched areas fails with `422 delivery_area_not_launched`; the message names
137
- the metro areas Dunback covers. Requests for more than 5 guests are checked
138
- against the areas launched for catering, smaller ones against the areas
139
- launched for individual delivery.
140
-
141
- Composing usually takes 5–30 s. When it finishes, you receive the
142
- `catering.options_ready`, `catering.no_options` or `catering.failed` webhook.
143
-
144
- ### `GET /catering/requests/:id` → CateringRequest
145
-
146
- ### `GET /catering/requests?partnerReference=…` → `{ data: CateringRequest[] }` (newest first)
147
-
148
- ### CateringRequest
149
-
150
- | Field | Notes |
151
- | --- | --- |
152
- | `id` | `creq_…` |
153
- | `object` | `"catering_request"` |
154
- | `status` | `COMPOSING`, `OPTIONS_READY`, `NO_OPTIONS`, `SELECTED` or `FAILED` |
155
- | `partnerReference`, `event`, `cuisine`, `guestCount` | As sent; `event` gains `startsAtLocal` |
156
- | `dishPreferences`, `mealType`, `spicyShare`, `partyDiet`, `maxTotal`, `maxPerGuest` | As sent (`[]` / `null` when not) |
157
- | `budget` | With `maxTotal` / `maxPerGuest` only: `{ maxTotal, maxPerGuest, limit, withinBudget, overBudget, suggestedMaxTotal, suggestedMaxPerGuest, message }`. When the budget leaves fewer than three options, `message` says so and how far to raise it for three ("Only 2 catering offers fit your budget of $1,000. Raising your budget to about $1,150 would give you 3 offers to choose from."). **Show `message` to the host.** |
158
- | `deliveryDeadlineLocal`, `timeZone`, `daypart` | |
159
- | `allergySummary` | `[{ constraint, guests: [names] }]` |
160
- | `options` | Up to 3, each from one restaurant; from different restaurants when several can cater. See below |
161
- | `unavailableReasons` | `[{ name, code, reason }]` when `NO_OPTIONS`. `code`: `party_too_large`, `below_minimum_order`, `notice_too_short`, `no_buffet_dishes`, `style_not_offered`, `outside_delivery_area`, `not_serving_then`, `different_cuisine`, `no_matching_dishes` (none of the dishes asked for), `over_budget` or `restaurant_declined` (more may be added) |
162
- | `orderId` | Set once an option is selected |
163
- | `error` | `{ code, message }`, when `FAILED` |
164
- | `createdAt`, `updatedAt` | |
165
-
166
- Each option:
167
-
168
- How the food is served is the host's choice (`serviceStyle`):
169
-
170
- - `buffet`: trays and platters guests share. Only restaurants with catering
171
- dishes for mains take part; their trays come first, single portions only
172
- fill in.
173
- - `meal_boxes` (default): one individually packed meal per guest, which
174
- guests pick up themselves. Any restaurant's single portions qualify (no
175
- trays), so there are more dishes to choose from and usually more
176
- restaurants. A restaurant can opt out of packing meal boxes.
177
-
178
- Each option repeats its `serviceStyle`, and the restaurant's order says how to pack it.
179
-
180
- Restaurants may set their own catering policies: the most guests they cater
181
- for in one order, a minimum order (food subtotal), free delivery at or above a
182
- food subtotal, and advance notice by party size (e.g. more than 20 guests: 24
183
- hours, more than 50: 72 hours). Each is optional. Dunback only offers options
184
- that meet them: a restaurant that can't take the party, or needs more notice
185
- than is left, is left out; an option slightly under a restaurant's minimum gets
186
- shared sides or desserts added (`addedForMinimum`); `orderBy` is moved earlier
187
- to the notice the restaurant needs. Free delivery shows as a `Free delivery`
188
- price line of 0.
189
-
190
- Restaurants that specialize in catering list catering dishes: trays and
191
- platters that serve several people. Dunback composes with those first and adds
192
- single portions only where needed (guests no tray suits, or a few guests left
193
- over). Such an item has `serves`: `quantity` counts trays and `unitPrice` is
194
- per tray, so 2 trays with `serves: 8` feed 16 guests.
195
-
196
- | Field | Notes |
197
- | --- | --- |
198
- | `id` | `opt_1` … `opt_3` |
199
- | `title` | |
200
- | `strategy` | `favorites`, `value` or `variety` |
201
- | `restaurant` | `{ name, distanceMiles, imageUrl, policies: { minimumOrder, maxGuests, freeDeliveryOver, noticeTiers: [{ overGuests, hours }] } }`; each policy is `null` when the restaurant has none |
202
- | `freeDeliveryShortfall` | Food (USD) to add for the restaurant's free delivery; `null` when delivery is already free or there's no such policy |
203
- | `items[]` | `{ name, description, imageUrl, role: "main"\|"drink"\|"extra", quantity, unitPrice, allergens, dietaryTags, serves?, addedForMinimum? }`. Each dish appears once with its full quantity: Dunback has no per-dish limit. `serves`: a catering dish (tray) serving that many people per unit; `quantity` and `unitPrice` are then per tray. `addedForMinimum`: a shared dish added to reach the restaurant's minimum order. |
204
- | `allergyCoverage[]` | `{ constraint, guests, dishes }` |
205
- | `unfedGuests[]` | `{ constraint, guests: [names], what? }`: guests with no dish known to be safe |
206
- | `price` | See Price |
207
- | `withinBudget` | Present when a budget was set |
208
- | `acceptsCard` | `false` when the restaurant hasn't set up card payments on Dunback (its Stripe account): the option can then only be paid in USDC |
209
- | `paymentMethods` | `["stripe","usdc"]`, or `["usdc"]` when `acceptsCard` is false |
210
- | `orderBy` | ISO; latest payment time the restaurant accepts |
211
-
212
- ### Price
213
-
214
- | Field | Notes |
215
- | --- | --- |
216
- | `currency` | `"USD"` |
217
- | `lines[]` | `{ code, label, amount }`. `code` is `food`, `delivery`, `restaurant_fee`, `tax`, `platform_fee` or `service_fee`. |
218
- | `dunbackServiceFee` | The host's service fee: `serviceFeeRate` × (food and drinks + the restaurant's service charge). Delivery and tax are not included. |
219
- | `serviceFeeRate` | Dunback's service fee rate on catering orders (`0.05` = 5%) |
220
- | `totals` | `{ usdc, card, cardProcessingFee }` |
221
- | `perGuest` | `{ usdc, card }` |
222
-
223
- The card total is the USDC total grossed up for card processing.
224
-
225
- ### `POST /catering/requests/:id/select` → `201` Order
226
-
227
- | Field | Notes |
228
- | --- | --- |
229
- | `optionId` | required |
230
- | `payer` | `{ name?, email? }` (pre-fills Stripe) |
231
- | `paymentMethods` | `["stripe","usdc"]` (default both). `stripe` is left out when the option's `acceptsCard` is false. |
232
- | `successUrl`, `cancelUrl` | Stripe return URLs: https, on your registered hosts. The hosted payment page links back to them ("Back to the event": `cancelUrl` before payment, `successUrl` after) |
233
-
234
- Errors:
235
-
236
- | Status | code | Meaning |
237
- | --- | --- | --- |
238
- | 409 | `invalid_state` | Already selected, or not ready |
239
- | 409 | `order_deadline_passed` | Too late for the restaurant to make the event time |
240
- | 409 | `card_payments_unavailable` | Only `stripe` was asked for, and this restaurant can't take card payments (`acceptsCard: false`). Offer USDC or another option. |
241
- | 409 | `restaurant_*` | The restaurant can't take it now |
242
-
243
- ---
244
-
245
- ## Orders
246
-
247
- ### Order
248
-
249
- | Field | Notes |
250
- | --- | --- |
251
- | `id` | `ord_…` |
252
- | `object` | `"order"` |
253
- | `status` | `AWAITING_PAYMENT`, `PAID`, `FULFILLING`, `CONFIRMED`, `EXPIRED`, `CANCELLED`, `REFUNDED`, `REFUND_PENDING` or `NEEDS_ATTENTION`. A `CONFIRMED` order becomes `REFUNDED` / `REFUND_PENDING` when all its deliveries failed (see Refunds) |
254
- | `title`, `summary`, `restaurant`, `deliveryDeadlineLocal`, `timeZone`, `guestCount` | |
255
- | `delivery` | `{ address: {address1, address2, city, state, zip, country}, onsiteContact: {name, phone}, deliveryNotes, editable }`. `deliveryNotes` is your note only. `editable` is true while the order is `AWAITING_PAYMENT`. |
256
- | `items`, `allergyCoverage`, `unfedGuests`, `price` | Same shapes as the option |
257
- | `payment` | See below |
258
- | `fulfillment` | `{ restaurantOrderIds, providerPayment, confirmedAt }`. `providerPayment` is how Dunback paid the restaurant: `{ method: "usdc_x402", amount, payTo, txHash, verifiedOnChain, network }` for a USDC order, or `{ method: "stripe_connect", status: "PAID"\|"PENDING" }` for a card order (paid through the restaurant's own Stripe account) |
259
- | `refund` | The latest refund: `{ status: "SUCCEEDED"\|"PENDING", method, amount, note? }` |
260
- | `refunds` | Every refund: `[{ amount, method, status, reason, detail, at, restaurantOrderId? }]`. `reason` is `cancel`, `failed`, `cancelled` (by the restaurant), `late` or `not_delivered` |
261
- | `cancellation` | The cancellation and refund policy as it applies now; see Cancellation and refund policy |
262
- | `lateRefund` | `{ afterMinutes, requestableFrom }`: a delivery `afterMinutes` or more late can get a refund request; offer it only from `requestableFrom` |
263
- | `error` | `{ code, message }` |
264
-
265
- `payment` holds:
266
-
267
- | Field | Notes |
268
- | --- | --- |
269
- | `expiresAt` | ISO |
270
- | `hostedPaymentUrl` | Dunback page offering every method; safe to give the payer |
271
- | `stripe` | `{ checkoutUrl, amount, currency: "usd" }` |
272
- | `usdc.network`, `usdc.chainId` | `"polygon"`, `137` |
273
- | `usdc.asset` | USDC contract on Polygon |
274
- | `usdc.receiver` | Dunback's receiving address |
275
- | `usdc.amount`, `usdc.amountAtomic` | Exact amount, e.g. `"412.380317"` and `"412380317"` |
276
- | `usdc.paymentUri` | `ethereum:…` (EIP-681) |
277
- | `usdc.note` | |
278
- | `usdc.x402Url` | For agents |
279
- | `received` | `{ method: "stripe"\|"usdc"\|"x402", amount, currency, reference, payer?, at }` |
280
- | `lastError` | `{ method, code, message, at }` |
281
-
282
- The links (`hostedPaymentUrl`, `stripe`, `usdc`) are present while the status
283
- is `AWAITING_PAYMENT`.
284
-
285
- ### `GET /orders/:id` → Order
286
-
287
- This also re-checks Stripe for open card payments.
288
-
289
- ### `POST /orders/:id/usdc/confirm` `{ txHash }` → Order
290
-
291
- Verifies a Polygon USDC transfer to `payment.usdc.receiver`. The amount must
292
- be ≥ the USDC total; the exact tagged amount isn't required when you supply the
293
- hash. The call waits up to 60 s for the restaurant to confirm.
294
-
295
- | Status | code |
296
- | --- | --- |
297
- | 409 | `payment_pending` |
298
- | 400 | `payment_not_found` |
299
- | 400 | `payment_amount_short` |
300
- | 409 | `payment_already_used` |
301
-
302
- ### `POST /orders/:id/delivery` → Order
303
-
304
- Corrects the delivery details before payment. The payer can do the same on the
305
- hosted payment page (`hostedPaymentUrl`).
306
-
307
- | Field | Type | Notes |
308
- | --- | --- | --- |
309
- | `deliveryAddress` | `{address1, address2?, city, state?, zip, country?}`, required | |
310
- | `onsiteContact` | `{name, phone}` | Leave out to keep the current contact |
311
- | `deliveryNotes` | string, up to 500 | Replaces the current note; default `""` |
312
-
313
- The price stays as quoted, so the correction is checked:
314
-
315
- | Status | code | Meaning |
316
- | --- | --- | --- |
317
- | 409 | `invalid_state` | The order isn't `AWAITING_PAYMENT` |
318
- | 422 | `delivery_area_not_launched` | Dunback doesn't deliver to that area yet |
319
- | 422 | `outside_delivery_area` | The restaurant doesn't deliver to that address |
320
- | 422 | `address_moved` | More than about a mile from the quoted address: create a new catering request |
321
- | 422 | `contact_incomplete` | A required field is missing |
322
-
323
- On success you also receive the `order.delivery_updated` webhook.
324
-
325
- ### `POST /orders/:id/cancel` `{ reason?, acceptPostCommitment? }` → Order
326
-
327
- | Order status | Result |
328
- | --- | --- |
329
- | `AWAITING_PAYMENT` | Cancels the payment links |
330
- | `CONFIRMED`, before the commitment deadline | Cancels at the restaurant and refunds the restaurant's full amount (card automatically, USDC after review) |
331
- | `CONFIRMED`, after the commitment deadline, before delivery | Requires `"acceptPostCommitment": true` (else `409 post_commitment_confirmation_required`, with `details.cancellation`). Cancels at the restaurant; Dunback decides the refund (`order.refund_decided`) |
332
- | Otherwise | `409 cancel_refused` or `409 invalid_state` |
333
-
334
- ### Cancellation and refund policy
335
-
336
- Dunback applies one cancellation and refund policy to every catering order,
337
- whatever the restaurant's own policy elsewhere:
338
-
339
- - **Before the commitment deadline:** the host may cancel and is refunded the
340
- restaurant's full amount (food, delivery, restaurant fees and taxes).
341
- Dunback's service fee and commission are kept.
342
- - **After the commitment deadline, until delivery:** the host may still cancel
343
- (for example, the event is called off). The restaurant may already have
344
- bought or prepared food, so Dunback decides the refund with the restaurant,
345
- from nothing up to that full amount, and sends it. You get
346
- `order.refund_decided` with the decision and Dunback's explanation (and
347
- `order.refunded` when money moves); the host is emailed too.
348
-
349
- Every order carries `cancellation`:
350
-
351
- | Field | Meaning |
352
- | --- | --- |
353
- | `policy` | The policy in one paragraph. **Show it with the order.** Options carry the same text as `cancellationPolicy`. |
354
- | `phase` | `unpaid`, `before_commitment`, `after_commitment` or `closed` |
355
- | `notice` | What cancelling now means. **Show it again, and get the host's confirmation, before you call cancel.** |
356
- | `commitmentDeadlineUtc`, `deliveryDeadlineUtc` | ISO instants |
357
- | `refundIfCancelledNow` | `{ kind: "restaurant_full_refund", amount }`, `{ kind: "decided_by_dunback", maximum }` or null |
358
- | `requiresAcceptPostCommitment` | true after the commitment deadline |
359
-
360
-
361
- ### `POST /orders/:id/refund-requests` `{ restaurantOrderId?, reason, impact }` → 202
362
-
363
- For a catering delivery made at or after Dunback's catering late-delivery
364
- threshold (60 minutes by default; Dunback may change it). You receive
365
- `order.delivered_late` (the order, plus `lateDeliveries` and
366
- `lateRefundPolicy`) when that happens; show the policy and let the host ask.
367
-
368
- - `reason` (required): why the host is asking for a refund.
369
- - `impact` (required): how the late delivery affected the event.
370
- - Late deliveries are not refunded automatically. Dunback reviews the request
371
- and decides the refund at its discretion, from nothing up to the
372
- restaurant's part of that delivery; Dunback's service fee and commission are
373
- not refunded. You get `order.refund_decided` with the decision (and
374
- `order.refunded` if anything is refunded); the host is emailed.
375
- - Errors: `409 not_late`, `409 already_requested`, `409 request_window_closed`
376
- (30 days after delivery), `400 invalid_request`.
377
-
378
- ### Refunds
379
-
380
- | What happened | Refund | Webhook |
381
- | --- | --- | --- |
382
- | The host cancels before the commitment deadline (`POST /orders/:id/cancel`) | The restaurant's part of the order. Dunback's commission and service fee are kept. A card payment's processing fee is not refunded (Stripe keeps it). | `order.cancelled` |
383
- | The host cancels after the commitment deadline, before delivery (`acceptPostCommitment: true`) | What Dunback decides with the restaurant: 0% to 100% of the restaurant's part | `order.cancelled`, then `order.refund_decided` (and `order.refunded` if anything is refunded) |
384
- | The restaurant couldn't take the order after payment | Everything the host paid | `order.failed` |
385
- | A delivery failed, or was cancelled by the restaurant | Everything the host paid for that delivery, card processing fee included | `order.refunded` |
386
- | A delivery was at or after the catering late-delivery threshold, and the host requested a refund | What Dunback decides: 0% to 100% of the restaurant's part of that delivery | `order.refund_decided` (and `order.refunded`) |
387
-
388
- Card payments are always refunded to the card; USDC refunds are sent to the
389
- paying address after review. `refunds` lists every refund of the order;
390
- `refund` is the latest one. When every delivery of an order failed, the order
391
- becomes `REFUNDED` (or `REFUND_PENDING` while a refund is still due); when only
392
- some did, it stays `CONFIRMED` and `order.refunded` tells you about each refund.
393
-
394
- ### `POST /orders/:id/pay/x402?t=<token>` (x402 resource; no API key, the URL is `payment.usdc.x402Url`)
395
-
396
- 1. Without `PAYMENT-SIGNATURE`, the endpoint returns
397
- `402 Payment Required` with a `PAYMENT-REQUIRED` header: base64 JSON
398
- `{ x402Version: 2, accepts: [{ scheme: "exact", network: "eip155:137", amount, asset, payTo, maxTimeoutSeconds, extra: { name: "USD Coin", version: "2" } }] }`.
399
- 2. Retry with
400
- `PAYMENT-SIGNATURE: base64({ x402Version: 2, scheme: "exact", network, accepted, payload: { authorization, signature } })`.
401
- The payload is an EIP-3009 `TransferWithAuthorization`. It is verified and
402
- settled by Dunback's facilitator.
403
- 3. On success the response is `200` with the Order and a `PAYMENT-RESPONSE`
404
- header. If the payment is rejected, you get `402` with `{ error: { code, message } }`.
405
-
406
- ---
407
-
408
- ## Webhooks
409
-
410
- `POST` to your URL with this body:
411
-
412
- ```json
413
- { "id": "evt_…", "type": "order.confirmed", "created": 1763000000, "data": { … } }
414
- ```
415
-
416
- The `Dunback-Signature: t=<unix>,v1=<hex>` header is
417
- `HMAC-SHA256(webhookSecret, "<t>.<raw body>")`. Reject anything older than
418
- 5 minutes. Answer with a 2xx; anything else is retried after 1 s, 5 s and 25 s.
419
-
420
- | Event | `data` |
421
- | --- | --- |
422
- | `catering.options_ready`, `catering.no_options`, `catering.failed` | CateringRequest |
423
- | `order.created`, `order.confirmed`, `order.payment_failed`, `order.expired`, `order.failed`, `order.needs_attention`, `order.cancelled`, `order.refunded`, `order.delivery_updated` | Order |
424
- | `order.refund_decided` | Order plus `refundDecision: { restaurantOrderId, basis, percentage, amount, explanation, refund }` |
425
- | `order.delivered_late` | Order plus `lateDeliveries: [{ restaurantOrderId, lateMinutes }]` and `lateRefundPolicy` |
426
- | `ping` | `{ object: "ping", appId, message }`, plus top-level `livemode`. Sent by **Send test event** in the Developer Dashboard. |
427
-
428
- The webhook URL, its signing secret (reveal or roll) and the allowed return
429
- hosts are set per app and environment in the Developer Dashboard.
1
+ # Dunback Meadow Partner API v1
2
+
3
+ | | |
4
+ | --- | --- |
5
+ | Base URL | `https://dunbackmeadow.com/api/partner/v1` |
6
+ | Sandbox | `https://sandbox.dunbackmeadow.com/api/partner/v1` |
7
+ | Auth | `Authorization: Bearer dbk_live_<appId>_<secret>` (server-to-server only) |
8
+ | Keys | Created per app and environment in the Developer Dashboard: <https://dunbackmeadow.com/developer> |
9
+ | Format | JSON in and out. Money is in USD; USDC is 1:1. |
10
+
11
+ Each environment accepts only its own keys: `dbk_test_` in the sandbox,
12
+ `dbk_live_` in production. Anything else gets `401 wrong_environment`.
13
+
14
+ | Status | code | Meaning |
15
+ | --- | --- | --- |
16
+ | 401 | `unauthorized` | Missing, malformed or deleted key |
17
+ | 401 | `wrong_environment` | A key from the other environment |
18
+ | 403 | `partner_disabled` | The app was deleted or the account isn't active |
19
+
20
+ **Errors** use one shape:
21
+
22
+ ```json
23
+ { "error": { "code": "invalid_request", "message": "…", "details": {} } }
24
+ ```
25
+
26
+ **Idempotency.** For POST requests, send `Idempotency-Key: <unique>`.
27
+ Replays return the original response with `Idempotent-Replayed: true`. Reusing a
28
+ key with a different body returns `422 idempotency_mismatch`. Keys are kept for
29
+ 24 h.
30
+
31
+ ---
32
+
33
+ ## App
34
+
35
+ ### `GET /me`
36
+
37
+ The app and environment the key belongs to.
38
+
39
+ ```json
40
+ { "object": "app", "id": "app-k3m9x2q7w4ze", "name": "Event catering", "mode": "test",
41
+ "webhookUrl": "https://api.example.com/webhooks/dunback", "allowedReturnHosts": ["example.com"] }
42
+ ```
43
+
44
+ ---
45
+
46
+ ## Catalog
47
+
48
+ ### `GET /catalog/restaurants?city=&state=&zip=&q=`
49
+
50
+ Restaurants a host can name (`restaurantName` on a catering request) instead of
51
+ choosing a cuisine. With the venue, only restaurants in its metro area; `q`
52
+ filters by name. Returns `{ data: [{ name, cuisine, secondaryCuisine }], scope, metro }`.
53
+ When the host names a restaurant, don't offer a cuisine picker: every option
54
+ comes from that restaurant.
55
+
56
+ ### `GET /catalog/cuisines?city=&state=&zip=&guests=&serviceStyle=`
57
+
58
+ Pass the event venue (`zip`, or `city` + `state`) to count only restaurants in
59
+ the venue's metro area, the ones that can cater there. Without it, counts
60
+ cover the whole platform. Pass `guests` (expected guests, a whole number) to
61
+ count only restaurants whose catering policies allow that many (and
62
+ `serviceStyle` to count only those serving catering that way): most guests
63
+ per order, and a minimum order that many guests are likely to reach. The
64
+ response then includes `"guests"`, and each cuisine a `noticeHours`: the least
65
+ advance notice one of its restaurants needs for that many guests (0: none;
66
+ `null`: no restaurant). SDK: `listCuisines(venue?, { guests? })`,
67
+ or `cuisineCatalog(venue?, { guests? })` for the metro too.
68
+
69
+ ```json
70
+ {
71
+ "object": "list",
72
+ "data": [
73
+ { "id": "mexican", "label": "Mexican", "restaurants": 4 },
74
+ { "id": "custom:peruvian", "label": "Peruvian", "restaurants": 1, "custom": true }
75
+ ],
76
+ "scope": "metro",
77
+ "metro": { "id": "sf-bay-area", "name": "San Francisco Bay Area" }
78
+ }
79
+ ```
80
+
81
+ | Field | Notes |
82
+ | --- | --- |
83
+ | `scope` | `metro` with a venue, `platform` without |
84
+ | `metro` | The venue's metro area. `null` without a venue, or when Dunback doesn't serve that area (then every count is 0) |
85
+
86
+ Standard cuisine ids, always listed: `american`, `chinese`, `mexican`,
87
+ `italian`, `japanese`, `indian`, `thai`, `mediterranean`, `korean`,
88
+ `vietnamese`.
89
+
90
+ Restaurants can also declare a cuisine of their own. Such cuisines are listed
91
+ after the standard ones as `custom:<name>` (e.g. `custom:peruvian`, label
92
+ "Peruvian", `custom: true`), and only where at least one restaurant in scope
93
+ serves them. Hosts can pick them like any other: send the `id` as `cuisine`.
94
+
95
+ ---
96
+
97
+ ## Catering requests
98
+
99
+ ### `POST /catering/requests` → `202` CateringRequest (status `COMPOSING`)
100
+
101
+ | Field | Type | Notes |
102
+ | --- | --- | --- |
103
+ | `partnerReference` | string, required | Your id, e.g. `luma:evt-AbC123` |
104
+ | `event.name` | string, required | |
105
+ | `event.startsAt` | ISO 8601, required | Must be in the future |
106
+ | `event.timeZone` | IANA, required | Venue time zone |
107
+ | `event.url` | URL | |
108
+ | `deliveryDeadlineLocal` | `YYYY-MM-DDTHH:mm` | Default: `startsAt` minus 30 min, venue-local |
109
+ | `restaurantName` | string | A restaurant the host prefers (`/catalog/restaurants`): all options come from it. Part of a name matches every location; small misspellings are tolerated when no restaurant matches exactly (`restaurant.closeMatch: true`). Send it or `cuisine`, not both. If it can't cater, `restaurant.available` is false and `restaurant.reason` says why; the options are from other restaurants |
110
+ | `cuisine` | cuisine id | A standard id or a `custom:…` id from `/catalog/cuisines`. Required unless you send `restaurantName`, `dishPreferences` or `mealType: "breakfast"` (then any cuisine) |
111
+ | `serviceStyle` | `buffet` or `meal_boxes` | How food is served. `buffet`: trays and platters to share, from restaurants with catering dishes. `meal_boxes`: one packed meal per guest from restaurants' regular dishes (more dishes, usually more restaurants). Default `meal_boxes`. |
112
+ | `includeDrinks` | bool | Default true. Non-alcoholic only. |
113
+ | `dishPreferences` | string[], up to 8 | Kinds of dishes the host wants: `"sushi"`, `"seafood"`, `"pastries"`, `"bagels"`, `"tacos"`… The mains come from dishes that match (name, description, category, tags; `"seafood"` also by a fish or shellfish allergen), and only restaurants with such dishes take part. A guest none of them is safe for gets another safe main (`allergyCoverage[].outsidePreferences: true`) |
114
+ | `mealType` | `breakfast`, `lunch` or `dinner` | The kind of food, whatever the delivery time. Breakfast food: dishes in the restaurant's breakfast or brunch menu, or that read like breakfast (pastries, bagels, egg dishes, oatmeal, fruit platters…). Without it, a delivery before 10:30 prefers breakfast food without requiring it |
115
+ | `spicyShare` | number 0–1 | About this share of the main servings spicy (`0.33` = a third; `0` = nothing spicy). Spicy: the restaurant's spice level 2 or more, or, without a level, the dish's wording ("spicy", "Sichuan", "jalapeño"…) |
116
+ | `partyDiet` | array of `vegetarian`, `vegan`, `halal`, `kosher`, `gluten_free`, `dairy_free`, `pescatarian` | Every guest's food must fit, as if each guest had said so (an all-vegetarian event) |
117
+ | `maxTotal` | number, USD | Hard budget for the order: options priced above it are not offered. Compared with what the host would pay (the card total; the USDC total at a restaurant that takes no card). See `budget` below |
118
+ | `maxPerGuest` | number, USD | Hard budget per guest, like `maxTotal` |
119
+ | `budgetPerGuest` | number | Soft: only flags options above it (`withinBudget: false`) |
120
+ | `deliveryAddress` | `{address1, address2?, city, state?, zip, country?}`, required | |
121
+ | `onsiteContact` | `{name, phone, email?}`, required | Receives the delivery |
122
+ | `deliveryNotes` | string | |
123
+ | `host` | `{name, email, phone?}`, required | |
124
+ | `attendees[]` | 1–1000, required | `{externalId?, name, email?, phone?, allergies?, dietaryPreferences?, allergyConsent?}` |
125
+
126
+ A request may list up to 1000 guests; more fails with `400 invalid_request`.
127
+
128
+ `email` and `phone` are optional for every guest. `allergyConsent: true` is
129
+ required for each guest whose `allergies` or `dietaryPreferences` says more than
130
+ "none": it records that the guest agreed to share those notes with Dunback and
131
+ the restaurant. Otherwise the request fails with `400 allergy_consent_required`,
132
+ and `error.details.guests` lists `{ index, externalId, name }` for each guest
133
+ concerned.
134
+
135
+ Dunback delivers only where it has launched. A delivery address outside the
136
+ launched areas fails with `422 delivery_area_not_launched`; the message names
137
+ the metro areas Dunback covers. Requests for more than 5 guests are checked
138
+ against the areas launched for catering, smaller ones against the areas
139
+ launched for individual delivery.
140
+
141
+ Composing usually takes 5–30 s. When it finishes, you receive the
142
+ `catering.options_ready`, `catering.no_options` or `catering.failed` webhook.
143
+
144
+ ### `GET /catering/requests/:id` → CateringRequest
145
+
146
+ ### `GET /catering/requests?partnerReference=…` → `{ data: CateringRequest[] }` (newest first)
147
+
148
+ ### CateringRequest
149
+
150
+ | Field | Notes |
151
+ | --- | --- |
152
+ | `id` | `creq_…` |
153
+ | `object` | `"catering_request"` |
154
+ | `status` | `COMPOSING`, `OPTIONS_READY`, `NO_OPTIONS`, `SELECTED` or `FAILED` |
155
+ | `partnerReference`, `event`, `cuisine`, `guestCount` | As sent; `event` gains `startsAtLocal` |
156
+ | `dishPreferences`, `mealType`, `spicyShare`, `partyDiet`, `maxTotal`, `maxPerGuest` | As sent (`[]` / `null` when not) |
157
+ | `budget` | With `maxTotal` / `maxPerGuest` only: `{ maxTotal, maxPerGuest, limit, withinBudget, overBudget, suggestedMaxTotal, suggestedMaxPerGuest, message }`. When the budget leaves fewer than three options, `message` says so and how far to raise it for three ("Only 2 catering offers fit your budget of $1,000. Raising your budget to about $1,150 would give you 3 offers to choose from."). **Show `message` to the host.** |
158
+ | `deliveryDeadlineLocal`, `timeZone`, `daypart` | |
159
+ | `allergySummary` | `[{ constraint, guests: [names] }]` |
160
+ | `options` | Up to 3, each from one restaurant; from different restaurants when several can cater. See below |
161
+ | `unavailableReasons` | `[{ name, code, reason }]` when `NO_OPTIONS`. `code`: `party_too_large`, `below_minimum_order`, `notice_too_short`, `no_buffet_dishes`, `style_not_offered`, `outside_delivery_area`, `not_serving_then`, `different_cuisine`, `no_matching_dishes` (none of the dishes asked for), `over_budget` or `restaurant_declined` (more may be added) |
162
+ | `orderId` | Set once an option is selected |
163
+ | `error` | `{ code, message }`, when `FAILED` |
164
+ | `createdAt`, `updatedAt` | |
165
+
166
+ Each option:
167
+
168
+ How the food is served is the host's choice (`serviceStyle`):
169
+
170
+ - `buffet`: trays and platters guests share. Only restaurants with catering
171
+ dishes for mains take part; their trays come first, single portions only
172
+ fill in.
173
+ - `meal_boxes` (default): one individually packed meal per guest, which
174
+ guests pick up themselves. Any restaurant's single portions qualify (no
175
+ trays), so there are more dishes to choose from and usually more
176
+ restaurants. A restaurant can opt out of packing meal boxes.
177
+
178
+ Each option repeats its `serviceStyle`, and the restaurant's order says how to pack it.
179
+
180
+ Restaurants may set their own catering policies: the most guests they cater
181
+ for in one order, a minimum order (food subtotal), free delivery at or above a
182
+ food subtotal, and advance notice by party size (e.g. more than 20 guests: 24
183
+ hours, more than 50: 72 hours). Each is optional. Dunback only offers options
184
+ that meet them: a restaurant that can't take the party, or needs more notice
185
+ than is left, is left out; an option slightly under a restaurant's minimum gets
186
+ shared sides or desserts added (`addedForMinimum`); `orderBy` is moved earlier
187
+ to the notice the restaurant needs. Free delivery shows as a `Free delivery`
188
+ price line of 0.
189
+
190
+ Restaurants that specialize in catering list catering dishes: trays and
191
+ platters that serve several people. Dunback composes with those first and adds
192
+ single portions only where needed (guests no tray suits, or a few guests left
193
+ over). Such an item has `serves`: `quantity` counts trays and `unitPrice` is
194
+ per tray, so 2 trays with `serves: 8` feed 16 guests.
195
+
196
+ | Field | Notes |
197
+ | --- | --- |
198
+ | `id` | `opt_1` … `opt_3` |
199
+ | `title` | |
200
+ | `strategy` | `favorites`, `value` or `variety` |
201
+ | `restaurant` | `{ name, distanceMiles, imageUrl, policies: { minimumOrder, maxGuests, freeDeliveryOver, noticeTiers: [{ overGuests, hours }] } }`; each policy is `null` when the restaurant has none |
202
+ | `freeDeliveryShortfall` | Food (USD) to add for the restaurant's free delivery; `null` when delivery is already free or there's no such policy |
203
+ | `items[]` | `{ name, description, imageUrl, role: "main"\|"drink"\|"extra", quantity, unitPrice, allergens, dietaryTags, serves?, addedForMinimum? }`. Each dish appears once with its full quantity: Dunback has no per-dish limit. `serves`: a catering dish (tray) serving that many people per unit; `quantity` and `unitPrice` are then per tray. `addedForMinimum`: a shared dish added to reach the restaurant's minimum order. |
204
+ | `allergyCoverage[]` | `{ constraint, guests, dishes }` |
205
+ | `unfedGuests[]` | `{ constraint, guests: [names], what? }`: guests with no dish known to be safe |
206
+ | `price` | See Price |
207
+ | `withinBudget` | Present when a budget was set |
208
+ | `acceptsCard` | `false` when the restaurant hasn't set up card payments on Dunback (its Stripe account): the option can then only be paid in USDC |
209
+ | `paymentMethods` | `["stripe","usdc"]`, or `["usdc"]` when `acceptsCard` is false |
210
+ | `orderBy` | ISO; latest payment time the restaurant accepts |
211
+
212
+ ### Price
213
+
214
+ | Field | Notes |
215
+ | --- | --- |
216
+ | `currency` | `"USD"` |
217
+ | `lines[]` | `{ code, label, amount }`. `code` is `food`, `delivery`, `restaurant_fee`, `tax`, `platform_fee` or `service_fee`. |
218
+ | `dunbackServiceFee` | The host's service fee: `serviceFeeRate` × (food and drinks + the restaurant's service charge). Delivery and tax are not included. |
219
+ | `serviceFeeRate` | Dunback's service fee rate on catering orders (`0.05` = 5%) |
220
+ | `totals` | `{ usdc, card, cardProcessingFee }` |
221
+ | `perGuest` | `{ usdc, card }` |
222
+
223
+ The card total is the USDC total grossed up for card processing.
224
+
225
+ ### `POST /catering/requests/:id/select` → `201` Order
226
+
227
+ | Field | Notes |
228
+ | --- | --- |
229
+ | `optionId` | required |
230
+ | `payer` | `{ name?, email? }` (pre-fills Stripe) |
231
+ | `paymentMethods` | `["stripe","usdc"]` (default both). `stripe` is left out when the option's `acceptsCard` is false. |
232
+ | `successUrl`, `cancelUrl` | Stripe return URLs: https, on your registered hosts. The hosted payment page links back to them ("Back to the event": `cancelUrl` before payment, `successUrl` after) |
233
+
234
+ Errors:
235
+
236
+ | Status | code | Meaning |
237
+ | --- | --- | --- |
238
+ | 409 | `invalid_state` | Already selected, or not ready |
239
+ | 409 | `order_deadline_passed` | Too late for the restaurant to make the event time |
240
+ | 409 | `card_payments_unavailable` | Only `stripe` was asked for, and this restaurant can't take card payments (`acceptsCard: false`). Offer USDC or another option. |
241
+ | 409 | `restaurant_*` | The restaurant can't take it now |
242
+
243
+ ---
244
+
245
+ ## Orders
246
+
247
+ ### Order
248
+
249
+ | Field | Notes |
250
+ | --- | --- |
251
+ | `id` | `ord_…` |
252
+ | `object` | `"order"` |
253
+ | `status` | `AWAITING_PAYMENT`, `PAID`, `FULFILLING`, `CONFIRMED`, `EXPIRED`, `CANCELLED`, `REFUNDED`, `REFUND_PENDING` or `NEEDS_ATTENTION`. A `CONFIRMED` order becomes `REFUNDED` / `REFUND_PENDING` when all its deliveries failed (see Refunds) |
254
+ | `title`, `summary`, `restaurant`, `deliveryDeadlineLocal`, `timeZone`, `guestCount` | |
255
+ | `delivery` | `{ address: {address1, address2, city, state, zip, country}, onsiteContact: {name, phone}, deliveryNotes, editable }`. `deliveryNotes` is your note only. `editable` is true while the order is `AWAITING_PAYMENT`. |
256
+ | `items`, `allergyCoverage`, `unfedGuests`, `price` | Same shapes as the option |
257
+ | `payment` | See below |
258
+ | `fulfillment` | `{ restaurantOrderIds, providerPayment, confirmedAt }`. `providerPayment` is how Dunback paid the restaurant: `{ method: "usdc_x402", amount, payTo, txHash, verifiedOnChain, network }` for a USDC order, or `{ method: "stripe_connect", status: "PAID"\|"PENDING" }` for a card order (paid through the restaurant's own Stripe account) |
259
+ | `refund` | The latest refund: `{ status: "SUCCEEDED"\|"PENDING", method, amount, note? }` |
260
+ | `refunds` | Every refund: `[{ amount, method, status, reason, detail, at, restaurantOrderId? }]`. `reason` is `cancel`, `failed`, `cancelled` (by the restaurant), `late` or `not_delivered` |
261
+ | `cancellation` | The cancellation and refund policy as it applies now; see Cancellation and refund policy |
262
+ | `lateRefund` | `{ afterMinutes, requestableFrom }`: a delivery `afterMinutes` or more late can get a refund request; offer it only from `requestableFrom` |
263
+ | `error` | `{ code, message }` |
264
+
265
+ `payment` holds:
266
+
267
+ | Field | Notes |
268
+ | --- | --- |
269
+ | `expiresAt` | ISO |
270
+ | `hostedPaymentUrl` | Dunback page offering every method; safe to give the payer |
271
+ | `stripe` | `{ checkoutUrl, amount, currency: "usd" }` |
272
+ | `usdc.network`, `usdc.chainId` | `"polygon"`, `137` |
273
+ | `usdc.asset` | USDC contract on Polygon |
274
+ | `usdc.receiver` | Dunback's receiving address |
275
+ | `usdc.amount`, `usdc.amountAtomic` | Exact amount, e.g. `"412.380317"` and `"412380317"` |
276
+ | `usdc.paymentUri` | `ethereum:…` (EIP-681) |
277
+ | `usdc.note` | |
278
+ | `usdc.x402Url` | For agents |
279
+ | `received` | `{ method: "stripe"\|"usdc"\|"x402", amount, currency, reference, payer?, at }` |
280
+ | `lastError` | `{ method, code, message, at }` |
281
+
282
+ The links (`hostedPaymentUrl`, `stripe`, `usdc`) are present while the status
283
+ is `AWAITING_PAYMENT`.
284
+
285
+ ### `GET /orders/:id` → Order
286
+
287
+ This also re-checks Stripe for open card payments.
288
+
289
+ ### `POST /orders/:id/usdc/confirm` `{ txHash }` → Order
290
+
291
+ Verifies a Polygon USDC transfer to `payment.usdc.receiver`. The amount must
292
+ be ≥ the USDC total; the exact tagged amount isn't required when you supply the
293
+ hash. The call waits up to 60 s for the restaurant to confirm.
294
+
295
+ | Status | code |
296
+ | --- | --- |
297
+ | 409 | `payment_pending` |
298
+ | 400 | `payment_not_found` |
299
+ | 400 | `payment_amount_short` |
300
+ | 409 | `payment_already_used` |
301
+
302
+ ### `POST /orders/:id/delivery` → Order
303
+
304
+ Corrects the delivery details before payment. The payer can do the same on the
305
+ hosted payment page (`hostedPaymentUrl`).
306
+
307
+ | Field | Type | Notes |
308
+ | --- | --- | --- |
309
+ | `deliveryAddress` | `{address1, address2?, city, state?, zip, country?}`, required | |
310
+ | `onsiteContact` | `{name, phone}` | Leave out to keep the current contact |
311
+ | `deliveryNotes` | string, up to 500 | Replaces the current note; default `""` |
312
+
313
+ The price stays as quoted, so the correction is checked:
314
+
315
+ | Status | code | Meaning |
316
+ | --- | --- | --- |
317
+ | 409 | `invalid_state` | The order isn't `AWAITING_PAYMENT` |
318
+ | 422 | `delivery_area_not_launched` | Dunback doesn't deliver to that area yet |
319
+ | 422 | `outside_delivery_area` | The restaurant doesn't deliver to that address |
320
+ | 422 | `address_moved` | More than about a mile from the quoted address: create a new catering request |
321
+ | 422 | `contact_incomplete` | A required field is missing |
322
+
323
+ On success you also receive the `order.delivery_updated` webhook.
324
+
325
+ ### `POST /orders/:id/cancel` `{ reason?, acceptPostCommitment? }` → Order
326
+
327
+ | Order status | Result |
328
+ | --- | --- |
329
+ | `AWAITING_PAYMENT` | Cancels the payment links |
330
+ | `CONFIRMED`, before the commitment deadline | Cancels at the restaurant and refunds the restaurant's full amount (card automatically, USDC after review) |
331
+ | `CONFIRMED`, after the commitment deadline, before delivery | Requires `"acceptPostCommitment": true` (else `409 post_commitment_confirmation_required`, with `details.cancellation`). Cancels at the restaurant; Dunback decides the refund (`order.refund_decided`) |
332
+ | Otherwise | `409 cancel_refused` or `409 invalid_state` |
333
+
334
+ ### Cancellation and refund policy
335
+
336
+ Dunback applies one cancellation and refund policy to every catering order,
337
+ whatever the restaurant's own policy elsewhere:
338
+
339
+ - **Before the commitment deadline:** the host may cancel and is refunded the
340
+ restaurant's full amount (food, delivery, restaurant fees and taxes).
341
+ Dunback's service fee and commission are kept.
342
+ - **After the commitment deadline, until delivery:** the host may still cancel
343
+ (for example, the event is called off). The restaurant may already have
344
+ bought or prepared food, so Dunback decides the refund with the restaurant,
345
+ from nothing up to that full amount, and sends it. You get
346
+ `order.refund_decided` with the decision and Dunback's explanation (and
347
+ `order.refunded` when money moves); the host is emailed too.
348
+
349
+ Every order carries `cancellation`:
350
+
351
+ | Field | Meaning |
352
+ | --- | --- |
353
+ | `policy` | The policy in one paragraph. **Show it with the order.** Options carry the same text as `cancellationPolicy`. |
354
+ | `phase` | `unpaid`, `before_commitment`, `after_commitment` or `closed` |
355
+ | `notice` | What cancelling now means. **Show it again, and get the host's confirmation, before you call cancel.** |
356
+ | `commitmentDeadlineUtc`, `deliveryDeadlineUtc` | ISO instants |
357
+ | `refundIfCancelledNow` | `{ kind: "restaurant_full_refund", amount }`, `{ kind: "decided_by_dunback", maximum }` or null |
358
+ | `requiresAcceptPostCommitment` | true after the commitment deadline |
359
+
360
+
361
+ ### `POST /orders/:id/refund-requests` `{ restaurantOrderId?, reason, impact }` → 202
362
+
363
+ For a catering delivery made at or after Dunback's catering late-delivery
364
+ threshold (60 minutes by default; Dunback may change it). You receive
365
+ `order.delivered_late` (the order, plus `lateDeliveries` and
366
+ `lateRefundPolicy`) when that happens; show the policy and let the host ask.
367
+
368
+ - `reason` (required): why the host is asking for a refund.
369
+ - `impact` (required): how the late delivery affected the event.
370
+ - Late deliveries are not refunded automatically. Dunback reviews the request
371
+ and decides the refund at its discretion, from nothing up to the
372
+ restaurant's part of that delivery; Dunback's service fee and commission are
373
+ not refunded. You get `order.refund_decided` with the decision (and
374
+ `order.refunded` if anything is refunded); the host is emailed.
375
+ - Errors: `409 not_late`, `409 already_requested`, `409 request_window_closed`
376
+ (30 days after delivery), `400 invalid_request`.
377
+
378
+ ### Deliveries: `order.deliveries`
379
+
380
+ One entry per restaurant order: `status` (`pending`, `on_the_way`,
381
+ `delivered`, `not_delivered`, `cancelled`), `deliveredAt`, `lateMinutes`,
382
+ `deliveredBy` (`driver`, or `courier` for a courier company the restaurant
383
+ booked, named in `courierCompany`), `timeRecordedBy` (`driver` or `courier`:
384
+ Dunback's clock, with a photo and location; `restaurant`: entered by the
385
+ restaurant from the courier's proof of delivery, so show that with the time),
386
+ `hostConfirmedAt`, `problemReport`, `problemReportableUntil` (48 hours after
387
+ delivery), and `canConfirm` / `canReportProblem`. You receive
388
+ `order.delivered` when a delivery is recorded.
389
+
390
+ ### `POST /orders/:id/deliveries/confirm` `{ restaurantOrderId? }` → Order
391
+
392
+ The host says the delivery arrived. Errors: `409 not_delivered`.
393
+
394
+ ### `POST /orders/:id/problem-reports` → 202
395
+
396
+ ```json
397
+ { "restaurantOrderId": "…", "type": "MISSING_ITEMS", "description": "Two of the five trays were missing.",
398
+ "wantsRefund": true, "photos": [{ "contentType": "image/jpeg", "data": "<base64>" }] }
399
+ ```
400
+
401
+ - For 48 hours after a delivery. `type`: `MISSING_ITEMS`, `DAMAGED`,
402
+ `WRONG_ORDER`, `NO_SETUP`, `CONDUCT`, `LATE`, `NOT_RECEIVED`, `OTHER`.
403
+ `description`: 10 to 2000 characters. Up to 3 photos of 5 MB (JPEG, PNG,
404
+ WebP). Without `restaurantOrderId`, every reportable delivery of the order.
405
+ - The restaurant is told at once. With `wantsRefund`, Dunback reviews the
406
+ report against its records of the delivery and decides the refund, from
407
+ nothing up to the restaurant's part of that delivery (Dunback's service fee
408
+ and commission are not refunded): `order.refund_decided` with basis
409
+ `delivery_problem` (a `LATE` report of a delivery recorded as late is the
410
+ late-delivery request, basis `late_delivery`).
411
+ - Response: `{ object: "problem_report", orderId, reportedAt, reports: [{ restaurantOrderId, type, refundRequested, refundBasis, maximum }], order }`.
412
+ - Errors: `409 not_delivered`, `409 already_reported`, `409 report_window_closed`,
413
+ `413 photo_too_large`, `415 invalid_photo`, `400 invalid_request`.
414
+
415
+ ### Refunds
416
+
417
+ | What happened | Refund | Webhook |
418
+ | --- | --- | --- |
419
+ | The host cancels before the commitment deadline (`POST /orders/:id/cancel`) | The restaurant's part of the order. Dunback's commission and service fee are kept. A card payment's processing fee is not refunded (Stripe keeps it). | `order.cancelled` |
420
+ | The host cancels after the commitment deadline, before delivery (`acceptPostCommitment: true`) | What Dunback decides with the restaurant: 0% to 100% of the restaurant's part | `order.cancelled`, then `order.refund_decided` (and `order.refunded` if anything is refunded) |
421
+ | The restaurant couldn't take the order after payment | Everything the host paid | `order.failed` |
422
+ | A delivery failed, or was cancelled by the restaurant | Everything the host paid for that delivery, card processing fee included | `order.refunded` |
423
+ | A delivery was at or after the catering late-delivery threshold, and the host requested a refund | What Dunback decides: 0% to 100% of the restaurant's part of that delivery | `order.refund_decided` (and `order.refunded`) |
424
+
425
+ Card payments are always refunded to the card; USDC refunds are sent to the
426
+ paying address after review. `refunds` lists every refund of the order;
427
+ `refund` is the latest one. When every delivery of an order failed, the order
428
+ becomes `REFUNDED` (or `REFUND_PENDING` while a refund is still due); when only
429
+ some did, it stays `CONFIRMED` and `order.refunded` tells you about each refund.
430
+
431
+ ### `POST /orders/:id/pay/x402?t=<token>` (x402 resource; no API key, the URL is `payment.usdc.x402Url`)
432
+
433
+ 1. Without `PAYMENT-SIGNATURE`, the endpoint returns
434
+ `402 Payment Required` with a `PAYMENT-REQUIRED` header: base64 JSON
435
+ `{ x402Version: 2, accepts: [{ scheme: "exact", network: "eip155:137", amount, asset, payTo, maxTimeoutSeconds, extra: { name: "USD Coin", version: "2" } }] }`.
436
+ 2. Retry with
437
+ `PAYMENT-SIGNATURE: base64({ x402Version: 2, scheme: "exact", network, accepted, payload: { authorization, signature } })`.
438
+ The payload is an EIP-3009 `TransferWithAuthorization`. It is verified and
439
+ settled by Dunback's facilitator.
440
+ 3. On success the response is `200` with the Order and a `PAYMENT-RESPONSE`
441
+ header. If the payment is rejected, you get `402` with `{ error: { code, message } }`.
442
+
443
+ ---
444
+
445
+ ## Webhooks
446
+
447
+ `POST` to your URL with this body:
448
+
449
+ ```json
450
+ { "id": "evt_…", "type": "order.confirmed", "created": 1763000000, "data": { … } }
451
+ ```
452
+
453
+ The `Dunback-Signature: t=<unix>,v1=<hex>` header is
454
+ `HMAC-SHA256(webhookSecret, "<t>.<raw body>")`. Reject anything older than
455
+ 5 minutes. Answer with a 2xx; anything else is retried after 1 s, 5 s and 25 s.
456
+
457
+ | Event | `data` |
458
+ | --- | --- |
459
+ | `catering.options_ready`, `catering.no_options`, `catering.failed` | CateringRequest |
460
+ | `order.created`, `order.confirmed`, `order.payment_failed`, `order.expired`, `order.failed`, `order.needs_attention`, `order.cancelled`, `order.refunded`, `order.delivery_updated` | Order |
461
+ | `order.refund_decided` | Order plus `refundDecision: { restaurantOrderId, basis, percentage, amount, explanation, refund }`; `basis`: `cancelled_after_commitment`, `late_delivery` or `delivery_problem` |
462
+ | `order.delivered` | Order plus `deliveredNow: [restaurantOrderId]` and `problemReportHours` (48) |
463
+ | `order.delivered_late` | Order plus `lateDeliveries: [{ restaurantOrderId, lateMinutes }]` and `lateRefundPolicy` |
464
+ | `ping` | `{ object: "ping", appId, message }`, plus top-level `livemode`. Sent by **Send test event** in the Developer Dashboard. |
465
+
466
+ The webhook URL, its signing secret (reveal or roll) and the allowed return
467
+ hosts are set per app and environment in the Developer Dashboard.