# Créer une application (POST)

Créez une nouvelle application pour organiser et catégoriser vos messages.

## Endpoint

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

## Authentification

> **Info: Obligatoire**
>
> Incluez l’un de ces en-têtes dans votre requête :
> - `Token: <your-api-key>` — Récupérez-la dans [Clés API](https://pocketalert.app/account/apikeys)
> - `Authorization: Bearer <jwt-token>` — Obtenu via [Connexion](https://info.pocketalert.app/api/user/login.md)

## Requête

### En-têtes

| En-tête | Obligatoire | Description |
|--------|:--------:|-------------|
| `Content-Type` | ✅ | `application/json` |
| `Token` | ✅ | Votre clé API |
| `Authorization` | ✅ | `Bearer <jwt-token>` |

### Paramètres du corps

| Paramètre | Type | Obligatoire | Description |
|-----------|------|:--------:|-------------|
| `name` | string | ✅ | Nom de l’application |
| `color` | string | ❌ | Couleur de l’application (hexadécimal) |

### Exemple de requête

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

## Réponse

### Réponse de succès

> **Tip: 201 Created**
>
> Application créée avec succès

| Champ | Type | Description |
|-------|------|-------------|
| `tid` | string | Identifiant unique de l’application |
| `name` | string | Nom de l’application |
| `color` | string | Couleur de l’application |
| `is_active` | boolean | Indique si l’application est active |
| `created_at` | string | Horodatage de création |

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

### Réponses d’erreur

| Statut | Description |
|:------:|-------------|
| `401` | Non autorisé — jeton absent ou invalide |
| `400` | Requête incorrecte — corps de requête invalide |
