# Obter todas as mensagens (GET)

Recupere uma lista de todas as mensagens da sua conta.

## Endpoint

```
GET https://api.pocketalert.app/v1/messages
```

## 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>` — De [Login](https://info.pocketalert.app/api/user/login.md)

## Requisição

### Cabeçalhos

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

### Parâmetros de consulta

| Parâmetro | Tipo | Padrão | Descrição |
|-----------|------|:------:|-----------|
| `sort` | string | `desc` | Ordem de classificação pela data de criação (`asc` ou `desc`) |
| `limit` | integer | `50` | Número máximo de mensagens a retornar |

### Exemplo de requisição

**cURL**

```bash
curl -X GET "https://api.pocketalert.app/v1/messages?sort=desc&limit=10" \
  -H "Token: your-api-key"
```

**JavaScript**

```javascript
const response = await fetch('https://api.pocketalert.app/v1/messages?sort=desc&limit=10', {
  headers: { 'Token': 'your-api-key' }
});
const messages = await response.json();
```

**Python**

```python
import requests

response = requests.get(
    'https://api.pocketalert.app/v1/messages',
    headers={'Token': 'your-api-key'},
    params={'sort': 'desc', 'limit': 10}
)
print(response.json())
```

**PHP**

```php
$response = Http::withHeaders([
    'Token' => 'your-api-key',
])->get('https://api.pocketalert.app/v1/messages', [
    'sort' => 'desc',
    'limit' => 10,
]);

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

## Resposta

### Resposta de sucesso

> **Tip: 200 OK**
>
> Retorna um array de objetos de mensagem

| Campo | Tipo | Descrição |
|-------|------|-----------|
| `tid` | string | Identificador único da mensagem |
| `title` | string | Título da mensagem |
| `message` | string | Corpo da mensagem |
| `application` | string | Nome do aplicativo |
| `device` | string | Dispositivo de destino |
| `is_read` | boolean | Se a mensagem foi lida |
| `created_at` | string | Data e hora de criação |

```json
[
  {
    "tid": "jb4xw9elz24c5",
    "title": "Server Alert",
    "message": "CPU usage exceeded 90%",
    "application": "Monitoring",
    "device": "iPhone",
    "is_read": true,
    "created_at": "18.09.2023 17:35:35"
  },
  {
    "tid": "d4u21qej1hld",
    "title": "Deploy Complete",
    "message": "Version 2.1.0 deployed",
    "application": "CI/CD",
    "device": "iPhone",
    "is_read": false,
    "created_at": "18.09.2023 17:35:23"
  }
]
```

### Respostas de erro

| Status | Descrição |
|:------:|-----------|
| `401` | Não autorizado — token inválido ou ausente |
