# Obtener mensaje (GET)

Obtén los detalles de un mensaje específico mediante su identificador único.

## Endpoint

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

## Autenticación

> **Info: Obligatorio**
>
> Incluye una de estas cabeceras en tu solicitud:
> - `Token: <your-api-key>` — Obtenla en [Claves de API](https://pocketalert.app/account/apikeys)
> - `Authorization: Bearer <jwt-token>` — Desde [Iniciar sesión](https://info.pocketalert.app/api/user/login.md)

## Solicitud

### Parámetros de ruta

| Parámetro | Tipo | Obligatorio | Descripción |
|-----------|------|:--------:|-------------|
| `tid` | string | ✅ | Identificador único del mensaje |

### Cabeceras

| Cabecera | Obligatorio | Descripción |
|--------|:--------:|-------------|
| `Token` | ✅ | Tu clave de API |
| `Authorization` | ✅ | `Bearer <jwt-token>` |

### Ejemplo de solicitud

**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();
```

## Respuesta

### Respuesta correcta

> **Tip: 200 OK**
>
> Devuelve el objeto del mensaje

| Campo | Tipo | Descripción |
|-------|------|-------------|
| `tid` | string | Identificador único del mensaje |
| `title` | string | Título del mensaje |
| `message` | string | Cuerpo del mensaje |
| `application` | string | Nombre de la aplicación |
| `device` | string | Dispositivo de destino |
| `is_read` | boolean | Indica si el mensaje se leyó |
| `created_at` | string | Fecha de creación |

```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"
}
```

### Respuestas de error

| Estado | Descripción |
|:------:|-------------|
| `401` | No autorizado — Token no válido o ausente |
| `404` | No encontrado — El mensaje no existe |
