> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fooddelivery.cl/llms.txt
> Use this file to discover all available pages before exploring further.

# Obtener un pedido

> Detalle completo de un pedido. Un pedido de otro restaurante responde 404 (la API no revela la existencia de datos ajenos).




## OpenAPI

````yaml /openapi.yaml get /orders/{order_id}
openapi: 3.1.0
info:
  title: FoodDelivery API
  version: '1.0'
  description: |
    API pública de FoodDelivery, v1.
    Lectura con cualquier llave; los endpoints de escritura requieren una
    llave con el permiso de escritura (se define al generarla en el panel).
    Las llaves sandbox (`fd_test_`) usan estos mismos endpoints en modo
    prueba: pedidos marcados PRUEBA, pago simulado y stock/local sin efecto
    real (ver la guía Sandbox).
    Montos en CLP sin decimales; fechas ISO 8601 en horario de Chile
    (America/Santiago).
servers:
  - url: https://app.fooddelivery.cl/api/v1
security:
  - apiKey: []
tags:
  - name: Pedidos
  - name: Menú
  - name: Inventario
  - name: Locales
paths:
  /orders/{order_id}:
    get:
      tags:
        - Pedidos
      summary: Obtener un pedido
      description: >
        Detalle completo de un pedido. Un pedido de otro restaurante responde
        404 (la API no revela la existencia de datos ajenos).
      operationId: getOrder
      parameters:
        - name: order_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: Detalle completo del pedido.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Order'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  schemas:
    Order:
      type: object
      properties:
        id:
          type: string
          format: uuid
        number:
          type: string
          description: Número corto visible para el cliente.
          examples:
            - '#0041-150726'
        status:
          $ref: '#/components/schemas/OrderStatus'
        type:
          type: string
          enum:
            - delivery
            - retiro
        location_id:
          type: string
          format: uuid
          nullable: true
        customer:
          type: object
          properties:
            name:
              type: string
              nullable: true
            phone:
              type: string
              nullable: true
            email:
              type: string
              nullable: true
        address:
          type: string
          nullable: true
          description: Dirección de entrega (solo pedidos delivery).
        items:
          type: array
          items:
            type: object
            properties:
              product_id:
                type: string
                format: uuid
                nullable: true
              name:
                type: string
              quantity:
                type: integer
              unit_price:
                type: integer
                description: Precio unitario en CLP, con modificadores incluidos.
              notes:
                type: string
                nullable: true
              modifiers:
                type: array
                items:
                  type: object
                  properties:
                    group:
                      type: string
                      nullable: true
                      description: Nombre del grupo de modificadores.
                    name:
                      type: string
                      nullable: true
                      description: Opción elegida.
                    price:
                      type: integer
        subtotal:
          type: integer
        shipping_fee:
          type: integer
          description: Costo de envío cobrado al cliente, en CLP.
        discount:
          type: integer
          description: Descuento aplicado (cupones/promociones), en CLP.
        total:
          type: integer
          description: Total pagado por el cliente, en CLP.
        payment:
          type: object
          properties:
            method:
              type: string
              nullable: true
              description: >
                Medio elegido por el cliente: `transferencia`, `tarjeta` o
                `apple_pay` (pago online vía Fintoc), o `efectivo` (pago
                presencial).
            paid:
              type: boolean
              description: >
                true si hay un cobro online confirmado. Los pedidos con pago
                presencial (efectivo) siempre reportan false.
        delivery:
          type: object
          nullable: true
          description: null en pedidos de retiro o sin despacho asociado.
          properties:
            provider:
              type: string
              enum:
                - uber
                - pedidosya
                - propio
            status:
              type: string
              nullable: true
              description: Estado del despacho según el proveedor.
            tracking_url:
              type: string
              nullable: true
              description: null para reparto propio.
        scheduled_for:
          type: string
          format: date-time
          nullable: true
          description: Fecha-hora comprometida si es un pedido programado.
        created_at:
          type: string
          format: date-time
    OrderStatus:
      type: string
      description: >
        `pendiente_pago` = esperando el pago online; `programado` = pagado pero
        retenido hasta su fecha-hora (pedidos programados); el resto es el flujo
        de cocina y despacho.
      enum:
        - pendiente_pago
        - programado
        - recibido
        - en_preparacion
        - listo
        - en_reparto
        - entregado
        - cancelado
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - invalid_request
                - unauthorized
                - forbidden
                - not_found
                - location_closed
                - location_inactive
                - insufficient_stock
                - illegal_transition
                - managed_by_integrator
                - state_conflict
                - payment_unavailable
                - rate_limited
                - internal_error
            message:
              type: string
  responses:
    Unauthorized:
      description: API key ausente, inválida o revocada.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: El recurso no existe o pertenece a otro restaurante.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    RateLimited:
      description: Límite de peticiones excedido; ver header `Retry-After`.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: >
        API key del restaurante, generada en el panel de administración
        (Integraciones → API pública): `fd_live_...` para producción o
        `fd_test_...` para sandbox (modo prueba sobre el mismo restaurante).

````