# Crea applicazione (POST)

Crea una nuova applicazione per organizzare e categorizzare i tuoi messaggi.

## Endpoint

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

## Autenticazione

> **Info: Obbligatorio**
>
> Includi una di queste intestazioni nella tua richiesta:
> - `Token: <your-api-key>` — Ottienila da [Chiavi API](https://pocketalert.app/account/apikeys)
> - `Authorization: Bearer <jwt-token>` — Da [Accedi](https://info.pocketalert.app/api/user/login.md)

## Richiesta

### Intestazioni

| Intestazione | Obbligatoria | Descrizione |
|--------------|:------------:|-------------|
| `Content-Type` | ✅ | `application/json` |
| `Token` | ✅ | La tua chiave API |
| `Authorization` | ✅ | `Bearer <jwt-token>` |

### Parametri del corpo

| Parametro | Tipo | Obbligatorio | Descrizione |
|-----------|------|:------------:|-------------|
| `name` | string | ✅ | Nome dell'applicazione |
| `color` | string | ❌ | Colore dell'applicazione (esadecimale) |

### Esempio di richiesta

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

## Risposta

### Risposta di successo

> **Tip: 201 Created**
>
> Applicazione creata con successo

| Campo | Tipo | Descrizione |
|-------|------|-------------|
| `tid` | string | Identificatore univoco dell'applicazione |
| `name` | string | Nome dell'applicazione |
| `color` | string | Colore dell'applicazione |
| `is_active` | boolean | Indica se l'applicazione è attiva |
| `created_at` | string | Data e ora di creazione |

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

### Risposte di errore

| Stato | Descrizione |
|:-----:|-------------|
| `401` | Non autorizzato — token non valido o mancante |
| `400` | Richiesta non valida — corpo della richiesta non valido |
