# Create Application (POST)

Buat aplikasi baru untuk mengelompokkan dan mengategorikan notifikasi push Anda.

## Endpoint

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

## Autentikasi

> **Info: Wajib**
>
> Sertakan salah satu header berikut dalam permintaan Anda:
> - `Token: <your-api-key>` — Dapatkan dari [API Keys](https://pocketalert.app/account/apikeys)
> - `Authorization: Bearer <jwt-token>` — Dari [Login](https://info.pocketalert.app/api/user/login.md)

## Permintaan

### Header

| Header | Wajib | Deskripsi |
|--------|:--------:|-------------|
| `Content-Type` | ✅ | `application/json` |
| `Token` | ✅ | Kunci API Anda |
| `Authorization` | ✅ | `Bearer <jwt-token>` |

### Parameter Body

| Parameter | Tipe | Wajib | Deskripsi |
|-----------|------|:--------:|-------------|
| `name` | string | ✅ | Nama aplikasi |
| `color` | string | ❌ | Warna aplikasi (hex) |

### Contoh Permintaan

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

## Respons

### Respons Sukses

> **Tip: 201 Created**
>
> Aplikasi berhasil dibuat

| Field | Tipe | Deskripsi |
|-------|------|-------------|
| `tid` | string | Pengenal unik aplikasi |
| `name` | string | Nama aplikasi |
| `color` | string | Warna aplikasi |
| `is_active` | boolean | Apakah aplikasi aktif |
| `created_at` | string | Waktu pembuatan |

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

### Respons Error

| Status | Deskripsi |
|:------:|-------------|
| `401` | Unauthorized — Token tidak valid atau tidak ada |
| `400` | Bad Request — isi permintaan tidak valid |
