# Obter mensagem (GET)

Recupere os detalhes de uma mensagem específica pelo seu identificador único.

## Endpoint

```
GET 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>` — De [Login](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>` |

### Exemplo de requisição

**cURL**

```bash
curl -X GET "https://api.pocketalert.app/v1/messages/jb4xw9elz24c5" \
  -H "Token: your-api-key"
```

**JavaScript**

```javascript
const tid = 'jb4xw9elz24c5';
const response = await fetch(`https://api.pocketalert.app/v1/messages/${tid}`, {
  headers: { 'Token': 'your-api-key' }
});
const message = await response.json();
```

**Python**

```python
import requests

tid = 'jb4xw9elz24c5'
response = requests.get(
    f'https://api.pocketalert.app/v1/messages/{tid}',
    headers={'Token': 'your-api-key'}
)
print(response.json())
```

**PHP**

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

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

## Resposta

### Resposta de sucesso

> **Tip: 200 OK**
>
> Retorna o objeto da 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"
}
```

### Respostas de erro

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