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

# Solicitação de nova entrega

> Cria uma nova solicitação de entrega no sistema logístico.

Este endpoint permite criar uma nova entrega com todas as informações necessárias, incluindo endereços de coleta e entrega, dados do cliente, informações de pagamento e configurações do veículo.

**Importante:**

* A requisição é processada de forma assíncrona
* A resposta retorna um `deliveryId` que deve ser usado para rastrear o status da entrega
* O endpoint retorna status 202 (Accepted) quando a entrega é aceita para processamento
* É necessário estar autenticado com token OAuth válido


## OpenAPI

````yaml POST /v1/logistics/delivery
openapi: 3.1.0
info:
  title: API Módulo Logístico
  description: >
    API para integração com o módulo logístico do OpenDelivery.


    Esta API utiliza autenticação OAuth 2.0 com o fluxo Client Credentials para
    obter tokens de acesso.

    Todos os endpoints protegidos requerem o token de acesso no header
    Authorization.
  version: 1.2.0
  contact:
    name: Suporte OpenDelivery
servers:
  - url: https://opendelivery.gohusky.net/logistic
    description: Servidor de produção
  - url: https://sandbox.opendelivery.gohusky.net/logistic
    description: Servidor Homologação
security: []
tags:
  - name: Autenticação
    description: Endpoints relacionados à autenticação e obtenção de tokens de acesso
  - name: Entregas
    description: Endpoints relacionados à gestão de entregas e pedidos logísticos
