# Alterar estados de entrega

Você pode utilizar este endpoint para alterar o status de uma entrega, aqui você pode adicionar comentários ou incluir razões para problemas criados anteriormente no sistema. Para saber mais sobre os status do Shippify [entre aqui.](/developers/pt/guia-de-integracao/processos-basicos/atualizacao-de-estados/estados.md)

## Atualizar o status de uma entrega

> Update the status of a delivery by its ID or reference.

```json
{"openapi":"3.0.0","info":{"title":"API Shippify","version":"1.0.0"},"servers":[{"url":"https://api.shippify.co","description":"Servidor de desenvolvimento"}],"security":[{"Basic_Auth":[]}],"components":{"securitySchemes":{"Basic_Auth":{"type":"http","scheme":"basic"}},"schemas":{"changeStatus":{"successfulResponse":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request":{"type":"object","required":["status","comment","author"],"properties":{"status":{"description":"Novo status da rota","type":"string","enum":["pending_to_review","processing","broadcasting","assigned","confirmed_to_pickup","going_to_pickup","at_pickup","on_delivery","going_to_dropoff","at_dropoff","dropped_off","completed","canceled","going_to_return","at_return_point","returned","not_picked_up","not_picked_up_payable","hold_by_courier"]},"comment":{"type":"string","description":"Comentário da mudança"},"reasonByCompany":{"type":"array","description":"Razões predefinidas para a mudança de status","items":{"type":"object","required":["reasonId","reason"],"properties":{"reasonId":{"type":"integer","description":"Identifier of the reason for changing the status"},"reason":{"type":"string","description":"Name of the reason for changing the status"}}}},"author":{"type":"object","required":["id","type","name","email"],"description":"Informações do usuário que faz a mudança de status","properties":{"type":{"type":"string","description":"Tipo de usuário","enum":["operator","admin"]},"id":{"type":"integer","description":"Identificador do usuário"},"name":{"type":"string","description":"Nome do usuário"},"email":{"type":"string","description":"Email do usuário"}}}}}},"Unauthenticated":{"properties":{"code":{"type":"string"},"message":{"type":"string"}},"type":"object"}}},"paths":{"/v1/deliveries/{id}/status":{"patch":{"tags":["Entregas"],"summary":"Atualizar o status de uma entrega","description":"Update the status of a delivery by its ID or reference.","responses":{"200":{"description":"Operação bem-sucedida","content":{"application/json":{"schema":{"$ref":"#/components/schemas/changeStatus/successfulResponse"}}}},"401":{"description":"Não autorizado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthenticated"}}}}},"parameters":[{"name":"id","in":"path","description":"Identifier or reference ID of the delivery to change status.","required":true,"schema":{"type":"string"}}],"requestBody":{"description":"Aqui vai a descrição","content":{"application/json":{"schema":{"$ref":"#/components/schemas/changeStatus/request"}}}}}}}}
```

## Casos de uso

<details>

<summary>Alteração de estado por referenceId</summary>

Utilize o referenceid da entrega na url da petição para alterar o estado.

</details>

<details>

<summary>Cancelar entrega</summary>

```json
{
    "status": "canceled",
    "comment": "TEST",
    "author": {
        "email": "example@shippify.co",
        "id": 999,
        "name": "Test operator",
        "type": "operator"
    }
}
```

</details>

<details>

<summary>Alterar estado à em posse do motorista baseado nos motivos e problemas</summary>

```json
{
    "status": "hold_by_courier",
    "comment": "Sul da cidade",
    "reasonByCompany": [
        {
            "companyId": "9065",
            "reasonId": 67,
            "reason": "ZONA DE PERIGO"
        }
    ],
    "author": {
        "type": "operator",
        "id": 1,
        "name": "Juan Perez",
        "email": "example@shippify.co"
    }
}
```

</details>

<details>

<summary>Completar entrega</summary>

```json
{
    "status": "completed",
    "comment": "",
    "author": {
        "type": "operator",
        "id": 1,
        "name": "Juan Perez",
        "email": "example@shippify.co"
    }
}
```

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.shippify.co/developers/pt/shippify-api/entregas/alterar-estados-de-entrega.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
