{
  "openapi": "3.1.0",
  "info": {
    "title": "API da Loggius",
    "version": "1.0.0",
    "summary": "Envios, eventos de entrega e webhooks assinados.",
    "description": "Crie envios, registre cada etapa da entrega e receba avisos no seu sistema. O comprador acompanha tudo pelo rastreio da Loggius, com previsão e confirmação de cada passo.\n\nDocumentação completa: https://loggius.com.br/docs\n\nEm Markdown, para IA: https://loggius.com.br/llms-full.txt\n\nLimite de 120 requisições por minuto por chave secreta e 300 por chave pública. Valores em centavos, datas ISO 8601 com fuso e telefone em E.164.",
    "contact": {
      "name": "Loggius",
      "url": "https://loggius.com.br/docs"
    }
  },
  "externalDocs": {
    "description": "Documentação da API",
    "url": "https://loggius.com.br/docs"
  },
  "servers": [
    {
      "url": "https://api.loggius.com.br/v1",
      "description": "Produção"
    }
  ],
  "security": [
    {
      "secretKey": []
    }
  ],
  "tags": [
    {
      "name": "Conta",
      "description": "Conferir a chave e a loja."
    },
    {
      "name": "Envios",
      "description": "Criar, listar e consultar envios."
    },
    {
      "name": "Eventos",
      "description": "Registrar e listar as etapas de cada envio."
    },
    {
      "name": "Rastreio público",
      "description": "Rota com a chave pública, sem dados pessoais."
    },
    {
      "name": "Webhooks",
      "description": "Avisos que a Loggius manda para o seu sistema."
    }
  ],
  "paths": {
    "/me": {
      "get": {
        "operationId": "getMe",
        "tags": [
          "Conta"
        ],
        "summary": "Conferir a chave",
        "description": "Devolve a loja e a chave usadas na chamada. Use para testar a integração.",
        "responses": {
          "200": {
            "description": "Loja e chave em uso.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Me"
                },
                "examples": {
                  "sucesso": {
                    "value": {
                      "store": {
                        "id": "0193c2aa-51f0-7e3b-a4d2-9c8b7a6f5e41",
                        "name": "Loja Aurora"
                      },
                      "key": {
                        "name": "ERP da loja",
                        "prefix": "sk_live_7fQx2"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/shipments": {
      "post": {
        "operationId": "createShipment",
        "tags": [
          "Envios"
        ],
        "summary": "Criar envio",
        "description": "Registra um pedido para acompanhar. A Loggius gera o código do envio, calcula a previsão, grava o evento CREATED e dispara o webhook shipment.created.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateShipmentRequest"
              },
              "examples": {
                "pedido": {
                  "value": {
                    "externalId": "PED-10482",
                    "purchasedAt": "2026-12-01T13:28:00-03:00",
                    "buyer": {
                      "name": "Mariana Souza",
                      "email": "mariana.souza@email.com",
                      "phone": "+5511987654321",
                      "document": "12345678909"
                    },
                    "destination": {
                      "zip": "01310100",
                      "street": "Avenida Paulista",
                      "number": "1578",
                      "complement": "Apto 42",
                      "district": "Bela Vista",
                      "city": "São Paulo",
                      "state": "SP"
                    },
                    "items": [
                      {
                        "name": "Camiseta básica preta M",
                        "quantity": 2,
                        "unitPriceCents": 7990
                      }
                    ],
                    "totalCents": 17480,
                    "shippingCents": 1500,
                    "carrier": "Correios"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Envio criado, com o evento CREATED.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ShipmentWithEvents"
                },
                "examples": {
                  "sucesso": {
                    "value": {
                      "id": "0193d6f2-8c4a-7b1e-9f3a-2d5e6c7b8a90",
                      "code": "LG7K2M9QXHPA",
                      "externalId": "PED-10482",
                      "status": "PREPARING",
                      "buyer": {
                        "name": "Mariana Souza",
                        "email": "mariana.souza@email.com",
                        "phone": "+5511987654321",
                        "document": "12345678909"
                      },
                      "destination": {
                        "zip": "01310100",
                        "street": "Avenida Paulista",
                        "number": "1578",
                        "complement": "Apto 42",
                        "district": "Bela Vista",
                        "city": "São Paulo",
                        "state": "SP"
                      },
                      "items": [
                        {
                          "name": "Camiseta básica preta M",
                          "quantity": 2,
                          "unitPriceCents": 7990
                        }
                      ],
                      "totalCents": 17480,
                      "shippingCents": 1500,
                      "carrier": "Correios",
                      "carrierTrackingCode": null,
                      "purchasedAt": "2026-12-01T16:28:00.000Z",
                      "forecast": {
                        "preparation": {
                          "from": "2026-12-02T16:28:00.000Z",
                          "to": "2026-12-04T16:28:00.000Z"
                        },
                        "shipBy": "2026-12-05T16:28:00.000Z",
                        "delivery": {
                          "from": "2026-12-06T16:28:00.000Z",
                          "to": "2026-12-10T16:28:00.000Z"
                        }
                      },
                      "shippedAt": null,
                      "deliveredAt": null,
                      "createdAt": "2026-12-01T16:28:03.412Z",
                      "updatedAt": "2026-12-01T16:28:03.412Z",
                      "events": [
                        {
                          "id": "0193d6f2-8c4b-7a20-b3c1-5e8f9a0b1c2d",
                          "type": "CREATED",
                          "description": null,
                          "location": null,
                          "occurredAt": "2026-12-01T16:28:00.000Z",
                          "recordedAt": "2026-12-01T16:28:03.412Z",
                          "source": "API"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "externalId repetido. O campo code traz o envio que já existe: use-o em vez de criar outro.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ShipmentConflict"
                },
                "examples": {
                  "externalIdRepetido": {
                    "value": {
                      "statusCode": 409,
                      "message": "Já existe um envio com este externalId nesta loja (LG7K2M9QXHPA)",
                      "code": "LG7K2M9QXHPA"
                    }
                  }
                }
              }
            }
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "get": {
        "operationId": "listShipments",
        "tags": [
          "Envios"
        ],
        "summary": "Listar envios",
        "description": "Lista os envios da loja, do mais recente para o mais antigo, em páginas. Os envios da lista não trazem events.",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filtra por status, como IN_TRANSIT ou in_transit.",
            "schema": {
              "$ref": "#/components/schemas/ShipmentStatus"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Quantos envios por página, de 1 a 100. Padrão: 25.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "O nextCursor da página anterior. Quando nextCursor vier null, acabou.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Uma página de envios.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ShipmentList"
                },
                "examples": {
                  "sucesso": {
                    "value": {
                      "items": [
                        {
                          "id": "0193d6f2-8c4a-7b1e-9f3a-2d5e6c7b8a90",
                          "code": "LG7K2M9QXHPA",
                          "externalId": "PED-10482",
                          "status": "PREPARING",
                          "buyer": {
                            "name": "Mariana Souza",
                            "email": "mariana.souza@email.com",
                            "phone": "+5511987654321",
                            "document": "12345678909"
                          },
                          "destination": {
                            "zip": "01310100",
                            "street": "Avenida Paulista",
                            "number": "1578",
                            "complement": "Apto 42",
                            "district": "Bela Vista",
                            "city": "São Paulo",
                            "state": "SP"
                          },
                          "items": [
                            {
                              "name": "Camiseta básica preta M",
                              "quantity": 2,
                              "unitPriceCents": 7990
                            }
                          ],
                          "totalCents": 17480,
                          "shippingCents": 1500,
                          "carrier": "Correios",
                          "carrierTrackingCode": null,
                          "purchasedAt": "2026-12-01T16:28:00.000Z",
                          "forecast": {
                            "preparation": {
                              "from": "2026-12-02T16:28:00.000Z",
                              "to": "2026-12-04T16:28:00.000Z"
                            },
                            "shipBy": "2026-12-05T16:28:00.000Z",
                            "delivery": {
                              "from": "2026-12-06T16:28:00.000Z",
                              "to": "2026-12-10T16:28:00.000Z"
                            }
                          },
                          "shippedAt": null,
                          "deliveredAt": null,
                          "createdAt": "2026-12-01T16:28:03.412Z",
                          "updatedAt": "2026-12-01T16:28:03.412Z"
                        }
                      ],
                      "nextCursor": "0193d6f2-8c4a-7b1e-9f3a-2d5e6c7b8a90"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/shipments/{code}": {
      "get": {
        "operationId": "getShipment",
        "tags": [
          "Envios"
        ],
        "summary": "Consultar envio",
        "description": "Traz um envio com o histórico completo de eventos, do mais antigo para o mais recente.",
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "description": "Código do envio (LG…) ou o id. Aceita minúsculas.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64,
              "examples": [
                "LG7K2M9QXHPA"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "O envio com o histórico.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ShipmentWithEvents"
                },
                "examples": {
                  "sucesso": {
                    "value": {
                      "id": "0193d6f2-8c4a-7b1e-9f3a-2d5e6c7b8a90",
                      "code": "LG7K2M9QXHPA",
                      "externalId": "PED-10482",
                      "status": "SHIPPED",
                      "buyer": {
                        "name": "Mariana Souza",
                        "email": "mariana.souza@email.com",
                        "phone": "+5511987654321",
                        "document": "12345678909"
                      },
                      "destination": {
                        "zip": "01310100",
                        "street": "Avenida Paulista",
                        "number": "1578",
                        "complement": "Apto 42",
                        "district": "Bela Vista",
                        "city": "São Paulo",
                        "state": "SP"
                      },
                      "items": [
                        {
                          "name": "Camiseta básica preta M",
                          "quantity": 2,
                          "unitPriceCents": 7990
                        }
                      ],
                      "totalCents": 17480,
                      "shippingCents": 1500,
                      "carrier": "Correios",
                      "carrierTrackingCode": null,
                      "purchasedAt": "2026-12-01T16:28:00.000Z",
                      "forecast": {
                        "preparation": {
                          "from": "2026-12-02T16:28:00.000Z",
                          "to": "2026-12-04T16:28:00.000Z"
                        },
                        "shipBy": "2026-12-05T16:28:00.000Z",
                        "delivery": {
                          "from": "2026-12-06T16:28:00.000Z",
                          "to": "2026-12-10T16:28:00.000Z"
                        }
                      },
                      "shippedAt": "2026-12-03T14:10:00.000Z",
                      "deliveredAt": null,
                      "createdAt": "2026-12-01T16:28:03.412Z",
                      "updatedAt": "2026-12-03T14:10:02.118Z",
                      "events": [
                        {
                          "id": "0193d6f2-8c4b-7a20-b3c1-5e8f9a0b1c2d",
                          "type": "CREATED",
                          "description": null,
                          "location": null,
                          "occurredAt": "2026-12-01T16:28:00.000Z",
                          "recordedAt": "2026-12-01T16:28:03.412Z",
                          "source": "API"
                        },
                        {
                          "id": "0193e0a1-3f7c-7d44-8a90-1b2c3d4e5f60",
                          "type": "SHIPPED",
                          "description": "Pedido postado na agência",
                          "location": "São Paulo, SP",
                          "occurredAt": "2026-12-03T14:10:00.000Z",
                          "recordedAt": "2026-12-03T14:10:02.118Z",
                          "source": "API"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/shipments/{code}/events": {
      "post": {
        "operationId": "createShipmentEvent",
        "tags": [
          "Eventos"
        ],
        "summary": "Registrar evento",
        "description": "Acrescenta um evento ao histórico. O status do envio muda conforme o tipo e o webhook correspondente é disparado. Devolve o evento criado e o envio atualizado.",
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "description": "Código do envio (LG…) ou o id. Aceita minúsculas.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64,
              "examples": [
                "LG7K2M9QXHPA"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateEventRequest"
              },
              "examples": {
                "postado": {
                  "value": {
                    "type": "SHIPPED",
                    "occurredAt": "2026-12-03T11:10:00-03:00",
                    "location": "São Paulo, SP",
                    "description": "Pedido postado na agência"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Evento registrado e envio atualizado.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EventCreated"
                },
                "examples": {
                  "sucesso": {
                    "value": {
                      "event": {
                        "id": "0193e0a1-3f7c-7d44-8a90-1b2c3d4e5f60",
                        "type": "SHIPPED",
                        "description": "Pedido postado na agência",
                        "location": "São Paulo, SP",
                        "occurredAt": "2026-12-03T14:10:00.000Z",
                        "recordedAt": "2026-12-03T14:10:02.118Z",
                        "source": "API"
                      },
                      "shipment": {
                        "id": "0193d6f2-8c4a-7b1e-9f3a-2d5e6c7b8a90",
                        "code": "LG7K2M9QXHPA",
                        "externalId": "PED-10482",
                        "status": "SHIPPED",
                        "buyer": {
                          "name": "Mariana Souza",
                          "email": "mariana.souza@email.com",
                          "phone": "+5511987654321",
                          "document": "12345678909"
                        },
                        "destination": {
                          "zip": "01310100",
                          "street": "Avenida Paulista",
                          "number": "1578",
                          "complement": "Apto 42",
                          "district": "Bela Vista",
                          "city": "São Paulo",
                          "state": "SP"
                        },
                        "items": [
                          {
                            "name": "Camiseta básica preta M",
                            "quantity": 2,
                            "unitPriceCents": 7990
                          }
                        ],
                        "totalCents": 17480,
                        "shippingCents": 1500,
                        "carrier": "Correios",
                        "carrierTrackingCode": null,
                        "purchasedAt": "2026-12-01T16:28:00.000Z",
                        "forecast": {
                          "preparation": {
                            "from": "2026-12-02T16:28:00.000Z",
                            "to": "2026-12-04T16:28:00.000Z"
                          },
                          "shipBy": "2026-12-05T16:28:00.000Z",
                          "delivery": {
                            "from": "2026-12-06T16:28:00.000Z",
                            "to": "2026-12-10T16:28:00.000Z"
                          }
                        },
                        "shippedAt": "2026-12-03T14:10:00.000Z",
                        "deliveredAt": null,
                        "createdAt": "2026-12-01T16:28:03.412Z",
                        "updatedAt": "2026-12-03T14:10:02.118Z"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "Envio entregue ou cancelado (só aceita NOTE) ou aguardando a confirmação do endereço.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "encerrado": {
                    "value": {
                      "statusCode": 409,
                      "message": "Este envio já foi entregue e só aceita observações (NOTE)"
                    }
                  }
                }
              }
            }
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "get": {
        "operationId": "listShipmentEvents",
        "tags": [
          "Eventos"
        ],
        "summary": "Listar eventos",
        "description": "Traz só o histórico do envio, do mais antigo para o mais recente, ordenado por occurredAt.",
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "description": "Código do envio (LG…) ou o id. Aceita minúsculas.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64,
              "examples": [
                "LG7K2M9QXHPA"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Histórico do envio.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EventList"
                },
                "examples": {
                  "sucesso": {
                    "value": {
                      "items": [
                        {
                          "id": "0193d6f2-8c4b-7a20-b3c1-5e8f9a0b1c2d",
                          "type": "CREATED",
                          "description": null,
                          "location": null,
                          "occurredAt": "2026-12-01T16:28:00.000Z",
                          "recordedAt": "2026-12-01T16:28:03.412Z",
                          "source": "API"
                        },
                        {
                          "id": "0193e0a1-3f7c-7d44-8a90-1b2c3d4e5f60",
                          "type": "SHIPPED",
                          "description": "Pedido postado na agência",
                          "location": "São Paulo, SP",
                          "occurredAt": "2026-12-03T14:10:00.000Z",
                          "recordedAt": "2026-12-03T14:10:02.118Z",
                          "source": "API"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/public/shipments/{code}": {
      "get": {
        "operationId": "getPublicShipment",
        "tags": [
          "Rastreio público"
        ],
        "summary": "Rastreio no site",
        "description": "Rastreio sem dados pessoais, para mostrar no site da loja. Usa a chave pública (pk_live_), no cabeçalho Authorization ou no parâmetro key. Limite de 300 requisições por minuto por chave pública. Responde ao OPTIONS do navegador com CORS conforme os domínios permitidos da chave.",
        "security": [
          {
            "publicKey": []
          },
          {
            "publicKeyQuery": []
          }
        ],
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "description": "Código do envio (LG…). Aceita minúsculas. O id interno não vale aqui.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "examples": [
                "LG7K2M9QXHPA"
              ]
            }
          },
          {
            "name": "key",
            "in": "query",
            "required": false,
            "description": "A chave pública, se você não mandar o cabeçalho Authorization. Assim o navegador não faz a consulta prévia (OPTIONS) e a resposta chega mais rápido.",
            "schema": {
              "type": "string",
              "pattern": "^pk_live_"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Rastreio do envio.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicShipment"
                },
                "examples": {
                  "sucesso": {
                    "value": {
                      "code": "LG7K2M9QXHPA",
                      "status": "SHIPPED",
                      "store": {
                        "name": "Loja Aurora",
                        "logoUrl": null
                      },
                      "forecast": {
                        "preparation": {
                          "from": "2026-12-02T16:28:00.000Z",
                          "to": "2026-12-04T16:28:00.000Z"
                        },
                        "shipBy": "2026-12-05T16:28:00.000Z",
                        "delivery": {
                          "from": "2026-12-06T16:28:00.000Z",
                          "to": "2026-12-10T16:28:00.000Z"
                        }
                      },
                      "shippedAt": "2026-12-03T14:10:00.000Z",
                      "deliveredAt": null,
                      "events": [
                        {
                          "type": "CREATED",
                          "description": null,
                          "location": null,
                          "occurredAt": "2026-12-01T16:28:00.000Z"
                        },
                        {
                          "type": "SHIPPED",
                          "description": "Pedido postado na agência",
                          "location": "São Paulo, SP",
                          "occurredAt": "2026-12-03T14:10:00.000Z"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    }
  },
  "webhooks": {
    "shipment.created": {
      "post": {
        "operationId": "webhook_shipment_created",
        "tags": [
          "Webhooks"
        ],
        "summary": "shipment.created",
        "description": "Um envio foi criado. A Loggius manda um POST para a URL cadastrada em Integrações › Webhooks (ou para a URL de retorno da chave). Valide o cabeçalho Loggius-Signature: HMAC SHA-256 de \"<t>.<corpo cru>\" com o segredo whsec_, em hexadecimal, comparado em tempo constante, recusando t com mais de 5 minutos de diferença. Responda 2xx em até 10 segundos. Novas tentativas: 1: Na hora; 2: 1 min depois da 1ª; 3: 5 min depois da 2ª; 4: 30 min depois da 3ª; 5: 2 h depois da 4ª; 6: 6 h depois da 5ª.",
        "security": [],
        "parameters": [
          {
            "name": "User-Agent",
            "in": "header",
            "required": true,
            "description": "Loggius-Webhooks/1.0.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Loggius-Event",
            "in": "header",
            "required": true,
            "description": "Tipo do evento, igual ao type do corpo.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Loggius-Event-Id",
            "in": "header",
            "required": true,
            "description": "ID do evento, igual ao id do corpo. Repete nas novas tentativas e nos reenvios.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Loggius-Delivery-Attempt",
            "in": "header",
            "required": true,
            "description": "Número da tentativa, de 1 a 6. Volta a 1 quando você reenvia pelo painel.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 6
            }
          },
          {
            "name": "Loggius-Signature",
            "in": "header",
            "required": true,
            "description": "t=<data em segundos>,v1=<HMAC SHA-256 em hexadecimal>.",
            "schema": {
              "type": "string",
              "pattern": "^t=\\d+,v1=[0-9a-f]{64}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/WebhookEvent"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "shipment.created"
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Aviso recebido. Qualquer outra resposta, ou nenhuma em 10 segundos, gera nova tentativa."
          }
        }
      }
    },
    "shipment.shipped": {
      "post": {
        "operationId": "webhook_shipment_shipped",
        "tags": [
          "Webhooks"
        ],
        "summary": "shipment.shipped",
        "description": "Evento SHIPPED registrado. A Loggius manda um POST para a URL cadastrada em Integrações › Webhooks (ou para a URL de retorno da chave). Valide o cabeçalho Loggius-Signature: HMAC SHA-256 de \"<t>.<corpo cru>\" com o segredo whsec_, em hexadecimal, comparado em tempo constante, recusando t com mais de 5 minutos de diferença. Responda 2xx em até 10 segundos. Novas tentativas: 1: Na hora; 2: 1 min depois da 1ª; 3: 5 min depois da 2ª; 4: 30 min depois da 3ª; 5: 2 h depois da 4ª; 6: 6 h depois da 5ª.",
        "security": [],
        "parameters": [
          {
            "name": "User-Agent",
            "in": "header",
            "required": true,
            "description": "Loggius-Webhooks/1.0.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Loggius-Event",
            "in": "header",
            "required": true,
            "description": "Tipo do evento, igual ao type do corpo.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Loggius-Event-Id",
            "in": "header",
            "required": true,
            "description": "ID do evento, igual ao id do corpo. Repete nas novas tentativas e nos reenvios.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Loggius-Delivery-Attempt",
            "in": "header",
            "required": true,
            "description": "Número da tentativa, de 1 a 6. Volta a 1 quando você reenvia pelo painel.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 6
            }
          },
          {
            "name": "Loggius-Signature",
            "in": "header",
            "required": true,
            "description": "t=<data em segundos>,v1=<HMAC SHA-256 em hexadecimal>.",
            "schema": {
              "type": "string",
              "pattern": "^t=\\d+,v1=[0-9a-f]{64}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/WebhookEvent"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "shipment.shipped"
                      }
                    }
                  }
                ]
              },
              "examples": {
                "exemplo": {
                  "value": {
                    "id": "evt_3f9a1c7e5b2d8a6f04",
                    "type": "shipment.shipped",
                    "createdAt": "2026-12-03T14:10:02.530Z",
                    "data": {
                      "shipment": {
                        "id": "0193d6f2-8c4a-7b1e-9f3a-2d5e6c7b8a90",
                        "code": "LG7K2M9QXHPA",
                        "externalId": "PED-10482",
                        "status": "SHIPPED",
                        "buyer": {
                          "name": "Mariana Souza",
                          "email": "mariana.souza@email.com",
                          "phone": "+5511987654321",
                          "document": "12345678909"
                        },
                        "destination": {
                          "zip": "01310100",
                          "street": "Avenida Paulista",
                          "number": "1578",
                          "complement": "Apto 42",
                          "district": "Bela Vista",
                          "city": "São Paulo",
                          "state": "SP"
                        },
                        "items": [
                          {
                            "name": "Camiseta básica preta M",
                            "quantity": 2,
                            "unitPriceCents": 7990
                          }
                        ],
                        "totalCents": 17480,
                        "shippingCents": 1500,
                        "carrier": "Correios",
                        "carrierTrackingCode": null,
                        "purchasedAt": "2026-12-01T16:28:00.000Z",
                        "forecast": {
                          "preparation": {
                            "from": "2026-12-02T16:28:00.000Z",
                            "to": "2026-12-04T16:28:00.000Z"
                          },
                          "shipBy": "2026-12-05T16:28:00.000Z",
                          "delivery": {
                            "from": "2026-12-06T16:28:00.000Z",
                            "to": "2026-12-10T16:28:00.000Z"
                          }
                        },
                        "shippedAt": "2026-12-03T14:10:00.000Z",
                        "deliveredAt": null,
                        "createdAt": "2026-12-01T16:28:03.412Z",
                        "updatedAt": "2026-12-03T14:10:02.118Z"
                      },
                      "event": {
                        "id": "0193e0a1-3f7c-7d44-8a90-1b2c3d4e5f60",
                        "type": "SHIPPED",
                        "description": "Pedido postado na agência",
                        "location": "São Paulo, SP",
                        "occurredAt": "2026-12-03T14:10:00.000Z",
                        "recordedAt": "2026-12-03T14:10:02.118Z",
                        "source": "API"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Aviso recebido. Qualquer outra resposta, ou nenhuma em 10 segundos, gera nova tentativa."
          }
        }
      }
    },
    "shipment.in_transit": {
      "post": {
        "operationId": "webhook_shipment_in_transit",
        "tags": [
          "Webhooks"
        ],
        "summary": "shipment.in_transit",
        "description": "Evento IN_TRANSIT registrado. A Loggius manda um POST para a URL cadastrada em Integrações › Webhooks (ou para a URL de retorno da chave). Valide o cabeçalho Loggius-Signature: HMAC SHA-256 de \"<t>.<corpo cru>\" com o segredo whsec_, em hexadecimal, comparado em tempo constante, recusando t com mais de 5 minutos de diferença. Responda 2xx em até 10 segundos. Novas tentativas: 1: Na hora; 2: 1 min depois da 1ª; 3: 5 min depois da 2ª; 4: 30 min depois da 3ª; 5: 2 h depois da 4ª; 6: 6 h depois da 5ª.",
        "security": [],
        "parameters": [
          {
            "name": "User-Agent",
            "in": "header",
            "required": true,
            "description": "Loggius-Webhooks/1.0.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Loggius-Event",
            "in": "header",
            "required": true,
            "description": "Tipo do evento, igual ao type do corpo.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Loggius-Event-Id",
            "in": "header",
            "required": true,
            "description": "ID do evento, igual ao id do corpo. Repete nas novas tentativas e nos reenvios.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Loggius-Delivery-Attempt",
            "in": "header",
            "required": true,
            "description": "Número da tentativa, de 1 a 6. Volta a 1 quando você reenvia pelo painel.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 6
            }
          },
          {
            "name": "Loggius-Signature",
            "in": "header",
            "required": true,
            "description": "t=<data em segundos>,v1=<HMAC SHA-256 em hexadecimal>.",
            "schema": {
              "type": "string",
              "pattern": "^t=\\d+,v1=[0-9a-f]{64}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/WebhookEvent"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "shipment.in_transit"
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Aviso recebido. Qualquer outra resposta, ou nenhuma em 10 segundos, gera nova tentativa."
          }
        }
      }
    },
    "shipment.out_for_delivery": {
      "post": {
        "operationId": "webhook_shipment_out_for_delivery",
        "tags": [
          "Webhooks"
        ],
        "summary": "shipment.out_for_delivery",
        "description": "Evento OUT_FOR_DELIVERY registrado. A Loggius manda um POST para a URL cadastrada em Integrações › Webhooks (ou para a URL de retorno da chave). Valide o cabeçalho Loggius-Signature: HMAC SHA-256 de \"<t>.<corpo cru>\" com o segredo whsec_, em hexadecimal, comparado em tempo constante, recusando t com mais de 5 minutos de diferença. Responda 2xx em até 10 segundos. Novas tentativas: 1: Na hora; 2: 1 min depois da 1ª; 3: 5 min depois da 2ª; 4: 30 min depois da 3ª; 5: 2 h depois da 4ª; 6: 6 h depois da 5ª.",
        "security": [],
        "parameters": [
          {
            "name": "User-Agent",
            "in": "header",
            "required": true,
            "description": "Loggius-Webhooks/1.0.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Loggius-Event",
            "in": "header",
            "required": true,
            "description": "Tipo do evento, igual ao type do corpo.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Loggius-Event-Id",
            "in": "header",
            "required": true,
            "description": "ID do evento, igual ao id do corpo. Repete nas novas tentativas e nos reenvios.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Loggius-Delivery-Attempt",
            "in": "header",
            "required": true,
            "description": "Número da tentativa, de 1 a 6. Volta a 1 quando você reenvia pelo painel.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 6
            }
          },
          {
            "name": "Loggius-Signature",
            "in": "header",
            "required": true,
            "description": "t=<data em segundos>,v1=<HMAC SHA-256 em hexadecimal>.",
            "schema": {
              "type": "string",
              "pattern": "^t=\\d+,v1=[0-9a-f]{64}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/WebhookEvent"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "shipment.out_for_delivery"
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Aviso recebido. Qualquer outra resposta, ou nenhuma em 10 segundos, gera nova tentativa."
          }
        }
      }
    },
    "shipment.delivered": {
      "post": {
        "operationId": "webhook_shipment_delivered",
        "tags": [
          "Webhooks"
        ],
        "summary": "shipment.delivered",
        "description": "Evento DELIVERED registrado. A Loggius manda um POST para a URL cadastrada em Integrações › Webhooks (ou para a URL de retorno da chave). Valide o cabeçalho Loggius-Signature: HMAC SHA-256 de \"<t>.<corpo cru>\" com o segredo whsec_, em hexadecimal, comparado em tempo constante, recusando t com mais de 5 minutos de diferença. Responda 2xx em até 10 segundos. Novas tentativas: 1: Na hora; 2: 1 min depois da 1ª; 3: 5 min depois da 2ª; 4: 30 min depois da 3ª; 5: 2 h depois da 4ª; 6: 6 h depois da 5ª.",
        "security": [],
        "parameters": [
          {
            "name": "User-Agent",
            "in": "header",
            "required": true,
            "description": "Loggius-Webhooks/1.0.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Loggius-Event",
            "in": "header",
            "required": true,
            "description": "Tipo do evento, igual ao type do corpo.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Loggius-Event-Id",
            "in": "header",
            "required": true,
            "description": "ID do evento, igual ao id do corpo. Repete nas novas tentativas e nos reenvios.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Loggius-Delivery-Attempt",
            "in": "header",
            "required": true,
            "description": "Número da tentativa, de 1 a 6. Volta a 1 quando você reenvia pelo painel.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 6
            }
          },
          {
            "name": "Loggius-Signature",
            "in": "header",
            "required": true,
            "description": "t=<data em segundos>,v1=<HMAC SHA-256 em hexadecimal>.",
            "schema": {
              "type": "string",
              "pattern": "^t=\\d+,v1=[0-9a-f]{64}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/WebhookEvent"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "shipment.delivered"
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Aviso recebido. Qualquer outra resposta, ou nenhuma em 10 segundos, gera nova tentativa."
          }
        }
      }
    },
    "shipment.problem": {
      "post": {
        "operationId": "webhook_shipment_problem",
        "tags": [
          "Webhooks"
        ],
        "summary": "shipment.problem",
        "description": "Evento DELIVERY_FAILED ou PROBLEM registrado. A Loggius manda um POST para a URL cadastrada em Integrações › Webhooks (ou para a URL de retorno da chave). Valide o cabeçalho Loggius-Signature: HMAC SHA-256 de \"<t>.<corpo cru>\" com o segredo whsec_, em hexadecimal, comparado em tempo constante, recusando t com mais de 5 minutos de diferença. Responda 2xx em até 10 segundos. Novas tentativas: 1: Na hora; 2: 1 min depois da 1ª; 3: 5 min depois da 2ª; 4: 30 min depois da 3ª; 5: 2 h depois da 4ª; 6: 6 h depois da 5ª.",
        "security": [],
        "parameters": [
          {
            "name": "User-Agent",
            "in": "header",
            "required": true,
            "description": "Loggius-Webhooks/1.0.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Loggius-Event",
            "in": "header",
            "required": true,
            "description": "Tipo do evento, igual ao type do corpo.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Loggius-Event-Id",
            "in": "header",
            "required": true,
            "description": "ID do evento, igual ao id do corpo. Repete nas novas tentativas e nos reenvios.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Loggius-Delivery-Attempt",
            "in": "header",
            "required": true,
            "description": "Número da tentativa, de 1 a 6. Volta a 1 quando você reenvia pelo painel.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 6
            }
          },
          {
            "name": "Loggius-Signature",
            "in": "header",
            "required": true,
            "description": "t=<data em segundos>,v1=<HMAC SHA-256 em hexadecimal>.",
            "schema": {
              "type": "string",
              "pattern": "^t=\\d+,v1=[0-9a-f]{64}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/WebhookEvent"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "shipment.problem"
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Aviso recebido. Qualquer outra resposta, ou nenhuma em 10 segundos, gera nova tentativa."
          }
        }
      }
    },
    "shipment.lost": {
      "post": {
        "operationId": "webhook_shipment_lost",
        "tags": [
          "Webhooks"
        ],
        "summary": "shipment.lost",
        "description": "Evento LOST registrado. A Loggius manda um POST para a URL cadastrada em Integrações › Webhooks (ou para a URL de retorno da chave). Valide o cabeçalho Loggius-Signature: HMAC SHA-256 de \"<t>.<corpo cru>\" com o segredo whsec_, em hexadecimal, comparado em tempo constante, recusando t com mais de 5 minutos de diferença. Responda 2xx em até 10 segundos. Novas tentativas: 1: Na hora; 2: 1 min depois da 1ª; 3: 5 min depois da 2ª; 4: 30 min depois da 3ª; 5: 2 h depois da 4ª; 6: 6 h depois da 5ª.",
        "security": [],
        "parameters": [
          {
            "name": "User-Agent",
            "in": "header",
            "required": true,
            "description": "Loggius-Webhooks/1.0.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Loggius-Event",
            "in": "header",
            "required": true,
            "description": "Tipo do evento, igual ao type do corpo.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Loggius-Event-Id",
            "in": "header",
            "required": true,
            "description": "ID do evento, igual ao id do corpo. Repete nas novas tentativas e nos reenvios.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Loggius-Delivery-Attempt",
            "in": "header",
            "required": true,
            "description": "Número da tentativa, de 1 a 6. Volta a 1 quando você reenvia pelo painel.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 6
            }
          },
          {
            "name": "Loggius-Signature",
            "in": "header",
            "required": true,
            "description": "t=<data em segundos>,v1=<HMAC SHA-256 em hexadecimal>.",
            "schema": {
              "type": "string",
              "pattern": "^t=\\d+,v1=[0-9a-f]{64}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/WebhookEvent"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "shipment.lost"
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Aviso recebido. Qualquer outra resposta, ou nenhuma em 10 segundos, gera nova tentativa."
          }
        }
      }
    },
    "shipment.canceled": {
      "post": {
        "operationId": "webhook_shipment_canceled",
        "tags": [
          "Webhooks"
        ],
        "summary": "shipment.canceled",
        "description": "Evento CANCELED registrado. A Loggius manda um POST para a URL cadastrada em Integrações › Webhooks (ou para a URL de retorno da chave). Valide o cabeçalho Loggius-Signature: HMAC SHA-256 de \"<t>.<corpo cru>\" com o segredo whsec_, em hexadecimal, comparado em tempo constante, recusando t com mais de 5 minutos de diferença. Responda 2xx em até 10 segundos. Novas tentativas: 1: Na hora; 2: 1 min depois da 1ª; 3: 5 min depois da 2ª; 4: 30 min depois da 3ª; 5: 2 h depois da 4ª; 6: 6 h depois da 5ª.",
        "security": [],
        "parameters": [
          {
            "name": "User-Agent",
            "in": "header",
            "required": true,
            "description": "Loggius-Webhooks/1.0.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Loggius-Event",
            "in": "header",
            "required": true,
            "description": "Tipo do evento, igual ao type do corpo.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Loggius-Event-Id",
            "in": "header",
            "required": true,
            "description": "ID do evento, igual ao id do corpo. Repete nas novas tentativas e nos reenvios.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Loggius-Delivery-Attempt",
            "in": "header",
            "required": true,
            "description": "Número da tentativa, de 1 a 6. Volta a 1 quando você reenvia pelo painel.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 6
            }
          },
          {
            "name": "Loggius-Signature",
            "in": "header",
            "required": true,
            "description": "t=<data em segundos>,v1=<HMAC SHA-256 em hexadecimal>.",
            "schema": {
              "type": "string",
              "pattern": "^t=\\d+,v1=[0-9a-f]{64}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/WebhookEvent"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "shipment.canceled"
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Aviso recebido. Qualquer outra resposta, ou nenhuma em 10 segundos, gera nova tentativa."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "secretKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "sk_live_…",
        "description": "Chave secreta, criada no painel em Integrações › API. Use só no servidor."
      },
      "publicKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "pk_live_…",
        "description": "Chave pública. Vale só para GET /v1/public/shipments/{code}."
      },
      "publicKeyQuery": {
        "type": "apiKey",
        "in": "query",
        "name": "key",
        "description": "A chave pública (pk_live_…) no parâmetro key, sem cabeçalho."
      }
    },
    "headers": {
      "X-RateLimit-Limit": {
        "description": "Quantas requisições cabem por minuto: 120.",
        "schema": {
          "type": "integer"
        }
      },
      "X-RateLimit-Remaining": {
        "description": "Quantas ainda restam na janela atual.",
        "schema": {
          "type": "integer"
        }
      },
      "X-RateLimit-Reset": {
        "description": "Quando a janela recomeça, em segundos desde 1970 (Unix).",
        "schema": {
          "type": "integer"
        }
      },
      "Retry-After": {
        "description": "Só no 429. Quantos segundos esperar antes de tentar de novo.",
        "schema": {
          "type": "integer"
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Dados inválidos, cursor inválido ou evento com data antes da compra. O errors diz qual campo.",
        "headers": {
          "X-RateLimit-Limit": {
            "$ref": "#/components/headers/X-RateLimit-Limit"
          },
          "X-RateLimit-Remaining": {
            "$ref": "#/components/headers/X-RateLimit-Remaining"
          },
          "X-RateLimit-Reset": {
            "$ref": "#/components/headers/X-RateLimit-Reset"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "camposInvalidos": {
                "value": {
                  "statusCode": 400,
                  "message": "Alguns campos estão inválidos",
                  "errors": [
                    {
                      "field": "buyer.email",
                      "message": "E-mail do comprador inválido"
                    },
                    {
                      "field": "destination.state",
                      "message": "Estado inválido. Use a sigla da UF, como SP"
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Chave ausente, inválida ou revogada, ou chave do tipo errado: pública numa rota secreta ou secreta na rota pública.",
        "headers": {},
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "chaveInvalida": {
                "value": {
                  "statusCode": 401,
                  "message": "Chave de API inválida"
                }
              },
              "chaveErrada": {
                "value": {
                  "statusCode": 401,
                  "message": "Use a chave secreta (sk_live_) no servidor"
                }
              }
            }
          }
        }
      },
      "Forbidden": {
        "description": "Loja inativa ou arquivada, conta bloqueada ou, na rota pública, domínio que não está na lista da chave.",
        "headers": {
          "X-RateLimit-Limit": {
            "$ref": "#/components/headers/X-RateLimit-Limit"
          },
          "X-RateLimit-Remaining": {
            "$ref": "#/components/headers/X-RateLimit-Remaining"
          },
          "X-RateLimit-Reset": {
            "$ref": "#/components/headers/X-RateLimit-Reset"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "dominio": {
                "value": {
                  "statusCode": 403,
                  "message": "Este domínio não está liberado para esta chave pública. Cadastre-o em Integrações › API"
                }
              }
            }
          }
        }
      },
      "NotFound": {
        "description": "Envio não encontrado nesta loja.",
        "headers": {
          "X-RateLimit-Limit": {
            "$ref": "#/components/headers/X-RateLimit-Limit"
          },
          "X-RateLimit-Remaining": {
            "$ref": "#/components/headers/X-RateLimit-Remaining"
          },
          "X-RateLimit-Reset": {
            "$ref": "#/components/headers/X-RateLimit-Reset"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "naoEncontrado": {
                "value": {
                  "statusCode": 404,
                  "message": "Envio não encontrado"
                }
              }
            }
          }
        }
      },
      "PayloadTooLarge": {
        "description": "Corpo da requisição grande demais.",
        "headers": {},
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "Mais de 120 requisições por minuto com a mesma chave secreta (300 com a pública), ou muitas tentativas com chave inválida.",
        "headers": {
          "X-RateLimit-Limit": {
            "$ref": "#/components/headers/X-RateLimit-Limit"
          },
          "X-RateLimit-Remaining": {
            "$ref": "#/components/headers/X-RateLimit-Remaining"
          },
          "X-RateLimit-Reset": {
            "$ref": "#/components/headers/X-RateLimit-Reset"
          },
          "Retry-After": {
            "$ref": "#/components/headers/Retry-After"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/RateLimitError"
            },
            "examples": {
              "limite": {
                "value": {
                  "statusCode": 429,
                  "message": "Limite de 120 requisições por minuto atingido para esta chave",
                  "retryAfter": 37
                }
              }
            }
          }
        }
      },
      "ServerError": {
        "description": "Falha do nosso lado. Tente de novo em instantes.",
        "headers": {},
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "interno": {
                "value": {
                  "statusCode": 500,
                  "message": "Erro interno. Tente de novo em instantes"
                }
              }
            }
          }
        }
      }
    },
    "schemas": {
      "ShipmentStatus": {
        "type": "string",
        "enum": [
          "AWAITING_ADDRESS",
          "PREPARING",
          "SHIPPED",
          "IN_TRANSIT",
          "OUT_FOR_DELIVERY",
          "DELIVERED",
          "PROBLEM",
          "LOST",
          "CANCELED"
        ],
        "description": "Situação do envio. Na entrada, minúsculas também valem.\n\n- `AWAITING_ADDRESS`: Aguardando endereço. Criado por uma plataforma integrada sem o endereço completo. O comprador confirma o endereço por um link. Até lá, só aceita CANCELED e NOTE.\n- `PREPARING`: Em preparação. Envio criado. A loja está separando e embalando o pedido.\n- `SHIPPED`: Enviado. Pedido postado ou entregue à transportadora.\n- `IN_TRANSIT`: Em trânsito. Houve movimentação no trajeto até o destino.\n- `OUT_FOR_DELIVERY`: Saiu para entrega. Está com o entregador, a caminho do comprador.\n- `DELIVERED`: Entregue. Chegou ao comprador. Depois disso, só observações.\n- `PROBLEM`: Com problema. Tentativa de entrega sem sucesso ou outro problema no caminho.\n- `LOST`: Extraviado. O pacote se perdeu no caminho.\n- `CANCELED`: Cancelado. O envio foi cancelado. Depois disso, só observações."
      },
      "EventType": {
        "type": "string",
        "enum": [
          "CREATED",
          "SHIPPED",
          "IN_TRANSIT",
          "OUT_FOR_DELIVERY",
          "DELIVERY_FAILED",
          "DELIVERED",
          "PROBLEM",
          "LOST",
          "CANCELED",
          "NOTE"
        ],
        "description": "Tipo do evento.\n\n- `CREATED`: Gravado pela Loggius quando o envio é criado. Não dá para enviar.\n- `SHIPPED`: Pedido postado ou coletado pela transportadora. Grava shippedAt.\n- `IN_TRANSIT`: Nova movimentação no trajeto, como chegada a um centro de distribuição.\n- `OUT_FOR_DELIVERY`: O pacote saiu com o entregador.\n- `DELIVERY_FAILED`: O entregador tentou e não conseguiu entregar.\n- `DELIVERED`: O comprador recebeu. Grava deliveredAt.\n- `PROBLEM`: Algo impede a entrega, como endereço incompleto ou avaria.\n- `LOST`: O pacote se perdeu.\n- `CANCELED`: O envio foi cancelado.\n- `NOTE`: Um recado no histórico. Não muda o status nem dispara webhook."
      },
      "PostableEventType": {
        "type": "string",
        "enum": [
          "SHIPPED",
          "IN_TRANSIT",
          "OUT_FOR_DELIVERY",
          "DELIVERY_FAILED",
          "DELIVERED",
          "PROBLEM",
          "LOST",
          "CANCELED",
          "NOTE"
        ],
        "description": "Tipos aceitos ao registrar um evento. CREATED é gravado só pela Loggius. Na entrada, minúsculas também valem."
      },
      "EventSource": {
        "type": "string",
        "enum": [
          "API",
          "PANEL",
          "COURIER",
          "CARRIER",
          "SYSTEM",
          "INTEGRATION"
        ],
        "description": "Quem registrou o evento.\n\n- `API`: Registrado pela API com uma chave.\n- `PANEL`: Registrado por alguém da loja no painel.\n- `COURIER`: Registrado pelo entregador.\n- `CARRIER`: Vindo da transportadora.\n- `SYSTEM`: Gravado pela própria Loggius.\n- `INTEGRATION`: Vindo de uma plataforma integrada, como o checkout ou o gateway da loja."
      },
      "UF": {
        "type": "string",
        "enum": [
          "AC",
          "AL",
          "AP",
          "AM",
          "BA",
          "CE",
          "DF",
          "ES",
          "GO",
          "MA",
          "MT",
          "MS",
          "MG",
          "PA",
          "PB",
          "PR",
          "PE",
          "PI",
          "RJ",
          "RN",
          "RS",
          "RO",
          "RR",
          "SC",
          "SP",
          "SE",
          "TO"
        ],
        "description": "Sigla do estado. Na entrada, minúsculas também valem."
      },
      "FieldError": {
        "type": "object",
        "required": [
          "message"
        ],
        "properties": {
          "field": {
            "type": "string",
            "description": "Campo com problema, como buyer.email."
          },
          "message": {
            "type": "string",
            "description": "O que está errado, em português."
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "statusCode",
          "message"
        ],
        "properties": {
          "statusCode": {
            "type": "integer",
            "description": "Mesmo código HTTP da resposta."
          },
          "message": {
            "type": "string",
            "description": "Explicação em português. Com vários erros de campo, resume a lista."
          },
          "errors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FieldError"
            },
            "description": "Só quando o problema é em campos."
          }
        }
      },
      "ShipmentConflict": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Error"
          },
          {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "description": "Código do envio que já existe com este externalId. Só vem no 409 de externalId repetido."
              }
            }
          }
        ]
      },
      "RateLimitError": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Error"
          },
          {
            "type": "object",
            "properties": {
              "retryAfter": {
                "type": "integer",
                "description": "Segundos até poder tentar de novo. Igual ao cabeçalho Retry-After.",
                "minimum": 1
              }
            }
          }
        ]
      },
      "Me": {
        "type": "object",
        "required": [
          "store",
          "key"
        ],
        "properties": {
          "store": {
            "type": "object",
            "required": [
              "id",
              "name"
            ],
            "properties": {
              "id": {
                "type": "string",
                "description": "ID da loja.",
                "format": "uuid"
              },
              "name": {
                "type": "string",
                "description": "Nome da loja."
              }
            }
          },
          "key": {
            "type": "object",
            "required": [
              "name",
              "prefix"
            ],
            "properties": {
              "name": {
                "type": "string",
                "description": "Nome dado à chave no painel."
              },
              "prefix": {
                "type": "string",
                "description": "Começo da chave secreta, para conferir qual está em uso."
              }
            }
          }
        }
      },
      "Buyer": {
        "type": "object",
        "required": [
          "name",
          "email",
          "phone",
          "document"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Nome do comprador, de 2 a 120 caracteres."
          },
          "email": {
            "type": "string",
            "description": "E-mail do comprador. Recebe os avisos de acompanhamento.",
            "format": "email"
          },
          "phone": {
            "type": [
              "string",
              "null"
            ],
            "description": "Celular no formato E.164, como +5511987654321."
          },
          "document": {
            "type": [
              "string",
              "null"
            ],
            "description": "CPF ou CNPJ, só com números."
          }
        }
      },
      "Destination": {
        "type": "object",
        "required": [
          "zip",
          "street",
          "number",
          "complement",
          "district",
          "city",
          "state"
        ],
        "properties": {
          "zip": {
            "type": [
              "string",
              "null"
            ],
            "description": "CEP com 8 dígitos, só números."
          },
          "street": {
            "type": [
              "string",
              "null"
            ]
          },
          "number": {
            "type": [
              "string",
              "null"
            ]
          },
          "complement": {
            "type": [
              "string",
              "null"
            ]
          },
          "district": {
            "type": [
              "string",
              "null"
            ]
          },
          "city": {
            "type": "string",
            "description": "Cidade de entrega."
          },
          "state": {
            "$ref": "#/components/schemas/UF"
          }
        }
      },
      "Item": {
        "type": "object",
        "required": [
          "name",
          "quantity",
          "unitPriceCents"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Nome do item.",
            "minLength": 1,
            "maxLength": 200
          },
          "quantity": {
            "type": "integer",
            "description": "Quantidade.",
            "minimum": 1,
            "maximum": 999
          },
          "unitPriceCents": {
            "type": "integer",
            "description": "Preço unitário em centavos.",
            "minimum": 0,
            "maximum": 1000000000
          }
        }
      },
      "Period": {
        "type": "object",
        "required": [
          "from",
          "to"
        ],
        "properties": {
          "from": {
            "type": "string",
            "format": "date-time"
          },
          "to": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Forecast": {
        "type": "object",
        "description": "preparation { from, to }, shipBy e delivery { from, to }. Pode vir null enquanto o envio aguarda o endereço. Veja Previsão de prazos.",
        "required": [
          "preparation",
          "shipBy",
          "delivery"
        ],
        "properties": {
          "preparation": {
            "$ref": "#/components/schemas/Period"
          },
          "shipBy": {
            "type": "string",
            "description": "Data limite para postar.",
            "format": "date-time"
          },
          "delivery": {
            "$ref": "#/components/schemas/Period"
          }
        }
      },
      "Shipment": {
        "type": "object",
        "required": [
          "id",
          "code",
          "externalId",
          "status",
          "buyer",
          "destination",
          "items",
          "totalCents",
          "shippingCents",
          "carrier",
          "carrierTrackingCode",
          "purchasedAt",
          "forecast",
          "shippedAt",
          "deliveredAt",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Identificador interno do envio (UUID).",
            "format": "uuid"
          },
          "code": {
            "type": "string",
            "description": "Código do envio: LG mais 10 letras e números. É o que o comprador usa no rastreio.",
            "pattern": "^LG[23456789ABCDEFGHJKMNPQRSTUVWXYZ]{10}$",
            "examples": [
              "LG7K2M9QXHPA"
            ]
          },
          "externalId": {
            "type": [
              "string",
              "null"
            ],
            "description": "O número do pedido que você mandou."
          },
          "status": {
            "$ref": "#/components/schemas/ShipmentStatus"
          },
          "buyer": {
            "$ref": "#/components/schemas/Buyer"
          },
          "destination": {
            "$ref": "#/components/schemas/Destination"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Item"
            }
          },
          "totalCents": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Valores em centavos."
          },
          "shippingCents": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Valores em centavos."
          },
          "carrier": {
            "type": [
              "string",
              "null"
            ]
          },
          "carrierTrackingCode": {
            "type": [
              "string",
              "null"
            ]
          },
          "purchasedAt": {
            "type": "string",
            "description": "Data da compra. Base de toda a previsão.",
            "format": "date-time"
          },
          "forecast": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Forecast"
              },
              {
                "type": "null"
              }
            ]
          },
          "shippedAt": {
            "type": [
              "string",
              "null"
            ],
            "description": "Gravado pelo evento SHIPPED.",
            "format": "date-time"
          },
          "deliveredAt": {
            "type": [
              "string",
              "null"
            ],
            "description": "Gravado pelo evento DELIVERED.",
            "format": "date-time"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ShipmentEvent": {
        "type": "object",
        "required": [
          "id",
          "type",
          "description",
          "location",
          "occurredAt",
          "recordedAt",
          "source"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Identificador do evento (UUID).",
            "format": "uuid"
          },
          "type": {
            "$ref": "#/components/schemas/EventType"
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "Texto que explica o evento."
          },
          "location": {
            "type": [
              "string",
              "null"
            ],
            "description": "Onde aconteceu."
          },
          "occurredAt": {
            "type": "string",
            "description": "Quando aconteceu.",
            "format": "date-time"
          },
          "recordedAt": {
            "type": "string",
            "description": "Quando a Loggius gravou.",
            "format": "date-time"
          },
          "source": {
            "$ref": "#/components/schemas/EventSource"
          }
        }
      },
      "ShipmentWithEvents": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Shipment"
          },
          {
            "type": "object",
            "required": [
              "events"
            ],
            "properties": {
              "events": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ShipmentEvent"
                },
                "description": "Do mais antigo para o mais recente."
              }
            }
          }
        ]
      },
      "ShipmentList": {
        "type": "object",
        "required": [
          "items",
          "nextCursor"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Shipment"
            }
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "O nextCursor da página anterior. Quando nextCursor vier null, acabou.",
            "format": "uuid"
          }
        }
      },
      "EventList": {
        "type": "object",
        "required": [
          "items"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ShipmentEvent"
            }
          }
        }
      },
      "EventCreated": {
        "type": "object",
        "required": [
          "event",
          "shipment"
        ],
        "properties": {
          "event": {
            "$ref": "#/components/schemas/ShipmentEvent"
          },
          "shipment": {
            "$ref": "#/components/schemas/Shipment"
          }
        }
      },
      "CreateShipmentRequest": {
        "type": "object",
        "required": [
          "buyer",
          "destination"
        ],
        "properties": {
          "externalId": {
            "type": "string",
            "description": "Seu número do pedido, até 100 caracteres. Único por loja: repetir devolve 409 com o código do envio que já existe.",
            "maxLength": 100
          },
          "purchasedAt": {
            "type": "string",
            "description": "Data da compra, com fuso (Z ou -03:00). Padrão: agora. Não pode ser no futuro nem de mais de 180 dias atrás.",
            "format": "date-time"
          },
          "buyer": {
            "type": "object",
            "required": [
              "name",
              "email"
            ],
            "properties": {
              "name": {
                "type": "string",
                "description": "Nome do comprador, de 2 a 120 caracteres.",
                "minLength": 2,
                "maxLength": 120
              },
              "email": {
                "type": "string",
                "description": "E-mail do comprador. Recebe os avisos de acompanhamento.",
                "format": "email",
                "maxLength": 254
              },
              "phone": {
                "type": "string",
                "description": "Celular no formato E.164, como +5511987654321.",
                "pattern": "^\\+[1-9]\\d{6,14}$"
              },
              "document": {
                "type": "string",
                "description": "CPF ou CNPJ, com ou sem pontuação. Volta só com números.",
                "maxLength": 30
              }
            }
          },
          "destination": {
            "type": "object",
            "required": [
              "city",
              "state"
            ],
            "properties": {
              "zip": {
                "type": "string",
                "description": "CEP com 8 dígitos. Pode vir com hífen.",
                "pattern": "^\\d{5}-?\\d{3}$"
              },
              "street": {
                "type": "string",
                "maxLength": 200
              },
              "number": {
                "type": "string",
                "maxLength": 20
              },
              "complement": {
                "type": "string",
                "maxLength": 100
              },
              "district": {
                "type": "string",
                "maxLength": 100
              },
              "city": {
                "type": "string",
                "description": "Cidade de entrega.",
                "minLength": 2,
                "maxLength": 100
              },
              "state": {
                "$ref": "#/components/schemas/UF",
                "description": "Sigla do estado (UF), como SP ou sp. Define o prazo de entrega por estado."
              }
            }
          },
          "items": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/Item"
            },
            "description": "Até 100 itens, cada um com name, quantity e unitPriceCents."
          },
          "totalCents": {
            "type": "integer",
            "description": "Valor total do pedido em centavos.",
            "minimum": 0,
            "maximum": 1000000000
          },
          "shippingCents": {
            "type": "integer",
            "description": "Valor do frete em centavos.",
            "minimum": 0,
            "maximum": 1000000000
          },
          "carrier": {
            "type": "string",
            "description": "Transportadora, como Correios ou Jadlog.",
            "maxLength": 60
          },
          "carrierTrackingCode": {
            "type": "string",
            "description": "Código de rastreio da transportadora, se já tiver.",
            "maxLength": 60
          },
          "sendEmail": {
            "type": "boolean",
            "description": "Mande false para não avisar o comprador por e-mail que o pedido foi confirmado. Padrão: avisa."
          }
        }
      },
      "CreateEventRequest": {
        "type": "object",
        "required": [
          "type"
        ],
        "properties": {
          "type": {
            "$ref": "#/components/schemas/PostableEventType",
            "description": "Tipo do evento, como SHIPPED ou shipped. CREATED não é aceito. Veja Status e tipos de evento."
          },
          "occurredAt": {
            "type": "string",
            "description": "Quando aconteceu, com fuso. Padrão: agora. Aceita até 5 minutos no futuro e não pode ser antes da compra.",
            "format": "date-time"
          },
          "location": {
            "type": "string",
            "description": "Onde aconteceu, até 120 caracteres, como São Paulo, SP.",
            "maxLength": 120
          },
          "description": {
            "type": "string",
            "description": "Texto curto que explica o evento, até 500 caracteres.",
            "maxLength": 500
          },
          "sendEmail": {
            "type": "boolean",
            "description": "Mande false para não avisar o comprador por e-mail desta etapa. Padrão: avisa, quando a etapa tem e-mail."
          }
        }
      },
      "PublicEvent": {
        "type": "object",
        "required": [
          "type",
          "description",
          "location",
          "occurredAt"
        ],
        "properties": {
          "type": {
            "$ref": "#/components/schemas/EventType"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "location": {
            "type": [
              "string",
              "null"
            ]
          },
          "occurredAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PublicShipment": {
        "type": "object",
        "required": [
          "code",
          "status",
          "store",
          "forecast",
          "shippedAt",
          "deliveredAt",
          "events"
        ],
        "properties": {
          "code": {
            "type": "string",
            "description": "Código do envio."
          },
          "status": {
            "$ref": "#/components/schemas/ShipmentStatus"
          },
          "store": {
            "type": "object",
            "required": [
              "name",
              "logoUrl"
            ],
            "properties": {
              "name": {
                "type": "string"
              },
              "logoUrl": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uri"
              }
            },
            "description": "Nome e endereço da logo da loja, para montar o cabeçalho do rastreio. logoUrl vem null quando a loja não tem logo."
          },
          "forecast": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Forecast"
              },
              {
                "type": "null"
              }
            ]
          },
          "shippedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "deliveredAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicEvent"
            },
            "description": "Histórico com type, description, location e occurredAt, do mais antigo para o mais recente. Observações (NOTE) ficam de fora."
          }
        }
      },
      "WebhookEvent": {
        "type": "object",
        "required": [
          "id",
          "type",
          "createdAt",
          "data"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "ID do evento, como evt_3f9a…. Igual em todas as tentativas e nos reenvios.",
            "pattern": "^evt_[0-9a-f]+$"
          },
          "type": {
            "type": "string",
            "enum": [
              "shipment.created",
              "shipment.shipped",
              "shipment.in_transit",
              "shipment.out_for_delivery",
              "shipment.delivered",
              "shipment.problem",
              "shipment.lost",
              "shipment.canceled"
            ]
          },
          "createdAt": {
            "type": "string",
            "description": "Quando o evento foi gerado, em UTC.",
            "format": "date-time"
          },
          "test": {
            "type": "boolean",
            "const": true,
            "description": "Só aparece nos testes enviados pelo painel."
          },
          "data": {
            "type": "object",
            "required": [
              "shipment",
              "event"
            ],
            "properties": {
              "shipment": {
                "$ref": "#/components/schemas/Shipment"
              },
              "event": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/ShipmentEvent"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "O evento que causou o aviso."
              }
            }
          }
        }
      }
    }
  }
}
