# Criar Aplicativo (POST)

Crie um novo aplicativo para organizar e categorizar suas mensagens.

## Endpoint

```
POST https://api.pocketalert.app/v1/applications
```

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

## Requisição

### Cabeçalhos

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

### Parâmetros do Corpo

| Parâmetro | Tipo | Obrigatório | Descrição |
|-----------|------|:-----------:|-----------|
| `name` | string | ✅ | Nome do aplicativo |
| `color` | string | ❌ | Cor do aplicativo (hex) |

### Exemplo de Requisição

**cURL**

```bash
curl -X POST "https://api.pocketalert.app/v1/applications" \
  -H "Token: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Production Monitoring",
    "color": "#FF0000"
  }'
```

**JavaScript**

```javascript
const response = await fetch('https://api.pocketalert.app/v1/applications', {
  method: 'POST',
  headers: {
    'Token': 'your-api-key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: 'Production Monitoring',
    color: '#FF0000'
  })
});

const application = await response.json();
console.log(application);
```

**Python**

```python
import requests

response = requests.post(
    'https://api.pocketalert.app/v1/applications',
    headers={
        'Token': 'your-api-key',
        'Content-Type': 'application/json'
    },
    json={'name': 'Production Monitoring', 'color': '#FF0000'}
)

print(response.json())
```

**PHP**

```php
$response = Http::withHeaders([
    'Token' => 'your-api-key',
])->post('https://api.pocketalert.app/v1/applications', [
    'name' => 'Production Monitoring',
    'color' => '#FF0000',
]);

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

## Resposta

### Resposta de Sucesso

> **Tip: 201 Created**
>
> Aplicativo criado com sucesso

| Campo | Tipo | Descrição |
|-------|------|-----------|
| `tid` | string | Identificador único do aplicativo |
| `name` | string | Nome do aplicativo |
| `color` | string | Cor do aplicativo |
| `is_active` | boolean | Se o aplicativo está ativo |
| `created_at` | string | Data e hora de criação |

```json
{
  "tid": "iemkz2tlbakj4lgns961ohx0o",
  "name": "Production Monitoring",
  "color": "#FF0000",
  "is_active": true,
  "created_at": "18.01.2026 15:29:02"
}
```

### Respostas de Erro

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