> ## Documentation Index
> Fetch the complete documentation index at: https://developers.gyramais.com.br/llms.txt
> Use this file to discover all available pages before exploring further.

# Refazer Análise Manual

> Refaz uma análise manual já registrada em um relatório, substituindo o parecer anterior.

### Quando usar

Use este endpoint para **refazer a análise manual** de um relatório que já recebeu uma decisão humana prévia via `POST /report/analyze`. Cenário típico: nova informação chegou, o analista quer mudar o parecer registrado (ex.: de aprovado para negado), e ele tem permissão para revisar análises manuais.

<Info>
  Esta chamada só funciona quando **já existe uma análise manual registrada** no relatório. Se nenhuma decisão manual foi feita ainda, use `POST /report/analyze`. O endpoint também não reprocessa dados das fontes — apenas atualiza a decisão humana.
</Info>

### Autenticação

Bearer JWT no header `Authorization`. O usuário precisa ter permissão para refazer análises manuais.

### Parâmetros

| Nome         | Local  | Tipo      | Obrigatório | Descrição                                              |
| ------------ | ------ | --------- | ----------- | ------------------------------------------------------ |
| `id`         | `body` | `string`  | `sim`       | ID do relatório cuja análise manual será refeita.      |
| `approved`   | `body` | `boolean` | `sim`       | Nova decisão: `true` para aprovar, `false` para negar. |
| `commentary` | `body` | `string`  | `sim`       | Nova justificativa/parecer substituindo o anterior.    |

### Corpo da requisição

```json theme={null}
{
  "id": "69a207bcdd0197828df9155a",
  "approved": false,
  "commentary": "Revisão: informação adicional identificou risco não mapeado. Decisão alterada para negado."
}
```

<RequestExample>
  ```bash cURL theme={null}
  curl --location 'https://gyra-core.gyramais.com.br/report/re-analyze' \
  --header 'Authorization: Bearer abc123' \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "id": "69a207bcdd0197828df9155a",
    "approved": false,
    "commentary": "Revisão: decisão alterada para negado."
  }'
  ```

  ```javascript JavaScript theme={null}
  fetch("https://gyra-core.gyramais.com.br/report/re-analyze", {
    method: "POST",
    headers: {
      "Authorization": "Bearer abc123",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      id: "69a207bcdd0197828df9155a",
      approved: false,
      commentary: "Revisão: decisão alterada para negado."
    })
  })
    .then(res => res.json())
    .then(console.log)
  ```

  ```python Python theme={null}
  import requests

  url = "https://gyra-core.gyramais.com.br/report/re-analyze"
  headers = {
    "Authorization": "Bearer abc123",
    "Content-Type": "application/json"
  }
  payload = {
    "id": "69a207bcdd0197828df9155a",
    "approved": False,
    "commentary": "Revisão: decisão alterada para negado."
  }
  response = requests.post(url, headers=headers, json=payload)
  print(response.json())
  ```
</RequestExample>

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "id": "69a207bcdd0197828df9155a",
    "analystId": "6610684663774970a8cf738d",
    "analystName": "Usuário API",
    "policyStatus": "DENIED",
    "commentary": "Revisão: decisão alterada para negado.",
    "status": {
      "id": "6614758260513064a5af1045",
      "value": "DENIED",
      "title": "Negado"
    },
    "updatedAt": "2026-02-27T22:02:10.110Z"
  }
  ```

  ```json 400 Bad Request theme={null}
  {
    "code": 400,
    "message": "id should not be empty,id must be a string,approved should not be empty,approved must be a boolean value"
  }
  ```

  ```json 401 Unauthorized theme={null}
  {
    "code": 401,
    "message": "Token de acesso inválido."
  }
  ```

  ```json 403 Forbidden theme={null}
  {
    "code": 403,
    "message": "Usuário não tem permissão para refazer análise manual."
  }
  ```
</ResponseExample>