paths:
  /v1/logistics/delivery:
    post:
      tags:
        - Entregas
      summary: Solicitar nova entrega
      description: Cria uma nova solicitação de entrega no sistema logístico.
      operationId: requestNewDelivery
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NewDeliveryRequest'
            examples:
              basic_delivery:
                summary: Entrega básica
                value:
                  orderId: ORDER-12345
                  orderDisplayId: ORD-12345
                  merchant:
                    id: MERCHANT-001
                    name: Restaurante Exemplo
                  pickupAddress:
                    country: Brasil
                    state: SP
                    city: São Paulo
                    district: Centro
                    street: Rua Exemplo
                    number: '123'
                    postalCode: 01310-100
                    complement: Apto 45
                    reference: Próximo ao metrô
                    latitude: -23.5505
                    longitude: -46.6333
                    pickupLocation: Balcão
                    parkingSpace: true
                    instructions: Entregar na recepção
                  notifyPickup: true
                  notifyConclusion: true
                  returnToMerchant: false
                  canCombine: false
                  deliveryAddress:
                    country: Brasil
                    state: SP
                    city: São Paulo
                    district: Pinheiros
                    street: Av. Exemplo
                    number: '456'
                    postalCode: 05433-000
                    complement: null
                    reference: Edifício exemplo
                    latitude: -23.5675
                    longitude: -46.6925
                    pickupLocation: null
                    parkingSpace: false
                    instructions: Entregar no portão
                  customerName: João Silva
                  customerPhone: '+5511999999999'
                  vehicle:
                    type:
                      - MOTORBIKE_BAG
                    container: NORMAL
                    containerSize: null
                    instruction: null
                  limitTimes:
                    pickupLimit: 30
                    deliveryLimit: 60
                    orderCreatedAt: '2024-01-15T10:30:00.000Z'
                  totalOrderPrice:
                    value: 45.5
                    currency: BRL
                  orderDeliveryFee:
                    value: 8.5
                    currency: BRL
                  totalWeight: 500
                  packageVolume: 2000
                  packageQuantity: 1
                  specialInstructions: Produto frágil
                  additionalPricePercentual: null
                  payments:
                    method: ONLINE
                    wirelessPos: false
                    offlineMethod: null
                    change: null
                  combinedOrdersIds: null
                  sourceAppId: null
                  sourceOrderId: null
                  customerPhoneLocalizer: null
              offline_payment:
                summary: Entrega com pagamento offline
                value:
                  orderId: ORDER-12346
                  orderDisplayId: ORD-12346
                  merchant:
                    id: MERCHANT-001
                    name: Restaurante Exemplo
                  pickupAddress:
                    country: Brasil
                    state: SP
                    city: São Paulo
                    district: Centro
                    street: Rua Exemplo
                    number: '123'
                    postalCode: 01310-100
                    latitude: -23.5505
                    longitude: -46.6333
                  notifyPickup: true
                  notifyConclusion: true
                  returnToMerchant: false
                  canCombine: false
                  deliveryAddress:
                    country: Brasil
                    state: SP
                    city: São Paulo
                    district: Pinheiros
                    street: Av. Exemplo
                    number: '456'
                    postalCode: 05433-000
                    latitude: -23.5675
                    longitude: -46.6925
                  customerName: Maria Santos
                  customerPhone: '+5511888888888'
                  vehicle:
                    type:
                      - CAR
                    container: THERMIC
                    containerSize: MEDIUM
                    instruction: Manter refrigerado
                  limitTimes: null
                  totalOrderPrice:
                    value: 120
                    currency: BRL
                  orderDeliveryFee:
                    value: 15
                    currency: BRL
                  totalWeight: 2000
                  packageVolume: 5000
                  packageQuantity: 2
                  specialInstructions: null
                  additionalPricePercentual: null
                  payments:
                    method: OFFLINE
                    wirelessPos: true
                    offlineMethod:
                      - type: CREDIT
                        amount:
                          value: 100
                          currency: BRL
                      - type: CASH
                        amount:
                          value: 35
                          currency: BRL
                    change:
                      value: 15
                      currency: BRL
                  combinedOrdersIds: null
                  sourceAppId: APP-001
                  sourceOrderId: SRC-12346
                  customerPhoneLocalizer: null
      responses:
        '202':
          description: Entrega aceita para processamento
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NewDeliveryResponse'
              examples:
                success:
                  summary: Entrega criada com sucesso
                  value:
                    deliveryId: 123e4567-e89b-12d3-a456-426614174000
                    event: PENDING
                    completion:
                      estimate: '2024-01-15T11:30:00.000Z'
                      rejectAfter: '2024-01-15T12:00:00.000Z'
        '400':
          description: Requisição inválida
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalid_geocoding:
                  summary: Erro de geocodificação
                  value:
                    title: Endereço inválido ou não foi possível geocodificar
                    status: 400
                no_permission_geocode:
                  summary: Sem permissão para geocodificar
                  value:
                    title: >-
                      O Operador Logistico não tem permissão para geocodificar
                      endereços
                    status: 400
                unexpected_error:
                  summary: Erro inesperado
                  value:
                    title: Erro inesperado
                    status: 400
        '401':
          description: Não autorizado - Token inválido ou ausente
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  summary: Não autorizado
                  value:
                    title: Não autorizado
                    status: 401
        '422':
          description: Entidade não processável - Já existe uma entrega com o mesmo orderId
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                duplicate_order:
                  summary: Pedido duplicado
                  value:
                    title: Já existe um pedido com o mesmo orderId
                    status: 422
      security:
        - BearerAuth: []
