# English translation of openapi.yaml (source: 1aqh7ll). Same structure, line by line; only the texts change.
openapi: 3.1.0
info:
  title: SkyFood · Open Delivery API for integrators
  version: '1.7.1'
  summary: Receive SkyFood orders in your system and call the robot that makes the delivery.
  description: |
    SkyFood sells the store's products in its app and delivers them with **robots**. This API follows Abrasel's
    [Open Delivery 1.7.1](https://abrasel-nacional.github.io/opendelivery/) standard: SkyFood is the
    *Ordering Application* and your system (the store's POS/ERP) is the *Software Service*. Your system fetches the
    orders here, reports when it accepted them and when each order is ready, and SkyFood sends the robot to pick it up.

    This page covers only what the integration uses. The other Open Delivery routes follow the
    [official reference](https://abrasel-nacional.github.io/opendelivery/).

    ## Onboarding

    SkyFood registers each store and gives you:

    - **`client_id` and `client_secret`**: to request the token at `POST /oauth/token`. The secret is shown once;
      keep it safe.
    - **`token_url` and `base_url`**: the token address and the base of the `/v1/…` routes (`https://api.skyfood.io`
      in production, `https://sandbox.skyfood.io` in the sandbox).
    - **`merchant_id`**: the store's identifier, which comes in the order's `merchant.id` and is accepted in the
      optional `x-polling-merchants` header. If you already have an id for the store, tell SkyFood at registration.

    The menu comes from your system, sent through the API or read from an endpoint of yours (section **Menu through
    the API**, below). Credentials are per store: one store, one `client_id`.

    ## Order flow

    1. The customer pays in the app (in hotels, they can charge it to the room). Your polling receives **`CREATED`**.
    2. You read the order at `GET /v1/orders/{orderId}` and acknowledge the event at `POST /v1/events/acknowledgment`.
    3. You accept the order with `POST /v1/orders/{orderId}/confirm`. The customer sees the confirmation and you
       receive **`CONFIRMED`**.
    4. When the order is ready, `POST /v1/orders/{orderId}/readyForPickup`: **the robot is called** and goes to the
       store. You receive **`READY_FOR_PICKUP`**. When the robot arrives, the staff puts the order in it.
    5. From here on it's up to SkyFood: your system **calls nothing**, it only receives the events through polling.
       - The robot leaves the store with the order: **`DISPATCHED`**.
       - The customer takes the order out of the robot: **`DELIVERED`** and **`CONCLUDED`**.

    Delivery is always by the SkyFood robot, and SkyFood is the one that generates `DISPATCHED`, `DELIVERED` and
    `CONCLUDED`. The order comes with `delivery.deliveredBy: MARKETPLACE`, and the Open Delivery delivery routes
    (`dispatch`, `pickedUp`, `delivered`, `tracking`) are not used.

    At any time before the robot is loaded, the order can be cancelled (section **Cancellation**).

    ## Receiving orders (polling)

    1. Request a token and reuse it until it expires (6 hours). When you get `401 token_expired`, request another.
    2. Call `GET /v1/events:polling` at a fixed interval; we suggest every 30 seconds. With no events, the response
       is `204`.
    3. For each `CREATED`, fetch the order at `orderURL` (`GET /v1/orders/{orderId}`).
    4. Acknowledge **all** handled events at `POST /v1/events/acknowledgment`. An event that is not acknowledged
       comes back in the next polls.

    Events come from oldest to newest, up to 100 per response. Handle each `eventId` only once.

    ## Cancellation

    - **The customer cancels without asking the store**, as long as the robot hasn't been loaded. You receive
      `CANCELLED` with `metadata.code: CONSUMER_CANCELLATION_REQUESTED`: stop preparing and cancel the order in your
      system.
    - **The store cancels** with `POST …/requestCancellation`. The answer comes as an event: `CANCELLED` (before the
      robot reaches the store) or `CANCELLATION_REQUEST_DENIED` (the robot is already at the store or has the order;
      the delivery goes on).
    - SkyFood refunds the customer. Your system doesn't need to do anything.

    ## Menu through the API

    The store's menu on SkyFood comes from your system, in the Open Delivery
    [`Merchant`](https://abrasel-nacional.github.io/opendelivery/#operation/getMerchant) format, in one of two ways:

    - **Push:** you send the whole `Merchant` to `POST /v1/merchantUpdate` with `entityType: MERCHANT`. No endpoint
      of yours is needed. This is the way to manage the menu by hand through the API.
    - **Pull:** you expose an endpoint and give its URL and `apiKey` to SkyFood, which reads it (details below).

    ### How a push is applied

    - The `Merchant` you send **replaces the whole menu**, right away (the `204` response means the menu is already
      applied). To change a price, or add or remove an item, send the complete `Merchant` again with the change.
    - Each `itemOffer` listed in `categories[].itemOfferId` becomes a product: name, description and `externalCode`
      of the `item`, price of the `itemOffer` (`price.value`, in reais) and the `optionGroups` of the `itemOffer`. An
      item not listed in any category is ignored. The order follows the categories' `index` and the order of
      `itemOfferId`.
    - A product is identified by the `itemOffer`'s `id`: **keep ids stable**. A new id creates a new product; the
      product's `id` on SkyFood (`items[].id` in orders) doesn't change between pushes.
    - **An item that disappears from the push is hidden** in the app (it isn't deleted; old orders keep it). If it
      comes back with the same `itemOffer.id`, it reappears.
    - `status: UNAVAILABLE` on the `item`, the `itemOffer` or the category makes the item **visible and
      unavailable** (`AVAILABLE` puts it back on sale).
    - Option: each `optionGroups[].options[]` points (`itemId`) to an `item` with the option's name and
      `externalCode`; `price.value` is the extra charge. `minPermitted`/`maxPermitted` limit the choice. An option
      that disappears from the push is hidden; `status: UNAVAILABLE` makes it unavailable; a group that disappears
      is no longer shown.
    - Image: see **Product images**, below.
    - Display category, featured, alcoholic drink and translations (English/Spanish) go in the `x-skyfood` member
      of the `itemOffer`, the `item` or the category: see **How the menu appears on SkyFood**, below.
    - The merchant's `status` opens (`AVAILABLE`) or closes (`UNAVAILABLE`) the store. Leave it out to leave the
      store as it is.
    - A push with no item listed in a category doesn't change the menu (it never empties the store).
    - Body up to 1 MiB (above that, `413 payload_too_large`); for larger menus, use pull.

    ### Examples

    The whole menu (coffee with a choice of size, and cheese bread; `x-skyfood` is optional):

    ```json
    {"entityType": "MERCHANT", "updatedObjects": [{
      "id": "<merchant_id>",
      "categories": [
        {"id": "cat-bebidas", "index": 0, "name": "Bebidas", "status": "AVAILABLE", "itemOfferId": ["of-cafe"],
         "x-skyfood": {"category": "bebidas"}},
        {"id": "cat-salgados", "index": 1, "name": "Salgados", "status": "AVAILABLE", "itemOfferId": ["of-pao"],
         "x-skyfood": {"category": "lanches"}}],
      "itemOffers": [
        {"id": "of-cafe", "itemId": "it-cafe", "status": "AVAILABLE", "price": {"value": 8.50, "currency": "BRL"},
         "optionGroupsId": ["og-tamanho"], "x-skyfood": {"category": "cafe", "featured": true}},
        {"id": "of-pao", "itemId": "it-pao", "status": "AVAILABLE", "price": {"value": 6.00, "currency": "BRL"}}],
      "items": [
        {"id": "it-cafe", "name": "Café coado", "description": "Café filtrado na hora", "externalCode": "CAFE-01",
         "status": "AVAILABLE", "image": {"URL": "https://seu-sistema.example/img/cafe.jpg"},
         "x-skyfood": {"translations": {"en": {"name": "Drip coffee", "description": "Freshly brewed"},
                                        "es": {"name": "Café de filtro", "description": "Recién hecho"}}}},
        {"id": "it-pao", "name": "Pão de queijo", "externalCode": "PAO-01", "status": "AVAILABLE"},
        {"id": "it-p", "name": "Pequeno", "externalCode": "TAM-P", "status": "AVAILABLE"},
        {"id": "it-g", "name": "Grande", "externalCode": "TAM-G", "status": "AVAILABLE"}],
      "optionGroups": [
        {"id": "og-tamanho", "name": "Tamanho", "status": "AVAILABLE", "minPermitted": 1, "maxPermitted": 1,
         "options": [
           {"id": "op-p", "itemId": "it-p", "index": 0, "status": "AVAILABLE", "price": {"value": 0, "currency": "BRL"}},
           {"id": "op-g", "itemId": "it-g", "index": 1, "status": "AVAILABLE", "price": {"value": 2.00, "currency": "BRL"}}]}]
    }]}
    ```

    Each operation below is **this same body, complete, with the change shown** (the
    `POST /v1/merchantUpdate` reference has each one ready to copy):

    | Operation | Change in the `Merchant` |
    |---|---|
    | Change a price | `itemOffers[of-cafe].price.value: 9.90` |
    | Add an item | new `items[]` (`it-suco`), new `itemOffers[]` (`of-suco`, `itemId: it-suco`) and `of-suco` in `categories[].itemOfferId` |
    | Remove an item | take `of-pao` out of `itemOfferId` (and, if you like, the `itemOffer` and the `item`): it's hidden |
    | Unavailable item (sold out) | `items[it-pao].status: UNAVAILABLE`; `AVAILABLE` brings it back |
    | Add an option | new `items[]` (`it-xg`) and new `options[]` (`op-xg`, `itemId: it-xg`) in the group |
    | Remove an option | take `op-p` out of `options` (it's hidden); `status: UNAVAILABLE` only makes it unavailable |
    | Change the image | `items[it-cafe].images: [{URL: "https://…/cafe-v2.webp", type: MAIN}]` (or `image.URL`) |
    | Change category, featured, alcoholic drink | `itemOffers[of-pao].x-skyfood: {category: doces, featured: true}`; `alcoholic: true` marks an alcoholic drink |
    | Translate | `items[it-pao].x-skyfood.translations: {en: {name: "Cheese bread"}, es: {name: "Pan de queso"}}` |

    Opening or closing the store doesn't need the menu: `{"merchantStatus": "UNAVAILABLE"}` closes it and
    `{"merchantStatus": "AVAILABLE"}` opens it, right away.

    ### Product images

    - The product image is the first `https` URL among `items[].images[]` with `type: MAIN` and, after those,
      `items[].image.URL`. A URL that isn't `https` (`http`, empty, invalid) is ignored.
    - After applying the menu, SkyFood downloads each new or changed image and serves it from its own CDN (the app
      doesn't load it from your server). The same URL isn't downloaded again: to change the photo, send **another
      URL** (for example, with `?v=2`).
    - Until the download finishes, the previous image stays (an item that had no image shows your URL in the
      meantime). The image never holds up publishing: the item appears even if the download fails.
    - A temporary failure (network, timeout, `5xx`) is retried up to 5 times; a refused image (non-public address,
      not an image, too large) isn't retried. On any failure, the last good image stays.
    - An item sent without an image keeps the current one: through the API you can't remove an image, only replace
      it.
    - Requirements: an `https` URL at a public address, without authentication or an expiring signature, up to 3
      `https` redirects, a response within 20 seconds; JPEG, PNG or WebP (checked by content), up to 5 MB. The image
      is stored as it came (not resized). The app shows the photo square (and also cropped to a wide strip): use a
      square image, with the dish centered and room around the edges, about 1000 × 1000 px, in JPEG or WebP of up
      to ~300 KB.

    ### Store adjustments in the partner portal

    In the partner portal, the store can adjust fields of the menu you send. Each adjustment applies to one field
    and your later pushes **don't undo it** (the other fields keep coming from your system):

    - **Product:** name, description, price, image, availability (including taking it off the menu), display
      category, featured, alcoholic drink and translations.
    - **Option:** name, price and availability.
    - Precedence of each field: **store adjustment** > your value (`x-skyfood` included) > SkyFood's default (the
      category guessed from the name, not featured, not alcoholic, no translations).
    - Only the store undoes an adjustment ("Use the system's value"), and the field goes right back to the last
      value you sent (if you never sent that `x-skyfood` field, the current value stays).
    - You still decide which items exist: an item or option that disappears from your push is hidden even with an
      adjustment. The store doesn't create products or change `externalCode`, option groups, minimum/maximum or the
      order.
    - **Price:** when the store has adjusted a price, the order carries SkyFood's price (what the customer paid) in
      `items[].unitPrice`, `optionsPrice`, `totalPrice`, `options[].unitPrice` and `total`. Use the order's prices,
      not the ones in your own records for the `externalCode`.

    ### Responses and checking

    - `204`: applied. `400 merchant_update_invalid` with the cause in `detail` (JSON that isn't an object, unknown
      `entityType`, empty `updatedObjects`, a `Merchant` with a field of the wrong type, such as `price.value` as
      text, `x-skyfood` with an unknown category, language or field); in that case nothing changes.
      `413 payload_too_large`: body over 1 MiB.
    - A partial `entityType` (`ITEM`, `ITEM_OFFER`, `OPTION`, `AVAILABILITY`, …) and an empty body **don't apply the
      object sent**: they make SkyFood read your endpoint again. With no endpoint registered, they answer
      `400 merchant_update_invalid` (`store has no menu endpoint to read`); use `MERCHANT`.
    - `BASIC_INFO` updates only the registration data (CNPJ, phone, address).
    - **To check**, read `GET /v1/merchant` (production and sandbox, same token): it's the menu the customer sees, in
      the same `Merchant` format, with the store's adjustments applied. The `id`s are SkyFood's (the `items[].id` in
      orders); your id comes in `x-skyfood.id` of each `itemOffer` and option, and `x-skyfood.overrides` lists the
      fields the store adjusted. Each `itemOffer`'s `x-skyfood` also carries the current values of `category`,
      `featured`, `alcoholic` and `translations`. Hidden items and options (removed from the push) don't appear;
      unavailable ones come with `status: UNAVAILABLE`. The merchant's `status` shows whether the store is open.
    - In the sandbox, a test order (`POST /od-sandbox/v1/test-orders`) confirms that the item can be sold: a hidden
      or unavailable item answers `409 product_unavailable`, an option `409 option_unavailable`, a closed store
      `409 store_closed`.

    ### Reading your endpoint (pull)

    ```http
    GET https://seu-sistema.example/v1/merchant
    Accept: application/json
    X-API-KEY: <apiKey given to SkyFood>
    ```

    - Answer `200` with the store's `Merchant` (`id` equal to the agreed `merchant_id`) within 30 seconds, up to
      16 MiB. The URL must be `https`, with a valid certificate, at a public address and without redirects.
    - SkyFood reads the endpoint when you call `POST /v1/merchantUpdate` without a body (or with a partial
      `entityType`) and again when the response's `TTL` runs out (between 500 and 86,400 seconds; without `TTL`,
      86,400). The read is applied like a `MERCHANT` push.
    - A `4xx` response from your endpoint counts as a permanent failure; `5xx` and timeouts are retried. A
      `Merchant` with an invalid `x-skyfood` also fails without a retry, without changing anything; the cause shows
      up in `moreInfo` of `GET /v1/merchantStatus`.

    ## How the menu appears on SkyFood

    The customer sees the menu in the SkyFood app. Some fields the app uses don't exist in Open Delivery: they go in
    the **`x-skyfood`** member (outside the standard; anyone who doesn't know it ignores it and the `Merchant` is
    still valid). `GET /v1/skyfood/catalog` returns this vocabulary (categories, fields, languages, recommendations)
    for your system to read, instead of hard-coding it.

    ### Display categories

    The app groups products into **6 fixed SkyFood categories**, in this order:

    | `category` | In the app (pt) | en | es |
    |---|---|---|---|
    | `cafe` | Café | Coffee | Café |
    | `lanches` | Lanches | Snacks | Bocadillos |
    | `refeicoes` | Refeições | Meals | Comidas |
    | `saudavel` | Saudável | Healthy | Saludable |
    | `doces` | Doces | Sweets | Dulces |
    | `bebidas` | Bebidas | Drinks | Bebidas |

    Your `categories` don't appear in the app: they list the items (`itemOfferId`) and give the order and the
    `status`. Each product falls into one display category, in this precedence:

    1. the store's adjustment in the partner portal;
    2. `itemOffers[].x-skyfood.category`;
    3. `items[].x-skyfood.category`;
    4. `categories[].x-skyfood.category`, which applies to every item listed in it;
    5. a new product with no value: guessed from the item's name and then from its category's name ("suco" →
       `bebidas`, "bolo" → `doces`, "salada" → `saudavel`…); with no known word, `refeicoes`.

    With no value sent, an existing product keeps its current category. An unknown slug →
    `400 merchant_update_invalid`.

    ### Grouping and order

    - Store page: first **Destaques** (Featured), then one section per display category, in the table's order. A
      category with no product from the store doesn't appear; with more than one section, the top shows tabs.
    - Within a section, products follow your push: the `index` of your categories and the order of `itemOfferId`.
    - The store's search looks in the name and the description and shows a single list, without sections.

    ### Featured (`featured`)

    - `featured: true` puts the product in **Destaques** (Featured), at the top of the store, in a 2-column grid
      with a large photo; it also stays in its own category. There's no limit on how many: use few.
    - Available featured products from open stores also go into the draw for **"Para pedir agora"** (Order now), on
      the home screen (up to 10 at a time, among the stores at the location).
    - A sold-out featured product appears as "esgotado" (sold out) and doesn't open.

    ### Alcoholic drink (`alcoholic`)

    - `alcoholic: true` marks the product. There's no badge on the menu: when sending an order with the item, the
      app asks for the confirmation "Tenho 18 anos ou mais" (I'm 18 or older), on every order. Without it, the order
      isn't created.
    - The confirmation is the only check (there's no ID check on delivery).

    ### Options

    - `maxPermitted: 1`: single choice; greater than 1: multiple choice, up to `maxPermitted` options, each at most
      once (there's no quantity per option).
    - `minPermitted` ≥ 1: required group ("Obrigatório · escolha 1" or "Obrigatório · escolha até N", required ·
      choose 1 / up to N); the item only goes into the bag with the minimum chosen. `minPermitted: 0`:
      "Opcional · até N" (optional · up to N).
    - A negative minimum becomes 0; a maximum lower than 1 or than the minimum becomes the larger of the two (at
      least 1).
    - The option's `price.value` appears as "+ R$ 2,00" next to it (0 shows no price). With any paid option, the
      product's price appears as "A partir de R$ X" (from R$ X). Don't use negative values.
    - Groups in the order of `optionGroupsId`, options by `index`. An unavailable option appears grayed out,
      "Esgotado" (sold out).
    - Groups and options have no translation through the API: they appear as sent.

    ### Images

    - The app crops the same photo: a 60 px square in the list, 4:3 in Featured (2:1 when there's only one), a strip
      280 px tall across the screen width on the product page. Send it **square**, about 1000 × 1000 px, with the
      dish centered and room around the edges. Requirements and copying: **Product images**, above.
    - A product without an image shows a neutral icon (a cup in `cafe` and `bebidas`, a plate in the others).

    ### Texts and languages

    - **Name:** shown in full in the list and on the product page (it wraps); in Featured, up to 2 lines. Prefer up
      to ~40 characters.
    - **Description:** only appears on the product page, in **up to 2 lines**; the rest is cut off and doesn't
      expand. Prefer up to ~100 characters. There's no hard limit: longer text is just cut off.
    - Portuguese is the item's `name` and `description`. English and Spanish go in `x-skyfood.translations`:
      `{"en": {"name": "…", "description": "…"}, "es": {…}}`. When sent, it replaces all of the product's
      translations; empty text is discarded and a field without a translation uses the Portuguese. Other languages or
      fields → `400`.
    - Today the app shows the menu in Portuguese; the translations are stored and already served by the SkyFood API
      to anyone who asks for the menu in English or Spanish.

    ### Availability, hours and preparation

    - `status: UNAVAILABLE` (item, `itemOffer` or category): the product stays visible as "esgotado" (sold out),
      without an add button, and leaves "Para pedir agora". An item that disappears from the push is hidden.
    - Closed store (`merchantStatus: UNAVAILABLE`, the merchant's `status` or outside opening hours): the menu stays
      visible with the notice "Fechada, abre às …" (closed, opens at …) and doesn't take orders; the store
      disappears from the home screen.
    - Opening hours (per day of the week, in the location's time zone) and preparation time (shown as "15–25 min")
      are registered by SkyFood; `GET /v1/merchant` shows them in `services[].serviceHours` and
      `basicInfo.averagePreparationTime`.

    ### Ordering in the app

    - Quantity from 1 to 50 per item; up to 50 items per order. One store per bag.
    - A customer note per item, up to 140 characters, in the order's `items[].specialInstructions`.
    - Payment in the app: minimum order of R$ 5.00.

    ### Complete example with `x-skyfood`

    ```json
    {"entityType": "MERCHANT", "updatedObjects": [{
      "id": "<merchant_id>",
      "categories": [
        {"id": "cat-bar", "index": 0, "name": "Bar", "status": "AVAILABLE", "itemOfferId": ["of-cerveja", "of-suco"],
         "x-skyfood": {"category": "bebidas"}},
        {"id": "cat-doces", "index": 1, "name": "Sobremesas", "status": "AVAILABLE", "itemOfferId": ["of-brownie"]}],
      "itemOffers": [
        {"id": "of-cerveja", "itemId": "it-cerveja", "status": "AVAILABLE", "price": {"value": 15.00, "currency": "BRL"},
         "x-skyfood": {"alcoholic": true}},
        {"id": "of-suco", "itemId": "it-suco", "status": "AVAILABLE", "price": {"value": 12.00, "currency": "BRL"},
         "x-skyfood": {"category": "saudavel", "featured": true}},
        {"id": "of-brownie", "itemId": "it-brownie", "status": "AVAILABLE", "price": {"value": 9.00, "currency": "BRL"}}],
      "items": [
        {"id": "it-cerveja", "name": "Cerveja long neck", "description": "355 ml, gelada", "externalCode": "CERV-01",
         "status": "AVAILABLE",
         "x-skyfood": {"translations": {"en": {"name": "Long neck beer", "description": "355 ml, ice cold"},
                                        "es": {"name": "Cerveza long neck", "description": "355 ml, bien fría"}}}},
        {"id": "it-suco", "name": "Suco verde", "description": "Couve, maçã e gengibre", "externalCode": "SUCO-V",
         "status": "AVAILABLE", "x-skyfood": {"translations": {"en": {"name": "Green juice"}}}},
        {"id": "it-brownie", "name": "Brownie", "externalCode": "BROW-01", "status": "AVAILABLE"}]
    }]}
    ```

    Result: the beer in `bebidas` (through the `cat-bar` category), marked as alcoholic and translated; the juice in
    `saudavel` (the offer beats the category) and in Featured; the brownie, without `x-skyfood`, in `doces` (guessed
    from the name "Sobremesas", desserts) or in its current category, if it already existed. Check it with
    `GET /v1/merchant`.

    ## Errors

    Errors come as `application/problem+json`, compatible with Open Delivery's `Error` (`title`, `status`). Use the
    `code` field to decide what to do; each operation lists its own. Above the request limit, the response is
    `429 rate_limited` with the `Retry-After` header (seconds).

    ## Sandbox (test environment)

    The sandbox is an environment separate from production, for you to integrate and test without customers, without
    a real robot and without money: **`https://sandbox.skyfood.io`**. The `/oauth/token` and `/v1/…` routes are the
    same as in production; the data, credentials and tokens are different (a production token doesn't work in the
    sandbox, and vice versa). In the reference, choose the **Sandbox** server to use "Test Request" there.

    - **Credentials:** ask SkyFood (WhatsApp +55 11 99300-7106 or contato@tracftech.com) for a sandbox store. You get
      the `client_id`, `client_secret` and `merchant_id` of a store all your own, with a test menu (codes `SBX-…`),
      open 24 hours, at a test airport. The first `MERCHANT` push (section **Menu through the API**) replaces the
      test menu with yours; to test reading your endpoint, give SkyFood its URL and `apiKey`.
    - **Test orders:** since Open Delivery has no route to create an order, the sandbox has its own routes under
      `/od-sandbox/v1` (section **Sandbox** below), with the same token. The order is paid right away with a test
      card (no real payment) and follows exactly the path of a real order: the same events, the same rules, the same
      `GET /v1/orders/{orderId}`.
    - **Robot:** a virtual robot moves on its own, faster than a real one. The sandbox routes play the people's
      parts: the store staff putting the order in the robot (`load`), the customer taking it out (`collect`) or
      cancelling (`cancel`), and the store getting back an order that wasn't collected (`unload`). Each test order
      says in `nextStep` who acts now.
    - **Limits:** up to 60 test orders per hour per store (bursts of 10).

    ### Step by step in the sandbox

    1. `POST https://sandbox.skyfood.io/oauth/token` with the sandbox credentials: `200` with the token.
    2. `POST /od-sandbox/v1/test-orders` (no body, or with `items`): `201` with `orderId` and `nextStep: confirm`.
    3. `GET /v1/events:polling`: `CREATED` arrives. Read the order at `GET /v1/orders/{orderId}` and acknowledge the
       event.
    4. `POST /v1/orders/{orderId}/confirm` (`CONFIRMED`) and, with the order "ready", `POST …/readyForPickup`
       (`READY_FOR_PICKUP`). The virtual robot is called and goes to the store.
    5. Follow it with `GET /od-sandbox/v1/test-orders/{orderId}` until `nextStep: load` (robot at the store; a few
       seconds). Then **one** call to `POST /od-sandbox/v1/test-orders/{orderId}/load`: the store opens the
       compartment, puts the order in, closes it and the robot leaves. The `200` response already comes with
       `robot: to_destination` and you receive `DISPATCHED`.
    6. Wait for `nextStep: collect` (robot at the customer's gate) and call `POST …/collect` **once**: the customer
       opens it, takes the order out and closes it. The `200` response comes with `nextStep: done` and you receive
       `DELIVERED` and `CONCLUDED`.
    7. Cancellations: on another order, `POST …/cancel` before `load` generates `CANCELLED` with
       `CONSUMER_CANCELLATION_REQUESTED`; `POST /v1/orders/{orderId}/requestCancellation` tests cancellation by the
       store.
    8. To start over from scratch, `DELETE /od-sandbox/v1/test-orders` cancels the orders that aren't in the robot
       yet and acknowledges all pending events.

    `load`, `collect` and `unload` do the whole step in one call (open, wait for the robot to confirm, close, wait
    again and, on `load`, send the robot), usually in about 1 second and at most about 20. If the robot takes longer,
    the response is `202` with the current state: call again, and the step picks up where it left off (repeating a
    step that's already done returns `200` and does nothing). At the gate, the robot waits about 6 minutes; without
    `collect`, it goes back to the store and the order asks for `unload`.

    ## Certification checklist

    In the sandbox, with your sandbox store:

    1. `POST /oauth/token` with the store's credentials returns `200`.
    2. Create a test order (`POST /od-sandbox/v1/test-orders`). Your polling receives `CREATED`, you read the order
       and acknowledge the event; the next poll doesn't return the same event.
    3. Check the items' and options' `externalCode`, the total and the payment in the order.
    4. `confirm` returns `202` and you receive `CONFIRMED`. A second `confirm` returns `422 od_action_repeated`,
       which your system treats as success.
    5. `readyForPickup` returns `202`, you receive `READY_FOR_PICKUP` and the robot goes to the store. Do the `load`
       and follow `DISPATCHED`; do the `collect` and receive `DELIVERED` and `CONCLUDED`.
    6. On a second order, `requestCancellation` before `readyForPickup` results in `CANCELLED`.
    7. On a third order, the sandbox `cancel` (the customer cancels in the app): your system receives `CANCELLED`
       with `CONSUMER_CANCELLATION_REQUESTED` and cancels the order.
    8. `POST /v1/merchantUpdate` with `merchantStatus: UNAVAILABLE` closes the store (a test order starts answering
       `store_closed`); `AVAILABLE` reopens it.
    9. Send your menu (`entityType: MERCHANT`), change a price and check the new `unitPrice` on a test order.
    10. Your system renews the token when it receives `401 token_expired`.

    Then SkyFood registers your production store (with your menu endpoint, if you use pull) and gives you the
    production credentials.
  license:
    name: Apache 2.0 (Open Delivery contract)
    identifier: Apache-2.0
externalDocs:
  description: Official Open Delivery 1.7.1 reference (Abrasel)
  url: https://abrasel-nacional.github.io/opendelivery/
servers:
  - url: https://api.skyfood.io
    description: Production. Use the base_url you received at onboarding.
  - url: https://sandbox.skyfood.io
    description: Sandbox (testing, sandbox credentials).
security:
  - odClient: []
tags:
  - name: Authentication
    description: The store's access token (OAuth 2.0, client credentials).
  - name: Events
    description: |
      Queue of events for the store's orders. Poll it with `GET /v1/events:polling` and acknowledge with
      `POST /v1/events/acknowledgment`.

      | Event | Meaning |
      |---|---|
      | `CREATED` | New order, already paid (or charged to the room). Fetch it at `orderURL`. |
      | `CONFIRMED` | Echo of your `confirm`. |
      | `READY_FOR_PICKUP` | Echo of your `readyForPickup`: the robot was called. |
      | `DISPATCHED` | Sent by SkyFood: the robot left the store with the order. |
      | `DELIVERED` | Sent by SkyFood: the customer took the order out of the robot. |
      | `CONCLUDED` | Sent by SkyFood: order closed. |
      | `CANCELLATION_REQUESTED` | Echo of your `requestCancellation`. |
      | `CANCELLED` | Order cancelled (by the customer, the store or SkyFood). `metadata` carries `reason` and `code`. |
      | `CANCELLATION_REQUEST_DENIED` | The cancellation the store asked for was denied: the robot already has the order. |
  - name: Orders
    description: Order details.
  - name: Robot
    description: The store's actions on the order. `readyForPickup` calls the robot.
  - name: Cancellation
    description: Cancellation by the store.
  - name: Menu and store
    description: Menu updates and opening or closing the store.
  - name: Sandbox
    description: |
      Only at `https://sandbox.skyfood.io`, with the sandbox credentials. Paid test orders and the steps a person
      would take (the store loading the robot, the customer collecting or cancelling). See the step by step in the
      introduction.

      | `nextStep` | Who acts |
      |---|---|
      | `confirm` | You: `POST /v1/orders/{orderId}/confirm`. |
      | `readyForPickup` | You: `POST /v1/orders/{orderId}/readyForPickup`. |
      | `wait_robot` | The robot is on its way to the store. |
      | `load` | Sandbox: `POST …/load` (the store puts the order in the robot). |
      | `wait_delivery` | The robot is on its way to the customer. |
      | `collect` | Sandbox: `POST …/collect` (the customer collects it). |
      | `wait_return` | The robot is coming back to the store with the order. |
      | `unload` | Sandbox: `POST …/unload` (the store takes out the returned order). |
      | `done` | Delivered. |
      | `returned` | Came back to the store and was taken out (not delivered). |
      | `cancelled` | Cancelled. |
x-tagGroups:
  - name: Orders and robot
    tags: [Authentication, Events, Orders, Robot, Cancellation]
  - name: Store
    tags: [Menu and store]
  - name: Testing
    tags: [Sandbox]

paths:
  /oauth/token:
    post:
      operationId: issueToken
      tags: [Authentication]
      summary: Get an access token
      description: |
        OAuth 2.0 `client_credentials` with the store's credentials. The token is valid for `expires_in` seconds
        (6 hours): reuse it in `Authorization: Bearer <token>` and request another when it expires. Generating new
        credentials at SkyFood invalidates the previous tokens.
      security: []
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema: { $ref: '#/components/schemas/TokenRequest' }
            example: { grant_type: client_credentials, client_id: sfod_3f9a1c2e7b4d5a6f8e0c1b2a, client_secret: '<client_secret>' }
          application/json:
            schema: { $ref: '#/components/schemas/TokenRequest' }
            example: { grant_type: client_credentials, client_id: sfod_3f9a1c2e7b4d5a6f8e0c1b2a, client_secret: '<client_secret>' }
      responses:
        '200':
          description: Token issued.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/TokenResponse' }
              example: { access_token: 'q3J9yX0m6bN8cV1sZ4tW7eR2uI5oP0aL3kJ6hG9fD2s', token_type: bearer, expires_in: 21600 }
        '400':
          description: |
            - `unsupported_grant_type`: use `grant_type=client_credentials`.
            - `malformed_request`: unreadable body.
          content:
            application/problem+json:
              schema: { $ref: '#/components/schemas/Error' }
              example:
                type: about:blank
                title: Bad Request
                status: 400
                code: unsupported_grant_type
                error: unsupported_grant_type
                detail: only client_credentials
                request_id: 4f1c9a7e2b6d8e0f3a5c7b9d
        '401':
          description: '`invalid_client`: wrong `client_id` or `client_secret`. Check the credentials with SkyFood.'
          content:
            application/problem+json:
              schema: { $ref: '#/components/schemas/Error' }
              example:
                type: about:blank
                title: Unauthorized
                status: 401
                code: invalid_client
                error: invalid_client
                request_id: 4f1c9a7e2b6d8e0f3a5c7b9d
        '429': { $ref: '#/components/responses/TooManyRequests' }

  /v1/events:polling:
    get:
      operationId: pollEvents
      tags: [Events]
      summary: Poll events
      description: |
        Events not yet acknowledged for the token's store, from oldest to newest, up to 100 per response. With no
        events, `204`. Each event keeps coming back until it is acknowledged at `POST /v1/events/acknowledgment`.

        Watch out for the `eventType` filter: pending events of **other** types are acknowledged automatically
        (an Open Delivery rule) and don't come back. Without a filter, you receive them all.
      parameters:
        - name: eventType
          in: query
          required: false
          description: Filters by type, repeated (`eventType=A&eventType=B`). Unknown types are ignored.
          style: form
          explode: true
          schema:
            type: array
            items: { $ref: '#/components/schemas/EventType' }
        - name: x-polling-merchants
          in: header
          required: false
          description: Optional. If sent, it must contain the `merchant_id` of the token's store (comma-separated list).
          schema: { type: string }
      responses:
        '200':
          description: Pending events.
          content:
            application/json:
              schema:
                type: array
                items: { $ref: '#/components/schemas/Event' }
              example:
                - eventId: 0193a1b2-7c4d-7e8f-9a0b-1c2d3e4f5a6b
                  eventType: CREATED
                  orderId: 7b1e4c9a-2f3d-4a5b-8c6d-9e0f1a2b3c4d
                  orderURL: https://api.skyfood.io/v1/orders/7b1e4c9a-2f3d-4a5b-8c6d-9e0f1a2b3c4d
                  createdAt: '2026-10-06T12:00:00+00:00'
                  sourceAppId: 5a7c3e1f-8b2d-4f6a-9c0e-1d3b5f7a9c2e
                - eventId: 0193a1b9-1d2e-7f30-8a41-5b6c7d8e9f01
                  eventType: CANCELLED
                  orderId: 2c8d5e1f-4a6b-4c7d-9e8f-0a1b2c3d4e5f
                  orderURL: https://api.skyfood.io/v1/orders/2c8d5e1f-4a6b-4c7d-9e8f-0a1b2c3d4e5f
                  createdAt: '2026-10-06T12:01:30+00:00'
                  sourceAppId: 5a7c3e1f-8b2d-4f6a-9c0e-1d3b5f7a9c2e
                  metadata: { reason: Desisti do pedido, code: CONSUMER_CANCELLATION_REQUESTED, mode: MANUAL }
        '204': { description: No pending events. }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403':
          description: '`merchant_not_allowed`: `x-polling-merchants` doesn''t contain the `merchant_id` of the token''s store.'
          content:
            application/problem+json:
              schema: { $ref: '#/components/schemas/Error' }
        '429': { $ref: '#/components/responses/TooManyRequests' }

  /v1/events/acknowledgment:
    post:
      operationId: acknowledgeEvents
      tags: [Events]
      summary: Acknowledge events
      description: |
        Takes the events out of the polling queue. Send 1 to 100 events per call. Acknowledging the same event again
        has no effect.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: array
              minItems: 1
              maxItems: 100
              items: { $ref: '#/components/schemas/EventAck' }
            example:
              - id: 0193a1b2-7c4d-7e8f-9a0b-1c2d3e4f5a6b
                orderId: 7b1e4c9a-2f3d-4a5b-8c6d-9e0f1a2b3c4d
                eventType: CREATED
      responses:
        '202': { description: Acknowledged. }
        '400':
          description: |
            - `acknowledgment_invalid`: empty list or more than 100 events.
            - `malformed_request`: the body isn't a list of `{id, orderId, eventType}`.
          content:
            application/problem+json:
              schema: { $ref: '#/components/schemas/Error' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '429': { $ref: '#/components/responses/TooManyRequests' }

  /v1/orders/{orderId}:
    parameters:
      - $ref: '#/components/parameters/OrderId'
    get:
      operationId: getOrder
      tags: [Orders]
      summary: Order details
      description: |
        The order in Open Delivery's `Order` format. Main points:

        - `displayId` is the number the customer sees in the app.
        - `items[].externalCode` and `items[].options[].externalCode` are the codes from your menu.
        - `payments`: `PREPAID` = already paid in the app, nothing to charge. In hotels, `PENDING` with
          `method: OTHER` and `methodInfo` "Conta do quarto …" (room bill): the hotel charges it to the room.
        - `delivery.deliveryAddress.formattedAddress` is the robot's delivery point (for example, a gate). There's no
          postal address.
        - `preparationStartDateTime` is when the order reached the store.
      responses:
        '200':
          description: Order.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/Order' }
              examples:
                pedido: { $ref: '#/components/examples/Order' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '404': { $ref: '#/components/responses/OrderNotFound' }
        '429': { $ref: '#/components/responses/TooManyRequests' }

  /v1/orders/{orderId}/confirm:
    parameters:
      - $ref: '#/components/parameters/OrderId'
    post:
      operationId: confirmOrder
      tags: [Robot]
      summary: Accept the order
      description: |
        The store accepted the order: the customer sees the confirmation in the app and you receive `CONFIRMED`.
        Optional body, as in Open Delivery.
      requestBody: { $ref: '#/components/requestBodies/OptionalAction' }
      responses:
        '202': { description: Accepted. }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '404': { $ref: '#/components/responses/OrderNotFound' }
        '422': { $ref: '#/components/responses/ActionRejected' }
        '429': { $ref: '#/components/responses/TooManyRequests' }

  /v1/orders/{orderId}/readyForPickup:
    parameters:
      - $ref: '#/components/parameters/OrderId'
    post:
      operationId: readyForPickup
      tags: [Robot]
      summary: Order ready · call the robot
      description: |
        **This is the call that brings the robot.** Report when the order is ready and packed: SkyFood sends a robot
        to the store and you receive `READY_FOR_PICKUP`. When the robot arrives, the store staff puts the order in
        it. From then on the delivery is up to SkyFood: your system calls nothing else, it only receives through
        polling:

        1. `DISPATCHED` when the robot leaves the store with the order;
        2. `DELIVERED` and `CONCLUDED` when the customer collects the order.

        Call it once per order. Repeating it returns `422 od_action_repeated` (the robot has already been called).
      requestBody: { $ref: '#/components/requestBodies/OptionalAction' }
      responses:
        '202': { description: Accepted. The robot was called. }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '404': { $ref: '#/components/responses/OrderNotFound' }
        '422': { $ref: '#/components/responses/ActionRejected' }
        '429': { $ref: '#/components/responses/TooManyRequests' }

  /v1/orders/{orderId}/requestCancellation:
    parameters:
      - $ref: '#/components/parameters/OrderId'
    post:
      operationId: requestCancellation
      tags: [Cancellation]
      summary: Cancel the order (store)
      description: |
        The store asks for the cancellation. You receive `CANCELLATION_REQUESTED` and, right after, SkyFood's answer:

        - `CANCELLED`, if the robot hasn't reached the store yet: the order is cancelled and the customer is
          refunded;
        - `CANCELLATION_REQUEST_DENIED`, if the robot is already at the store or has the order: the delivery goes on.

        `code` must be one of the Open Delivery cancellation codes (`CancellationCode`); numeric codes aren't
        accepted. An order already delivered or cancelled → `422 od_order_finished`, with no event.
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: '#/components/schemas/CancellationRequest' }
            example: { reason: Acabou o café, code: UNAVAILABLE_ITEM, mode: MANUAL }
      responses:
        '202': { description: Cancellation request received. The result arrives as an event. }
        '400':
          description: '`cancellation_code_invalid`: `code` missing, numeric or not on the list; the cause comes in `detail`.'
          content:
            application/problem+json:
              schema: { $ref: '#/components/schemas/Error' }
              example:
                type: about:blank
                title: Bad Request
                status: 400
                code: cancellation_code_invalid
                detail: code must be an OD cancellation code
                request_id: 4f1c9a7e2b6d8e0f3a5c7b9d
        '401': { $ref: '#/components/responses/Unauthorized' }
        '404': { $ref: '#/components/responses/OrderNotFound' }
        '422': { $ref: '#/components/responses/ActionRejected' }
        '429': { $ref: '#/components/responses/TooManyRequests' }

  /v1/merchant:
    get:
      operationId: getMerchant
      tags: [Menu and store]
      summary: Read the published menu
      description: |
        The menu of the token's store as the customer sees it now, in Open Delivery's `Merchant` format (the same as
        the push), with the store's adjustments from the partner portal already applied.

        - The `id`s of the category, `itemOffer`, `item`, group and option are SkyFood's (the `itemOffer.id` is the
          `items[].id` in orders and the `productId` in test orders). Your id comes in `x-skyfood.id`; the
          `externalCode` is yours; the group's `externalCode` is the id of the group you sent.
        - `x-skyfood.overrides`: fields the store adjusted (product: `name`, `description`, `price`, `image`,
          `availability`, `category`, `featured`, `alcoholic`, `translations`; option: `name`, `price_delta`,
          `availability`). The value shown is the store's.
        - `itemOffers[].x-skyfood` carries the current values of `category` (display category), `featured`,
          `alcoholic` and `translations` (`{}` with no translations), whether they come from you, the store or
          SkyFood's default.
        - Hidden items and options don't appear; unavailable ones come with `status: UNAVAILABLE`.
        - The categories are SkyFood's 6 display categories (`externalCode` = slug), not yours; see **How the menu
          appears on SkyFood**.
        - Image: SkyFood's URL after the copy; before it, the previous one (or your URL, if there was no image).
        - `status`: `AVAILABLE` store open, `UNAVAILABLE` closed. `basicInfo` and `services` carry the registration
          data and the opening hours.
      responses:
        '200':
          description: Published menu.
          content:
            application/json:
              schema: { type: object, additionalProperties: true }
              example:
                id: 80562722-b213-5c8c-8590-cfdb24381361
                status: AVAILABLE
                lastUpdate: '2026-11-23T23:30:00Z'
                TTL: 3600
                menus: [{ id: 80562722-b213-5c8c-8590-cfdb24381361, name: Café do Portão, categoryId: [3f0c1d2e-5a6b-4c7d-8e9f-0a1b2c3d4e5f] }]
                categories:
                  - id: 3f0c1d2e-5a6b-4c7d-8e9f-0a1b2c3d4e5f
                    index: 0
                    name: Café
                    externalCode: cafe
                    status: AVAILABLE
                    itemOfferId: [01a20ab1-afaf-715b-af6b-9111da12b2c5]
                itemOffers:
                  - id: 01a20ab1-afaf-715b-af6b-9111da12b2c5
                    itemId: 01a20ab1-afaf-715b-af6b-9111da12b2c5
                    index: 0
                    status: AVAILABLE
                    price: { value: 11.00, originalValue: 11.00, currency: BRL }
                    optionGroupsId: [01a20ab1-afc7-77af-909d-a467287a98a0]
                    x-skyfood:
                      id: of-cafe
                      overrides: [price]
                      category: cafe
                      featured: true
                      alcoholic: false
                      translations:
                        en: { name: Drip coffee, description: Freshly brewed }
                        es: { name: Café de filtro, description: Recién hecho }
                items:
                  - id: 01a20ab1-afaf-715b-af6b-9111da12b2c5
                    name: Café coado
                    description: Café filtrado na hora
                    externalCode: CAFE-01
                    status: AVAILABLE
                    image: { URL: 'https://cdn.skyfood.io/products/01a20ab1-cafe.webp' }
                    unit: UN
                  - { id: 01a20ab1-afcb-7c51-a1b0-3f6e2d1c0b9a, name: Grande, externalCode: TAM-G, status: AVAILABLE, unit: UN }
                optionGroups:
                  - id: 01a20ab1-afc7-77af-909d-a467287a98a0
                    index: 1
                    name: Tamanho
                    externalCode: og-tamanho
                    status: AVAILABLE
                    minPermitted: 1
                    maxPermitted: 1
                    options:
                      - id: 01a20ab1-afcb-7c51-a1b0-3f6e2d1c0b9a
                        itemId: 01a20ab1-afcb-7c51-a1b0-3f6e2d1c0b9a
                        index: 0
                        status: AVAILABLE
                        price: { value: 2.00, originalValue: 2.00, currency: BRL }
                        x-skyfood: { id: op-g, overrides: [] }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '429': { $ref: '#/components/responses/TooManyRequests' }

  /v1/merchantUpdate:
    post:
      operationId: merchantUpdate
      tags: [Menu and store]
      summary: Update the menu or open/close the store
      description: |
        - **`entityType: MERCHANT`** with the complete `Merchant` in `updatedObjects`: replaces the whole menu right
          away (an item or option that disappears is hidden). Prices, additions, removals, availability and options
          change by sending the whole `Merchant` again; see the examples and the **Menu through the API** section of
          the introduction.
        - **`merchantStatus`:** `AVAILABLE` opens and `UNAVAILABLE` closes the store in the app right away.
        - **`BASIC_INFO`** updates the registration data.
        - **No body** or another `entityType` (`ITEM`, `ITEM_OFFER`, `AVAILABILITY`, …): SkyFood reads your menu
          endpoint again. With no endpoint registered, `400 merchant_update_invalid`.
        - **`x-skyfood`** (optional, outside the standard) in `itemOffers[]`, `items[]` and `categories[]`: display
          category, featured, alcoholic drink and translations. See **How the menu appears on SkyFood** and
          `GET /v1/skyfood/catalog`.
      requestBody:
        required: false
        content:
          application/json:
            schema: { $ref: '#/components/schemas/MerchantUpdate' }
            examples:
              cardapio:
                summary: The whole menu
                value:
                  entityType: MERCHANT
                  updatedObjects:
                    - id: <merchant_id>
                      categories: &cats
                        - { id: cat-bebidas, index: 0, name: Bebidas, status: AVAILABLE, itemOfferId: [of-cafe], x-skyfood: { category: bebidas } }
                        - { id: cat-salgados, index: 1, name: Salgados, status: AVAILABLE, itemOfferId: [of-pao], x-skyfood: { category: lanches } }
                      itemOffers: &offers
                        - &ofCafe
                          id: of-cafe
                          itemId: it-cafe
                          status: AVAILABLE
                          price: { value: 8.50, currency: BRL }
                          optionGroupsId: [og-tamanho]
                          x-skyfood: { category: cafe, featured: true }
                        - &ofPao { id: of-pao, itemId: it-pao, status: AVAILABLE, price: { value: 6.00, currency: BRL } }
                      items: &items
                        - &itCafe
                          id: it-cafe
                          name: Café coado
                          description: Café filtrado na hora
                          externalCode: CAFE-01
                          status: AVAILABLE
                          image: { URL: 'https://seu-sistema.example/img/cafe.jpg' }
                          x-skyfood:
                            translations:
                              en: { name: Drip coffee, description: Freshly brewed }
                              es: { name: Café de filtro, description: Recién hecho }
                        - { id: it-pao, name: Pão de queijo, externalCode: PAO-01, status: AVAILABLE }
                        - &itP { id: it-p, name: Pequeno, externalCode: TAM-P, status: AVAILABLE }
                        - &itG { id: it-g, name: Grande, externalCode: TAM-G, status: AVAILABLE }
                      optionGroups: &groups
                        - id: og-tamanho
                          name: Tamanho
                          status: AVAILABLE
                          minPermitted: 1
                          maxPermitted: 1
                          options:
                            - { id: op-p, itemId: it-p, index: 0, status: AVAILABLE, price: { value: 0, currency: BRL } }
                            - &opG { id: op-g, itemId: it-g, index: 1, status: AVAILABLE, price: { value: 2.00, currency: BRL } }
              preco:
                summary: Change a price (coffee at 9.90)
                value:
                  entityType: MERCHANT
                  updatedObjects:
                    - id: <merchant_id>
                      categories: *cats
                      itemOffers:
                        - id: of-cafe
                          itemId: it-cafe
                          status: AVAILABLE
                          price: { value: 9.90, currency: BRL }
                          optionGroupsId: [og-tamanho]
                        - *ofPao
                      items: *items
                      optionGroups: *groups
              incluir:
                summary: Add an item (juice)
                value:
                  entityType: MERCHANT
                  updatedObjects:
                    - id: <merchant_id>
                      categories:
                        - { id: cat-bebidas, index: 0, name: Bebidas, status: AVAILABLE, itemOfferId: [of-cafe, of-suco] }
                        - { id: cat-salgados, index: 1, name: Salgados, status: AVAILABLE, itemOfferId: [of-pao] }
                      itemOffers:
                        - *ofCafe
                        - *ofPao
                        - { id: of-suco, itemId: it-suco, status: AVAILABLE, price: { value: 12.00, currency: BRL } }
                      items:
                        - *itCafe
                        - { id: it-pao, name: Pão de queijo, externalCode: PAO-01, status: AVAILABLE }
                        - *itP
                        - *itG
                        - { id: it-suco, name: Suco de laranja, externalCode: SUCO-01, status: AVAILABLE }
                      optionGroups: *groups
              remover:
                summary: Remove an item (the cheese bread is hidden)
                value:
                  entityType: MERCHANT
                  updatedObjects:
                    - id: <merchant_id>
                      categories:
                        - { id: cat-bebidas, index: 0, name: Bebidas, status: AVAILABLE, itemOfferId: [of-cafe] }
                      itemOffers: [*ofCafe]
                      items: [*itCafe, *itP, *itG]
                      optionGroups: *groups
              esgotado:
                summary: Unavailable item (cheese bread sold out)
                value:
                  entityType: MERCHANT
                  updatedObjects:
                    - id: <merchant_id>
                      categories: *cats
                      itemOffers: *offers
                      items:
                        - *itCafe
                        - { id: it-pao, name: Pão de queijo, externalCode: PAO-01, status: UNAVAILABLE }
                        - *itP
                        - *itG
                      optionGroups: *groups
              opcoes:
                summary: 'Options: remove Pequeno (small), add Extra grande (extra large)'
                value:
                  entityType: MERCHANT
                  updatedObjects:
                    - id: <merchant_id>
                      categories: *cats
                      itemOffers: *offers
                      items:
                        - *itCafe
                        - { id: it-pao, name: Pão de queijo, externalCode: PAO-01, status: AVAILABLE }
                        - *itG
                        - { id: it-xg, name: Extra grande, externalCode: TAM-XG, status: AVAILABLE }
                      optionGroups:
                        - id: og-tamanho
                          name: Tamanho
                          status: AVAILABLE
                          minPermitted: 1
                          maxPermitted: 1
                          options:
                            - *opG
                            - { id: op-xg, itemId: it-xg, index: 2, status: AVAILABLE, price: { value: 3.50, currency: BRL } }
              imagem:
                summary: Change the coffee's image
                value:
                  entityType: MERCHANT
                  updatedObjects:
                    - id: <merchant_id>
                      categories: *cats
                      itemOffers: *offers
                      items:
                        - id: it-cafe
                          name: Café coado
                          description: Café filtrado na hora
                          externalCode: CAFE-01
                          status: AVAILABLE
                          images: [{ URL: 'https://seu-sistema.example/img/cafe-v2.webp', type: MAIN }]
                        - { id: it-pao, name: Pão de queijo, externalCode: PAO-01, status: AVAILABLE }
                        - *itP
                        - *itG
                      optionGroups: *groups
              skyfood:
                summary: 'x-skyfood: category, featured, alcoholic drink and translations'
                value:
                  entityType: MERCHANT
                  updatedObjects:
                    - id: <merchant_id>
                      categories:
                        - { id: cat-bar, index: 0, name: Bar, status: AVAILABLE, itemOfferId: [of-cerveja, of-suco], x-skyfood: { category: bebidas } }
                        - { id: cat-doces, index: 1, name: Sobremesas, status: AVAILABLE, itemOfferId: [of-brownie] }
                      itemOffers:
                        - { id: of-cerveja, itemId: it-cerveja, status: AVAILABLE, price: { value: 15.00, currency: BRL }, x-skyfood: { alcoholic: true } }
                        - { id: of-suco, itemId: it-suco, status: AVAILABLE, price: { value: 12.00, currency: BRL }, x-skyfood: { category: saudavel, featured: true } }
                        - { id: of-brownie, itemId: it-brownie, status: AVAILABLE, price: { value: 9.00, currency: BRL } }
                      items:
                        - id: it-cerveja
                          name: Cerveja long neck
                          description: '355 ml, gelada'
                          externalCode: CERV-01
                          status: AVAILABLE
                          x-skyfood:
                            translations:
                              en: { name: Long neck beer, description: '355 ml, ice cold' }
                              es: { name: Cerveza long neck, description: '355 ml, bien fría' }
                        - { id: it-suco, name: Suco verde, description: 'Couve, maçã e gengibre', externalCode: SUCO-V, status: AVAILABLE, x-skyfood: { translations: { en: { name: Green juice } } } }
                        - { id: it-brownie, name: Brownie, externalCode: BROW-01, status: AVAILABLE }
              fechar:
                summary: Close the store
                value: { merchantStatus: UNAVAILABLE }
              abrir:
                summary: Open the store
                value: { merchantStatus: AVAILABLE }
              ler:
                summary: Read your menu endpoint again (only with a registered endpoint)
                value: {}
      responses:
        '204': { description: 'Applied (`MERCHANT`, `merchantStatus`, `BASIC_INFO`) or menu read scheduled.' }
        '400':
          description: '`merchant_update_invalid`: a body that isn''t a JSON object, an invalid `merchantStatus`, `entityType`, `updatedObjects`, `Merchant` or `x-skyfood`, or a read requested with no menu endpoint registered; the cause comes in `detail`. Nothing is changed.'
          content:
            application/problem+json:
              schema: { $ref: '#/components/schemas/Error' }
              examples:
                status:
                  summary: Invalid merchantStatus
                  value:
                    type: about:blank
                    title: Bad Request
                    status: 400
                    code: merchant_update_invalid
                    detail: merchantStatus must be AVAILABLE or UNAVAILABLE
                    request_id: 4f1c9a7e2b6d8e0f3a5c7b9d
                categoria:
                  summary: Unknown display category
                  value:
                    type: about:blank
                    title: Bad Request
                    status: 400
                    code: merchant_update_invalid
                    detail: 'itemOffers[of-suco].x-skyfood.category: unknown category "sucos" (use one of cafe, lanches, refeicoes, saudavel, doces, bebidas)'
                    request_id: 4f1c9a7e2b6d8e0f3a5c7b9d
        '401': { $ref: '#/components/responses/Unauthorized' }
        '429': { $ref: '#/components/responses/TooManyRequests' }

  /v1/skyfood/catalog:
    get:
      operationId: getSkyfoodCatalog
      tags: [Menu and store]
      summary: SkyFood vocabulary (x-skyfood)
      description: |
        Outside the Open Delivery standard, with the same token. What the SkyFood app uses beyond the `Merchant`, for
        your system to read instead of hard-coding it:

        - `categories`: the 6 display categories (`slug` for `x-skyfood.category`, Portuguese name, names in
          `en`/`es`, `index` = order in the app);
        - `fields`: the members accepted in `x-skyfood`, with type, where they go (`in`) and values;
        - `languages`, `images` (formats, maximum and recommended size, aspect ratio), `texts` (limits and recommended
          length of each text) and `options` (how the app shows option groups).

        The API returns these texts in Portuguese, as in the example. Details in the **How the menu appears on
        SkyFood** section of the introduction.
      responses:
        '200':
          description: Vocabulary.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/SkyfoodCatalog' }
              example:
                categories:
                  - { slug: cafe, index: 0, name: Café, names: { pt: Café, en: Coffee, es: Café } }
                  - { slug: lanches, index: 1, name: Lanches, names: { pt: Lanches, en: Snacks, es: Bocadillos } }
                  - { slug: refeicoes, index: 2, name: Refeições, names: { pt: Refeições, en: Meals, es: Comidas } }
                  - { slug: saudavel, index: 3, name: Saudável, names: { pt: Saudável, en: Healthy, es: Saludable } }
                  - { slug: doces, index: 4, name: Doces, names: { pt: Doces, en: Sweets, es: Dulces } }
                  - { slug: bebidas, index: 5, name: Bebidas, names: { pt: Bebidas, en: Drinks, es: Bebidas } }
                fields:
                  - name: category
                    type: string
                    in: ['itemOffers[]', 'items[]', 'categories[]']
                    values: [cafe, lanches, refeicoes, saudavel, doces, bebidas]
                    override: category
                    description: Categoria de vitrine do produto. Em categories[] vale para todos os itens listados nela. Sem valor, produto novo recebe a categoria adivinhada pelo nome; produto existente mantém a atual.
                  - { name: featured, type: boolean, in: ['itemOffers[]', 'items[]'], override: featured, description: 'Destaque: aparece em "Destaques" no topo da loja e pode aparecer em "Para pedir agora" na tela inicial. Sem valor: mantém (produto novo: false).' }
                  - { name: alcoholic, type: boolean, in: ['itemOffers[]', 'items[]'], override: alcoholic, description: 'Bebida alcoólica: o pedido com o item exige a confirmação "Tenho 18 anos ou mais". Sem valor: mantém (produto novo: false).' }
                  - name: translations
                    type: object
                    in: ['itemOffers[]', 'items[]']
                    languages: [en, es]
                    textFields: [name, description]
                    override: translations
                    description: 'Nome e descrição em inglês e espanhol: {"en": {"name": …, "description": …}, "es": {…}}. Substitui todas as traduções do produto; texto vazio é descartado; campo sem tradução usa o português. Sem valor: mantém.'
                languages:
                  - { code: pt, base: true, description: 'Português: name e description do item. É o que o app mostra hoje.' }
                  - { code: en, base: false, description: 'Inglês: x-skyfood.translations.en; cada campo sem tradução cai no português.' }
                  - { code: es, base: false, description: 'Espanhol: x-skyfood.translations.es; cada campo sem tradução cai no português.' }
                images:
                  formats: [image/jpeg, image/png, image/webp]
                  maxBytes: 5242880
                  aspectRatio: '1:1'
                  recommendedWidth: 1000
                  recommendedHeight: 1000
                  recommendedBytes: 300000
                  description: URL https pública; a SkyFood copia a imagem para a própria CDN, sem redimensionar. O app recorta, quadrado na lista (60 px), 4:3 ou 2:1 em Destaques, faixa larga de 280 px de altura na ficha do produto. Prato centralizado, com folga nas bordas.
                texts:
                  - { field: item.name, required: true, maxLength: null, recommendedLength: 40, display: 'Lista e ficha do produto: inteiro, quebra linha. Destaques: até 2 linhas, o resto vira reticências.' }
                  - { field: item.description, required: false, maxLength: null, recommendedLength: 100, display: 'Só na ficha do produto, até 2 linhas; o resto é cortado com reticências e não abre. A busca também procura na descrição.' }
                  - { field: observação do cliente (pedido), required: false, maxLength: 140, recommendedLength: 140, display: 'Texto livre do cliente por item; chega em items[].specialInstructions do pedido.' }
                options:
                  - { rule: required, when: minPermitted >= 1, display: '"Obrigatório · escolha 1" (maxPermitted 1) ou "Obrigatório · escolha até N"; o item só vai à sacola com pelo menos minPermitted opções.' }
                  - { rule: single, when: maxPermitted = 1, display: Escolha única (botão de rádio). }
                  - { rule: price, when: 'options[].price.value > 0', display: '"+ R$ 2,00" ao lado da opção (0 não mostra preço) e o preço do produto aparece como "A partir de R$ X". Não use valor negativo.' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '429': { $ref: '#/components/responses/TooManyRequests' }

  /od-sandbox/v1/test-orders:
    servers:
      - url: https://sandbox.skyfood.io
        description: Sandbox
    post:
      operationId: sandboxCreateTestOrder
      tags: [Sandbox]
      summary: Create a test order
      description: |
        A test customer places an order at your sandbox store, paid right away with a test card (no real payment),
        for delivery at Gate A1. You receive `CREATED` through polling, as with any order.

        - No body: one unit of the menu's first available product (with the first options of the required groups).
        - With `items`: the products (`productId` = `items[].id` in orders), quantities and options you want. The
          errors are the app's (`409 product_unavailable`, `409 store_closed`, `422 option_group_min`…).

        Limit: 60 test orders per hour per store (bursts of 10); above it, `429 rate_limited`.
      requestBody:
        required: false
        content:
          application/json:
            schema: { $ref: '#/components/schemas/SandboxTestOrderRequest' }
            examples:
              padrao:
                summary: Default item
                value: {}
              itens:
                summary: Chosen items
                value:
                  items:
                    - productId: 5d2f7a1c-3b4e-4f6a-8d9c-0e1f2a3b4c5d
                      quantity: 2
                      optionIds: [9a8b7c6d-5e4f-4a3b-9c2d-1e0f9a8b7c6d]
      responses:
        '201':
          description: Order created and paid. Follow `nextStep`.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/SandboxTestOrder' }
              example:
                orderId: 7b1e4c9a-2f3d-4a5b-8c6d-9e0f1a2b3c4d
                displayId: PED-00042
                orderURL: https://sandbox.skyfood.io/v1/orders/7b1e4c9a-2f3d-4a5b-8c6d-9e0f1a2b3c4d
                lastEvent: CREATED
                robot: null
                nextStep: confirm
        '401': { $ref: '#/components/responses/Unauthorized' }
        '409': { $ref: '#/components/responses/SandboxConflict' }
        '422':
          description: '`validation_failed`, `option_group_min`, `option_group_max`: the `items` don''t fit the store''s menu.'
          content:
            application/problem+json:
              schema: { $ref: '#/components/schemas/Error' }
        '429': { $ref: '#/components/responses/TooManyRequests' }
    delete:
      operationId: sandboxReset
      tags: [Sandbox]
      summary: Clear the store's queue
      description: |
        Starts over from scratch: cancels (as the store) your test orders that aren't in the robot yet and
        acknowledges all of the store's pending events. Orders already in the robot finish on their own (or ask for
        `unload`).
      responses:
        '200':
          description: What was cleared.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/SandboxReset' }
              example: { cancelled: 2, acknowledged: 7 }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '429': { $ref: '#/components/responses/TooManyRequests' }

  /od-sandbox/v1/test-orders/{orderId}:
    servers:
      - url: https://sandbox.skyfood.io
        description: Sandbox
    parameters:
      - $ref: '#/components/parameters/OrderId'
    get:
      operationId: sandboxGetTestOrder
      tags: [Sandbox]
      summary: Test order status
      description: The order's last event, the robot's state and who acts now (`nextStep`).
      responses:
        '200':
          description: Status.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/SandboxTestOrder' }
              example:
                orderId: 7b1e4c9a-2f3d-4a5b-8c6d-9e0f1a2b3c4d
                displayId: PED-00042
                orderURL: https://sandbox.skyfood.io/v1/orders/7b1e4c9a-2f3d-4a5b-8c6d-9e0f1a2b3c4d
                lastEvent: READY_FOR_PICKUP
                robot: at_station
                nextStep: load
        '401': { $ref: '#/components/responses/Unauthorized' }
        '404': { $ref: '#/components/responses/SandboxOrderNotFound' }
        '429': { $ref: '#/components/responses/TooManyRequests' }

  /od-sandbox/v1/test-orders/{orderId}/load:
    servers:
      - url: https://sandbox.skyfood.io
        description: Sandbox
    parameters:
      - $ref: '#/components/parameters/OrderId'
    post:
      operationId: sandboxLoad
      tags: [Sandbox]
      summary: The store puts the order in the robot
      description: |
        With the robot at the store (`nextStep: load`): the staff opens the compartment, puts the order in, closes
        it and sends the robot off. You receive `DISPATCHED`. Before the robot arrives → `409 sandbox_robot_not_at_store`.
      responses:
        '200': { $ref: '#/components/responses/SandboxStepDone' }
        '202': { $ref: '#/components/responses/SandboxStepPending' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '404': { $ref: '#/components/responses/SandboxOrderNotFound' }
        '409': { $ref: '#/components/responses/SandboxConflict' }
        '429': { $ref: '#/components/responses/TooManyRequests' }

  /od-sandbox/v1/test-orders/{orderId}/collect:
    servers:
      - url: https://sandbox.skyfood.io
        description: Sandbox
    parameters:
      - $ref: '#/components/parameters/OrderId'
    post:
      operationId: sandboxCollect
      tags: [Sandbox]
      summary: The customer collects the order
      description: |
        With the robot at the customer's gate (`nextStep: collect`): the customer opens the compartment, takes the
        order out and closes it. You receive `DELIVERED` and `CONCLUDED`. Robot not at the customer →
        `409 sandbox_robot_not_at_customer`.
      responses:
        '200': { $ref: '#/components/responses/SandboxStepDone' }
        '202': { $ref: '#/components/responses/SandboxStepPending' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '404': { $ref: '#/components/responses/SandboxOrderNotFound' }
        '409': { $ref: '#/components/responses/SandboxConflict' }
        '429': { $ref: '#/components/responses/TooManyRequests' }

  /od-sandbox/v1/test-orders/{orderId}/unload:
    servers:
      - url: https://sandbox.skyfood.io
        description: Sandbox
    parameters:
      - $ref: '#/components/parameters/OrderId'
    post:
      operationId: sandboxUnload
      tags: [Sandbox]
      summary: The store takes out a returned order
      description: |
        With the order back at the store (`nextStep: unload`: not collected in time, or cancelled with the robot
        already loaded): the staff opens it, takes the order out and closes it, and the robot is free. Nothing to take
        out → `409 sandbox_nothing_to_unload`.
      responses:
        '200': { $ref: '#/components/responses/SandboxStepDone' }
        '202': { $ref: '#/components/responses/SandboxStepPending' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '404': { $ref: '#/components/responses/SandboxOrderNotFound' }
        '409': { $ref: '#/components/responses/SandboxConflict' }
        '429': { $ref: '#/components/responses/TooManyRequests' }

  /od-sandbox/v1/test-orders/{orderId}/cancel:
    servers:
      - url: https://sandbox.skyfood.io
        description: Sandbox
    parameters:
      - $ref: '#/components/parameters/OrderId'
    post:
      operationId: sandboxCancel
      tags: [Sandbox]
      summary: The customer cancels the order
      description: |
        The customer cancels in the app, without asking the store: allowed until the robot is loaded. You receive
        `CANCELLED` with `metadata.code: CONSUMER_CANCELLATION_REQUESTED`. After `load` → `409 order_not_cancellable`.
        Repeating it has no effect.
      responses:
        '200':
          description: Cancelled.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/SandboxTestOrder' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '404': { $ref: '#/components/responses/SandboxOrderNotFound' }
        '409': { $ref: '#/components/responses/SandboxConflict' }
        '429': { $ref: '#/components/responses/TooManyRequests' }

components:
  securitySchemes:
    odClient:
      type: oauth2
      description: |
        The store's token in `Authorization: Bearer <access_token>`, obtained at `POST /oauth/token` with the store's
        `client_id` and `client_secret`, on the same server as the routes (production or sandbox).
      flows:
        clientCredentials:
          tokenUrl: /oauth/token
          x-scalar-credentials-location: body
          scopes: {}

  parameters:
    OrderId:
      name: orderId
      in: path
      required: true
      description: The event's `orderId`.
      schema: { type: string, format: uuid }

  requestBodies:
    OptionalAction:
      required: false
      content:
        application/json:
          schema:
            type: object
            description: Optional, as in Open Delivery. SkyFood records the body; it has no effect on the order.

  responses:
    Unauthorized:
      description: |
        - `token_missing`: `Authorization: Bearer` is missing.
        - `token_invalid`: unknown or revoked token. Request another.
        - `token_expired`: expired token. Request another.
      content:
        application/problem+json:
          schema: { $ref: '#/components/schemas/Error' }
          example:
            type: about:blank
            title: Unauthorized
            status: 401
            code: token_expired
            request_id: 4f1c9a7e2b6d8e0f3a5c7b9d
    OrderNotFound:
      description: '`order_not_found`: the order doesn''t exist or doesn''t belong to the token''s store.'
      content:
        application/problem+json:
          schema: { $ref: '#/components/schemas/Error' }
          example:
            type: about:blank
            title: Not Found
            status: 404
            code: order_not_found
            request_id: 4f1c9a7e2b6d8e0f3a5c7b9d
    ActionRejected:
      description: |
        - `od_action_repeated`: the action was already taken on this order (`event_type` says which). Treat it as
          success.
        - `od_order_finished`: the order was already delivered or cancelled. There's nothing more to do.
      content:
        application/problem+json:
          schema: { $ref: '#/components/schemas/Error' }
          example:
            type: about:blank
            title: Unprocessable Entity
            status: 422
            code: od_action_repeated
            detail: instruction already sent for this order
            event_type: READY_FOR_PICKUP
            request_id: 4f1c9a7e2b6d8e0f3a5c7b9d
    TooManyRequests:
      description: '`rate_limited`: request limit exceeded. Try again after `Retry-After` seconds.'
      headers:
        Retry-After:
          description: Seconds until the next attempt.
          schema: { type: integer }
      content:
        application/problem+json:
          schema: { $ref: '#/components/schemas/Error' }
          example:
            type: about:blank
            title: Too Many Requests
            status: 429
            code: rate_limited
            retry_after_s: 2
            request_id: 4f1c9a7e2b6d8e0f3a5c7b9d
    SandboxStepDone:
      description: Step done. Follow `nextStep`.
      content:
        application/json:
          schema: { $ref: '#/components/schemas/SandboxTestOrder' }
          example:
            orderId: 7b1e4c9a-2f3d-4a5b-8c6d-9e0f1a2b3c4d
            displayId: PED-00042
            orderURL: https://sandbox.skyfood.io/v1/orders/7b1e4c9a-2f3d-4a5b-8c6d-9e0f1a2b3c4d
            lastEvent: DISPATCHED
            robot: to_destination
            nextStep: wait_delivery
    SandboxStepPending:
      description: The robot didn't confirm the doors within about 20 seconds; call again and the step picks up where it left off.
      content:
        application/json:
          schema: { $ref: '#/components/schemas/SandboxTestOrder' }
    SandboxOrderNotFound:
      description: '`sandbox_order_not_found`: there''s no test order with that id at the token''s store.'
      content:
        application/problem+json:
          schema: { $ref: '#/components/schemas/Error' }
    SandboxConflict:
      description: |
        Wrong moment for the step (see `nextStep` in `GET /od-sandbox/v1/test-orders/{orderId}`):

        - `sandbox_robot_not_at_store`, `sandbox_robot_not_at_customer`, `sandbox_nothing_to_unload`: the robot isn't
          where the step needs it.
        - `order_not_cancellable`: the order is already in the robot (or was delivered).
        - `store_closed`, `product_unavailable`, `option_unavailable`: the store is closed or the item unavailable.
        - `sandbox_no_available_product`, `sandbox_store_not_ready`: the store has no available product or isn't
          ready; contact SkyFood.
      content:
        application/problem+json:
          schema: { $ref: '#/components/schemas/Error' }
          example:
            type: about:blank
            title: Conflict
            status: 409
            code: sandbox_robot_not_at_store
            detail: the robot is not at the store with this order
            request_id: 4f1c9a7e2b6d8e0f3a5c7b9d

  examples:
    Order:
      summary: Order paid by card, delivered at gate B24
      value:
        id: 7b1e4c9a-2f3d-4a5b-8c6d-9e0f1a2b3c4d
        type: DELIVERY
        displayId: PED-48213
        sourceAppId: 5a7c3e1f-8b2d-4f6a-9c0e-1d3b5f7a9c2e
        salesChannel: SkyFood
        category: FOOD
        createdAt: '2026-10-06T11:58:40+00:00'
        lastEvent: CREATED
        orderTiming: INSTANT
        preparationStartDateTime: '2026-10-06T12:00:00+00:00'
        merchant: { id: 22815773000169-dbc7e35a-c936-4665-9e13-eb55eb8b6824, name: Café do Embarque }
        items:
          - id: 5d2f7a1c-3b4e-4f6a-8d9c-0e1f2a3b4c5d
            index: 0
            name: Café coado
            externalCode: CAFE-COADO
            unit: UN
            quantity: 1
            specialInstructions: ''
            unitPrice: { value: 8.90, currency: BRL }
            optionsPrice: { value: 2.50, currency: BRL }
            subtotalPrice: { value: 8.90, currency: BRL }
            totalPrice: { value: 11.40, currency: BRL }
            options:
              - index: 0
                id: 9a8b7c6d-5e4f-4a3b-9c2d-1e0f9a8b7c6d
                name: Grande
                externalCode: TAM-G
                unit: UN
                quantity: 1
                unitPrice: { value: 2.50, currency: BRL }
                totalPrice: { value: 2.50, currency: BRL }
        otherFees: []
        discounts:
          - amount: { value: 1.14, currency: BRL }
            target: CART
            sponsorshipValues:
              - { name: MARKETPLACE, amount: { value: 1.14, currency: BRL }, discountCode: skyfood }
        total:
          itemsPrice: { value: 11.40, currency: BRL }
          otherFees: { value: 0.00, currency: BRL }
          discount: { value: 1.14, currency: BRL }
          orderAmount: { value: 10.26, currency: BRL }
        payments:
          prepaid: 10.26
          pending: 0.00
          methods:
            - { value: 10.26, currency: BRL, type: PREPAID, method: CREDIT, brand: MASTERCARD, methodInfo: CARTAO_CREDITO, changeFor: 0.00 }
        customer:
          id: 3c4d5e6f-7a8b-4c9d-8e0f-1a2b3c4d5e6f
          name: Ana Souza
          phone: { number: '11987654321' }
          ordersCountOnMerchant: 1
        delivery:
          deliveredBy: MARKETPLACE
          deliveryAddress:
            country: BR
            state: ''
            city: ''
            district: ''
            street: Portão B24
            number: S/N
            complement: Terminal 2
            reference: Aeroporto Internacional
            formattedAddress: Portão B24 · Terminal 2
            postalCode: ''
            coordinates: { latitude: 0, longitude: 0 }
          estimatedDeliveryDateTime: '2026-10-06T12:35:00+00:00'
        sendPreparing: true
        sendDelivered: false
        sendPickedUp: false
        sendTracking: false
        extraInfo: Entrega por robô SkyFood em Portão B24 · Terminal 2. A loja entrega o pedido ao robô na estação.

  schemas:
    TokenRequest:
      type: object
      required: [grant_type, client_id, client_secret]
      properties:
        grant_type: { type: string, enum: [client_credentials] }
        client_id: { type: string }
        client_secret: { type: string }

    TokenResponse:
      type: object
      required: [access_token, token_type, expires_in]
      properties:
        access_token: { type: string, description: Opaque token. }
        token_type: { type: string, enum: [bearer] }
        expires_in: { type: integer, description: Validity in seconds. }

    Error:
      type: object
      description: Problem Details (RFC 9457), compatible with Open Delivery's `Error`.
      required: [title, status, code]
      properties:
        type: { type: string }
        title: { type: string, description: HTTP status text. }
        status: { type: integer }
        code: { type: string, description: Stable error code; use it to decide what to do. }
        detail: { type: string }
        error: { type: string, description: OAuth code (only at `/oauth/token`). }
        event_type: { type: string, description: 'In `od_action_repeated`, the event the action already generated.' }
        retry_after_s: { type: integer, description: 'In `rate_limited`, seconds until trying again.' }
        request_id: { type: string, description: Give it to SkyFood support. }

    EventType:
      type: string
      enum:
        - CREATED
        - CONFIRMED
        - READY_FOR_PICKUP
        - DISPATCHED
        - DELIVERED
        - CONCLUDED
        - CANCELLATION_REQUESTED
        - CANCELLED
        - CANCELLATION_REQUEST_DENIED

    Event:
      type: object
      required: [eventId, eventType, orderId, orderURL, createdAt]
      properties:
        eventId: { type: string, format: uuid }
        eventType: { $ref: '#/components/schemas/EventType' }
        orderId: { type: string, format: uuid }
        orderURL: { type: string, format: uri, description: 'Where to fetch the order (`GET /v1/orders/{orderId}`).' }
        createdAt: { type: string, format: date-time, description: 'UTC, for example `2026-10-06T12:00:00+00:00`.' }
        sourceAppId: { type: string, description: SkyFood's AppId. }
        metadata:
          type: object
          description: In cancellation events, `reason`, `code` (from the `CancellationCode` list) and `mode`.
          properties:
            reason: { type: string }
            code: { type: string }
            mode: { type: string }

    EventAck:
      type: object
      required: [id]
      properties:
        id: { type: string, format: uuid, description: 'The event''s `eventId`.' }
        orderId: { type: string, format: uuid }
        eventType: { type: string }

    Price:
      type: object
      required: [value, currency]
      properties:
        value: { type: number, description: 'Amount in reais, with two decimal places.' }
        currency: { type: string, examples: [BRL] }

    Order:
      type: object
      description: 'Open Delivery''s `Order` with the fields SkyFood sends.'
      required: [id, type, displayId, createdAt, orderTiming, preparationStartDateTime, merchant, items, total, payments]
      properties:
        id: { type: string, format: uuid }
        type: { type: string, description: Always `DELIVERY`. }
        displayId: { type: string, description: Order number in the app. }
        sourceAppId: { type: string }
        salesChannel: { type: string }
        category: { type: string }
        createdAt: { type: string, format: date-time }
        lastEvent: { type: string, description: The order's last event. }
        orderTiming: { type: string, description: Always `INSTANT`. }
        preparationStartDateTime: { type: string, format: date-time, description: When the order reached the store. }
        merchant:
          type: object
          required: [id, name]
          properties:
            id: { type: string, description: 'The store''s `merchant_id`.' }
            name: { type: string }
        items:
          type: array
          items:
            type: object
            required: [id, name, quantity, unitPrice, totalPrice]
            properties:
              id: { type: string, format: uuid }
              index: { type: integer }
              name: { type: string }
              externalCode: { type: string, description: The item's code in your menu. }
              unit: { type: string }
              quantity: { type: integer }
              specialInstructions: { type: string, description: The customer's note. }
              unitPrice: { $ref: '#/components/schemas/Price' }
              optionsPrice: { $ref: '#/components/schemas/Price' }
              subtotalPrice: { $ref: '#/components/schemas/Price' }
              totalPrice: { $ref: '#/components/schemas/Price' }
              options:
                type: array
                items:
                  type: object
                  required: [id, name, quantity, unitPrice]
                  properties:
                    index: { type: integer }
                    id: { type: string, format: uuid }
                    name: { type: string }
                    externalCode: { type: string, description: The option's code in your menu. }
                    unit: { type: string }
                    quantity: { type: integer }
                    unitPrice: { $ref: '#/components/schemas/Price' }
                    totalPrice: { $ref: '#/components/schemas/Price' }
        otherFees: { type: array, items: { type: object } }
        discounts:
          type: array
          description: SkyFood discount (`MARKETPLACE`) and store coupon (`MERCHANT`), always on the cart.
          items:
            type: object
            properties:
              amount: { $ref: '#/components/schemas/Price' }
              target: { type: string }
              sponsorshipValues:
                type: array
                items:
                  type: object
                  properties:
                    name: { type: string }
                    amount: { $ref: '#/components/schemas/Price' }
                    discountCode: { type: string }
        total:
          type: object
          required: [itemsPrice, otherFees, orderAmount]
          properties:
            itemsPrice: { $ref: '#/components/schemas/Price' }
            otherFees: { $ref: '#/components/schemas/Price' }
            discount: { $ref: '#/components/schemas/Price' }
            orderAmount: { $ref: '#/components/schemas/Price' }
        payments:
          type: object
          required: [prepaid, pending, methods]
          properties:
            prepaid: { type: number, description: Already paid in the app. }
            pending: { type: number, description: 'To be charged (only a room charge, collected by the hotel).' }
            methods:
              type: array
              items:
                type: object
                properties:
                  value: { type: number }
                  currency: { type: string }
                  type: { type: string, description: '`PREPAID` or `PENDING`.' }
                  method: { type: string, description: '`PIX`, `CREDIT` or `OTHER` (room charge).' }
                  brand: { type: string }
                  methodInfo: { type: string }
                  changeFor: { type: number }
        customer:
          type: object
          properties:
            id: { type: string, format: uuid }
            name: { type: string }
            phone:
              type: object
              properties:
                number: { type: string, description: Digits only; Brazilian numbers without the 55. }
            ordersCountOnMerchant: { type: integer }
        delivery:
          type: object
          properties:
            deliveredBy: { type: string, description: '`MARKETPLACE`: SkyFood delivers with the robot.' }
            deliveryAddress:
              type: object
              description: The robot's delivery point. Only `formattedAddress`, `street`, `complement` and `reference` are filled in.
              properties:
                country: { type: string }
                state: { type: string }
                city: { type: string }
                district: { type: string }
                street: { type: string }
                number: { type: string }
                complement: { type: string }
                reference: { type: string }
                formattedAddress: { type: string }
                postalCode: { type: string }
                coordinates:
                  type: object
                  properties:
                    latitude: { type: number }
                    longitude: { type: number }
            estimatedDeliveryDateTime: { type: string, format: date-time }
        sendPreparing: { type: boolean }
        sendDelivered: { type: boolean, description: '`false`: don''t call `delivered`.' }
        sendPickedUp: { type: boolean, description: '`false`: don''t call `pickedUp`.' }
        sendTracking: { type: boolean, description: '`false`: don''t call `tracking`.' }
        extraInfo: { type: string }

    CancellationCode:
      type: string
      enum:
        - SYSTEMIC_ISSUES
        - DUPLICATE_APPLICATION
        - UNAVAILABLE_ITEM
        - RESTAURANT_WITHOUT_DELIVERY_PERSON
        - OUTDATED_MENU
        - ORDER_OUTSIDE_THE_DELIVERY_AREA
        - BLOCKED_CUSTOMER
        - OUTSIDE_DELIVERY_HOURS
        - INTERNAL_DIFFICULTIES_OF_THE_RESTAURANT
        - RISK_AREA
        - DELIVERY_PROBLEM
        - CONSUMER_CANCELLATION_REQUESTED
        - OTHER_CANCELLATION_REASON

    CancellationRequest:
      type: object
      required: [code]
      properties:
        reason: { type: string, description: 'Reason for the cancellation, as free text.' }
        code: { $ref: '#/components/schemas/CancellationCode' }
        mode: { type: string, enum: [AUTO, MANUAL] }

    MerchantUpdate:
      type: object
      properties:
        merchantStatus: { type: string, enum: [AVAILABLE, UNAVAILABLE], description: Opens or closes the store. }
        entityType:
          type: string
          enum: [MERCHANT, BASIC_INFO, SERVICE, MENU, CATEGORY, ITEM, ITEM_OFFER, OPTION_GROUP, OPTION, AVAILABILITY]
        updatedObjects:
          type: array
          minItems: 1
          description: |
            Required with `entityType`. With `MERCHANT`, the complete `Merchant`s; `itemOffers[]`, `items[]` and
            `categories[]` accept the optional `x-skyfood` member (`SkyfoodFields`).
          items: { type: object }

    SkyfoodFields:
      type: object
      description: |
        The `x-skyfood` member (outside the OD standard) of `itemOffers[]` and `items[]`; in `categories[]`, only
        `category`. Field by field, the offer beats the item, which beats the category; a missing field keeps the
        current value. An unknown member → `400 merchant_update_invalid`.
      additionalProperties: false
      properties:
        category:
          type: string
          enum: [cafe, lanches, refeicoes, saudavel, doces, bebidas]
          description: Display category (current list at `GET /v1/skyfood/catalog`).
        featured: { type: boolean, description: Featured at the top of the store and in "Para pedir agora" (Order now). }
        alcoholic: { type: boolean, description: 'Alcoholic drink: the order requires "Tenho 18 anos ou mais" (I''m 18 or older).' }
        translations:
          type: object
          description: Replaces all of the product's translations; empty text is discarded.
          additionalProperties: false
          properties:
            en: { $ref: '#/components/schemas/SkyfoodTexts' }
            es: { $ref: '#/components/schemas/SkyfoodTexts' }
      example:
        category: bebidas
        featured: true
        alcoholic: true
        translations:
          en: { name: Long neck beer, description: '355 ml, ice cold' }
          es: { name: Cerveza long neck }

    SkyfoodTexts:
      type: object
      additionalProperties: false
      properties:
        name: { type: string }
        description: { type: string }

    SkyfoodCatalog:
      type: object
      description: SkyFood's vocabulary for the menu (`GET /v1/skyfood/catalog`).
      required: [categories, fields, languages, images, texts, options]
      properties:
        categories:
          type: array
          description: The fixed display categories, in the app's order (`index` 0 first).
          items:
            type: object
            required: [slug, index, name, names]
            properties:
              slug: { type: string, description: 'Value of `x-skyfood.category`.' }
              index: { type: integer }
              name: { type: string, description: Name in Portuguese. }
              names:
                type: object
                description: Name per language (pt, en, es).
                additionalProperties: { type: string }
        fields:
          type: array
          description: Members accepted in `x-skyfood`.
          items:
            type: object
            required: [name, type, in, override, description]
            properties:
              name: { type: string }
              type: { type: string, enum: [string, boolean, object] }
              in: { type: array, items: { type: string }, description: 'Where it goes: `itemOffers[]`, `items[]`, `categories[]`.' }
              values: { type: array, items: { type: string }, description: Accepted values (category). }
              languages: { type: array, items: { type: string }, description: Accepted languages (translations). }
              textFields: { type: array, items: { type: string }, description: Translatable fields (translations). }
              override: { type: string, description: 'Name of the field in `x-skyfood.overrides` when the store adjusts it.' }
              description: { type: string }
        languages:
          type: array
          items:
            type: object
            required: [code, base, description]
            properties:
              code: { type: string, enum: [pt, en, es] }
              base: { type: boolean, description: 'The language of the item''s `name`/`description`.' }
              description: { type: string }
        images:
          type: object
          required: [formats, maxBytes, aspectRatio, recommendedWidth, recommendedHeight, recommendedBytes, description]
          properties:
            formats: { type: array, items: { type: string } }
            maxBytes: { type: integer, description: Maximum size accepted for the copy. }
            aspectRatio: { type: string, description: Recommended aspect ratio. }
            recommendedWidth: { type: integer }
            recommendedHeight: { type: integer }
            recommendedBytes: { type: integer }
            description: { type: string }
        texts:
          type: array
          items:
            type: object
            required: [field, required, maxLength, recommendedLength, display]
            properties:
              field: { type: string }
              required: { type: boolean }
              maxLength: { type: [integer, 'null'], description: Limit enforced by SkyFood; null for no limit. }
              recommendedLength: { type: integer, description: Length that fits well in the app. }
              display: { type: string, description: How the app shows the text. }
        options:
          type: array
          description: How the app shows option groups.
          items:
            type: object
            required: [rule, when, display]
            properties:
              rule: { type: string }
              when: { type: string }
              display: { type: string }

    SandboxTestOrderRequest:
      type: object
      properties:
        items:
          type: array
          minItems: 1
          maxItems: 20
          items: { $ref: '#/components/schemas/SandboxItem' }

    SandboxItem:
      type: object
      required: [productId, quantity]
      properties:
        productId: { type: string, format: uuid, description: 'A product from your sandbox store (the `items[].id` in orders).' }
        quantity: { type: integer, minimum: 1, maximum: 20 }
        optionIds:
          type: array
          description: Chosen options (the `items[].options[].id` in orders).
          items: { type: string, format: uuid }

    SandboxTestOrder:
      type: object
      required: [orderId, displayId, orderURL, lastEvent, robot, nextStep]
      properties:
        orderId: { type: string, format: uuid, description: '`orderId` of the events and of `GET /v1/orders/{orderId}`.' }
        displayId: { type: string, description: Order number in the app. }
        orderURL: { type: string, format: uri }
        lastEvent: { type: [string, 'null'], description: The order's last event. }
        robot:
          type: [string, 'null']
          description: |
            Where the robot is: `scheduled`/`to_station` (on its way to the store), `at_station`/`loading` (at the
            store), `to_destination` (on its way to the customer), `at_destination` (at the customer), `collected`
            (collected), `returning` (coming back with the order), `awaiting_unload` (back at the store), `unloaded`,
            `cancelled`. `null` before `readyForPickup`.
        nextStep:
          type: string
          enum: [confirm, readyForPickup, wait_robot, load, wait_delivery, collect, wait_return, unload, done, returned, cancelled]
          description: Who acts now (table in the **Sandbox** section).

    SandboxReset:
      type: object
      required: [cancelled, acknowledged]
      properties:
        cancelled: { type: integer, description: Test orders cancelled. }
        acknowledged: { type: integer, description: Events acknowledged. }
