Move an order on, change its time, cancel or decline it
https://api.app2email.com/v1/{number}/shop/orders/{id}/action Scope: orders:manage. Not with a sandbox key. action: accept, preparing, ready, out_for_delivery, complete (handed over or delivered), time with minutes (later, or negative for earlier), cancel or reject with a reason, no_show for a ready pickup that was never collected (it ends as not collected and counts as a no-show of that customer), and hand_lines with lines [{ id, qty }] to give some lines now and the rest later (only when the shop has switched on partial hand-over; the order stays open until complete). Only the steps in the order's actions are accepted; anything else answers 400 shop_invalid, and 409 shop_changed when someone else moved the order meanwhile. cancel and reject give the stock back (restock false keeps it) and, with refund true, refund a paid order; notice in the answer says when a refund did not go through. The customer is told on WhatsApp where the shop has that message switched on. The step is written to the order's history with the key's name.
Path
-
Your app2email WhatsApp number - the number the message is sent FROM. Full number with country code, digits only.
e.g.4976659348270 -
The order's id, or its reference (SO-K7M2QX).
e.g.SO-K7M2QX
Body application/json required
-
acceptpreparingreadyout_for_deliverycompletecancelrejecttimeno_showhand_lines - reason string
cancel, reject: what the customer is told.
- minutes integer
time: minutes later (negative: earlier).
- refund boolean
cancel, reject of a paid order: refund it. no_show: refund what was paid online (default false: the payment is kept).
- restock boolean
cancel, reject: give the stock back (default true). no_show: default false.
- collected string
complete of an order paid at the counter.
cashcard - lines object[]
hand_lines: the lines given now (the shop setting orders.partial_handover must be on). The order stays open; complete hands over what is left.
Responses
Fields
- e.g.
true -
An order as the staff see it. Money in minor units.
52 fields
- id integer
- reference stringe.g.
SO-K7M2QX - status string
pending_payment = waits for its online payment; unconfirmed = a visitor of the order page has not confirmed on WhatsApp yet; new = waits for the shop to accept it.
pending_paymentunconfirmednewacceptedpreparingreadyout_for_deliverycompletedcancelledrejectedexpired - status_text string
- source string
webchatflowcounterapi - fulfilment string
pickupdelivery - asap boolean
- due_at string (date-time) | null
- due_label string
- slot_label string
- customer_name string
- customer_phone string
- customer_email string
- contact_identity string
The customer's WhatsApp number (digits) or business-scoped user id.
- contact_verified boolean
-
The delivery address; {} for a pickup.
- delivery_method string
- delivery_zone string
- note string
- allergy_note string
- items_count integer
- items_text stringe.g.
2 x Margherita, 1 x Cola - currency string
- subtotal integer
Whole minor units (cents): 1250 = 12.50.
- discount integer
Whole minor units (cents): 1250 = 12.50.
- discount_code string
- delivery_fee integer
Whole minor units (cents): 1250 = 12.50.
- fees integer
Whole minor units (cents): 1250 = 12.50.
- tip integer
Whole minor units (cents): 1250 = 12.50.
- tax integer
Whole minor units (cents): 1250 = 12.50.
- total integer
Whole minor units (cents): 1250 = 12.50.
- total_label stringe.g.
$30.50 - refunded integer
Whole minor units (cents): 1250 = 12.50.
- refundable integer
Whole minor units (cents): 1250 = 12.50.
- payment_state string
not_neededon_pickupon_deliverypendingauthorisedpaidpart_refundedrefundedreleasedfailed - payment_method string
- payment_id integer | null
- pickup_code string
The 4 characters the customer can say at the counter.
- order_url string
The customer's page of this order.
- actions string[]
What POST /shop/orders/{id}/action accepts for this order now.
- can_refund boolean
- late boolean
- created_at string (date-time)
- accepted_at string (date-time) | null
- ready_at string (date-time) | null
- completed_at string (date-time) | null
- cancelled_at string (date-time) | null
- cancelled_by string
- cancel_reason string
- handed_by string
- handed_method string
- lines object[]
Left out in lists.
13 item fields
- id integer
- item_id integer
- variant_id integer | null
- sku string
- name string
- variant_label string
- options object[]
- qty integer
- unit_price integer
Whole minor units (cents): 1250 = 12.50.
- unit_price_label string
- line_total integer
Whole minor units (cents): 1250 = 12.50.
- line_total_label string
- note string
- events object[]
GET only: the history, newest last: what happened, who did it, on which device.
- notice string
After an action: something to read, eg a refund that did not go through.
- repeated boolean
POST /shop/orders: true = this key was used before and this is that order.
- checkout_url string
POST /shop/orders with pay online: where the customer pays.
- payment_id integer | null
Errors
- 400 The request is malformed (missing or invalid fields, query parameters or times).
- 401 Missing, invalid, revoked or expired API key.
- 403 The key is valid but this call is not allowed: the key lacks the scope the call needs (insufficient_scope), the address is not allowed for the key (ip_not_allowed), the number or plan does not allow it, a recipient opted out or is not opted in, or a problem with the WhatsApp account.
- 404 The number, template, message, broadcast, webhook, delivery, opt-in, logged request, booking or Flow was not found.
- 409 Idempotency-Key: the first request with this key is still running, or did not finish. Or a conflict: the template name exists, the webhook URL is used by another webhook, the broadcast cannot be cancelled, the booking slot is taken or the booking is already cancelled, or the Flow is not published.
- 415 The body is not JSON.
- 429 A monthly plan limit, the number's own monthly cap, the key's daily cap, a WhatsApp rate limit, the API rate limit (rate_limited), or the webhook test limit (too_many_tests) was reached. Retry-After and error.retry_after_seconds say how long to wait.
- 500 Unexpected error on app2email's side.
- 503 app2email's connection to the WhatsApp account needs attention, or the request log is not available right now.