components:
  schemas:
    NewDeliveryRequest:
      type: object
      required:
        - orderId
        - orderDisplayId
        - merchant
        - pickupAddress
        - returnToMerchant
        - canCombine
        - deliveryAddress
        - customerName
        - vehicle
        - totalOrderPrice
        - totalWeight
        - payments
      properties:
        orderId:
          type: string
          description: Identificador único do pedido no sistema do cliente
          example: ORDER-12345
        orderDisplayId:
          type: string
          description: Identificador de exibição do pedido
          example: ORD-12345
        merchant:
          $ref: '#/components/schemas/MerchantData'
        pickupAddress:
          $ref: '#/components/schemas/AddressData'
          description: Endereço de coleta do pedido.
        notifyPickup:
          type: boolean
          description: Se deve notificar quando a coleta for iniciada
          example: true
        notifyConclusion:
          type: boolean
          description: Se deve notificar quando a entrega for concluída
          example: true
        returnToMerchant:
          type: boolean
          description: >-
            Informa se o entregador deve retornar ao endereço de coleta após a
            entrega ter sido efetuada.
          example: false
        canCombine:
          type: boolean
          description: >-
            Informa se a logística pode combinar este pedido com outros pedidos
            na mesma entrega.
          example: false
        deliveryAddress:
          $ref: '#/components/schemas/AddressData'
          description: Endereço de entrega do pedido.
        customerName:
          type: string
          description: Nome do cliente
          example: João Silva
        customerPhone:
          type: string
          description: Telefone do cliente (formato internacional recomendado)
          example: '+5511999999999'
        vehicle:
          $ref: '#/components/schemas/VehicleData'
        limitTimes:
          $ref: '#/components/schemas/LimitTimesData'
        totalOrderPrice:
          $ref: '#/components/schemas/PriceData'
        orderDeliveryFee:
          $ref: '#/components/schemas/PriceData'
        totalWeight:
          type: integer
          description: Peso total do pedido em gramas
          minimum: 0
          example: 500
        packageVolume:
          type: integer
          description: Volume do pacote em centímetros cúbicos
          minimum: 0
          example: 2000
        packageQuantity:
          type: integer
          description: Quantidade de pacotes
          minimum: 1
          example: 1
        specialInstructions:
          type: string
          description: Instruções especiais para a entrega
          example: Produto frágil
        additionalPricePercentual:
          type: number
          format: float
          description: Percentual adicional no preço (0-100)
          minimum: 0
          maximum: 100
          example: 10.5
        payments:
          $ref: '#/components/schemas/PaymentsData'
        combinedOrdersIds:
          type: array
          description: IDs de pedidos combinados
          items:
            type: string
          example:
            - ORDER-123
            - ORDER-124
        sourceAppId:
          type: string
          description: ID da aplicação de origem
          example: APP-001
        sourceOrderId:
          type: string
          description: ID do pedido no sistema de origem
          example: SRC-12345
        customerPhoneLocalizer:
          type: string
          description: >-
            Código localizador. Usado hoje para integração de pedido Ifood, para
            o fluxo de confirmação de pedido.
          example: '12345678'
    NewDeliveryResponse:
      type: object
      required:
        - deliveryId
        - event
        - completion
      properties:
        deliveryId:
          type: string
          format: uuid
          description: Identificador único da entrega criada
          example: 123e4567-e89b-12d3-a456-426614174000
        event:
          type: string
          enum:
            - PENDING
          description: Status inicial do evento da entrega
          example: PENDING
        completion:
          type: object
          required:
            - estimate
            - rejectAfter
          properties:
            estimate:
              type: string
              format: date-time
              description: Data e hora estimada para conclusão da entrega (ISO 8601)
              example: '2024-01-15T11:30:00.000Z'
            rejectAfter:
              type: string
              format: date-time
              description: >-
                Data e hora após a qual a entrega será rejeitada automaticamente
                se não for aceita (ISO 8601)
              example: '2024-01-15T12:00:00.000Z'
    ErrorResponse:
      type: object
      required:
        - title
        - status
      properties:
        title:
          type: string
          description: Mensagem de erro descritiva
          example: Não autorizado
        status:
          type: integer
          description: Código de status HTTP
          example: 401
    MerchantData:
      type: object
      required:
        - id
        - name
      properties:
        id:
          type: string
          description: Identificador único do merchant
          example: MERCHANT-001
        name:
          type: string
          description: Nome do merchant
          example: Restaurante Exemplo
    AddressData:
      type: object
      required:
        - country
        - state
        - city
        - district
        - street
        - number
      properties:
        country:
          type: string
          description: País (sigla). Padrão ISO 3166-1.
          minLength: 2
          maxLength: 2
          exclusiveMinimum: true
          example: BR
        state:
          type: string
          description: Estado (sigla). Padrão ISO 3166-2.
          example: SP
        city:
          type: string
          description: Cidade
          example: São Paulo
        district:
          type: string
          description: Bairro
          example: Centro
        street:
          type: string
          description: Rua
          example: Rua Exemplo
        number:
          type: string
          description: Número
          example: '123'
        postalCode:
          type: string
          description: CEP
          example: 01310-100
        complement:
          type: string
          description: Complemento
          example: Apto 45
        reference:
          type: string
          description: Ponto de referência
          example: Próximo ao metrô
        latitude:
          type: number
          format: float
          description: Latitude do endereço
          example: -23.5505
        longitude:
          type: number
          format: float
          description: Longitude do endereço
          example: -46.6333
        pickupLocation:
          type: string
          description: Local de coleta específico
          example: Balcão
        parkingSpace:
          type: boolean
          description: Se há espaço para estacionamento
          example: true
        instructions:
          type: string
          description: Instruções específicas para o endereço
          example: Entregar na recepção
    VehicleData:
      allOf:
        - $ref: '#/components/schemas/VehicleRequiredData'
      properties:
        containerSize:
          type: string
          enum:
            - SMALL
            - MEDIUM
            - LARGE
            - EXTRA_LARGE
          description: Tamanho do container (opcional, apenas para container térmico)
          example: MEDIUM
        instruction:
          type: string
          description: Instruções específicas sobre o veículo/container
          example: Manter refrigerado
    LimitTimesData:
      type: object
      properties:
        pickupLimit:
          type: integer
          description: Tempo limite para coleta em minutos
          minimum: 0
          example: 30
        deliveryLimit:
          type: integer
          description: Tempo limite para entrega em minutos
          minimum: 0
          example: 60
        orderCreatedAt:
          type: string
          format: date-time
          description: Data e hora de criação do pedido (ISO 8601)
          example: '2024-01-15T10:30:00.000Z'
    PriceData:
      type: object
      required:
        - value
        - currency
      properties:
        value:
          type: number
          format: float
          description: Valor monetário
          minimum: 0
          example: 45.5
        currency:
          type: string
          enum:
            - BRL
            - USD
            - EUR
          description: Moeda. Padrão ISO 4217.
          minLength: 3
          maxLength: 3
          exclusiveMinimum: true
          example: BRL
    PaymentsData:
      type: object
      required:
        - method
      properties:
        method:
          type: string
          enum:
            - ONLINE
            - OFFLINE
          description: Método de pagamento
          example: ONLINE
        wirelessPos:
          type: boolean
          description: Se deve usar máquina de cartão sem fio
          example: false
        offlineMethod:
          type: array
          description: Métodos de pagamento offline (obrigatório quando method é OFFLINE)
          items:
            $ref: '#/components/schemas/PaymentOfflineMethodData'
          example:
            - type: CREDIT
              amount:
                value: 100
                currency: BRL
        change:
          $ref: '#/components/schemas/PriceData'
          description: Valor de troco necessário
    VehicleRequiredData:
      type: object
      required:
        - type
        - container
      properties:
        type:
          type: array
          description: Tipos de veículo aceitos para a entrega
          items:
            type: string
            enum:
              - MOTORBIKE_BAG
              - MOTORBIKE_BOX
              - CAR
              - BICYCLE
              - SCOOTER
              - VUC
          minItems: 1
          example:
            - MOTORBIKE_BAG
        container:
          type: string
          enum:
            - NORMAL
            - THERMIC
          description: Tipo de container necessário
          example: NORMAL
    PaymentOfflineMethodData:
      type: object
      required:
        - type
        - amount
      properties:
        type:
          type: string
          enum:
            - CREDIT
            - DEBIT
            - MEAL_VOUCHER
            - FOOD_VOUCHER
            - PIX
            - CASH
            - CREDIT_DEBIT
            - OTHER
          description: Tipo de método de pagamento offline
          example: CREDIT
        amount:
          $ref: '#/components/schemas/PriceData'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >
        Token de acesso OAuth 2.0 obtido através do endpoint `/oauth/token`.


        Use o formato: `Authorization: Bearer {access_token}`


        O token deve ser incluído em todas as requisições aos endpoints
        protegidos.

````