# Atualizar mensagem (PUT)

Atualize o conteúdo ou o status de leitura de uma mensagem existente.

## Endpoint

```
PUT https://api.pocketalert.app/v1/messages/{tid}
```

## Autenticação

> **Info: Obrigatório**
>
> Inclua um destes cabeçalhos na sua requisição:
> - `Token: <your-api-key>` — Obtenha em [Chaves de API](https://pocketalert.app/account/apikeys)
> - `Authorization: Bearer <jwt-token>` — A partir de [Entrar](https://info.pocketalert.app/api/user/login.md)

## Requisição

### Parâmetros de caminho

| Parâmetro | Tipo | Obrigatório | Descrição |
|-----------|------|:--------:|-------------|
| `tid` | string | ✅ | Identificador único da mensagem |

### Cabeçalhos

| Cabeçalho | Obrigatório | Descrição |
|--------|:--------:|-------------|
| `Token` | ✅ | Sua chave de API |
| `Authorization` | ✅ | `Bearer <jwt-token>` |

### Parâmetros do corpo

| Parâmetro | Tipo | Obrigatório | Descrição |
|-----------|------|:--------:|-------------|
| `title` | string | ✅ | Título da mensagem |
| `message` | string | ✅ | Texto do corpo da mensagem |
| `application_id` | string | ❌ | TID do aplicativo |
| `device_id` | string | ❌ | TID do dispositivo |
| `is_read` | boolean | ❌ | Marca como lida/não lida |

### Exemplo de requisição

**cURL**

```bash
curl -X PUT "https://api.pocketalert.app/v1/messages/jb4xw9elz24c5" \
  -H "Token: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Updated Title",
    "message": "Updated message content",
    "is_read": true
  }'
```

**JavaScript**

```javascript
const tid = 'jb4xw9elz24c5';
const response = await fetch(`https://api.pocketalert.app/v1/messages/${tid}`, {
  method: 'PUT',
  headers: {
    'Token': 'your-api-key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    title: 'Updated Title',
    message: 'Updated message content',
    is_read: true
  })
});
```

**Python**

```python
import requests

tid = 'jb4xw9elz24c5'
response = requests.put(
    f'https://api.pocketalert.app/v1/messages/{tid}',
    headers={'Token': 'your-api-key'},
    json={
        'title': 'Updated Title',
        'message': 'Updated message content',
        'is_read': True
    }
)
print(response.json())
```

**PHP**

```php
$tid = 'jb4xw9elz24c5';
$response = Http::withHeaders([
    'Token' => 'your-api-key',
])->put('https://api.pocketalert.app/v1/messages/'.$tid, [
    'title' => 'Updated Title',
    'message' => 'Updated message content',
    'is_read' => true,
]);

return $response->json();
```

## Resposta

### Resposta de sucesso

> **Tip: 200 OK**
>
> Mensagem atualizada com sucesso

```json
{
  "data": "success"
}
```

### Respostas de erro

| Status | Descrição |
|:------:|-------------|
| `401` | Não autorizado — Token inválido ou ausente |
| `404` | Não encontrado — A mensagem não existe |
| `400` | Requisição inválida — corpo da requisição inválido |
