> For the complete documentation index, see [llms.txt](https://trust-positif.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trust-positif.gitbook.io/docs/authentication.md).

# Authentication

Autentikasi **opsional** untuk freemium. Untuk kuota paket premium dan whitelist IP, gunakan **API key**.

## Header API key

```
X-API-Key: tp_<token>
```

Contoh:

```http
POST /api/v1/check HTTP/1.1
Host: trustpositif.id
Content-Type: application/json
X-API-Key: tp_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6
```

Key tersedia setelah registrasi atau pembelian paket — **Dashboard → API Key**.

## Tanpa API key

Request tanpa header `X-API-Key` dikenali berdasarkan **IP klien**. Limit freemium: **100 domain/hari/IP**.

## Premium: whitelist IP

API key premium dapat dibatasi ke IP tertentu. Atur di **Dashboard → API Key & whitelist IP** (satu IP per baris).

Jika IP tidak diizinkan:

```json
{
  "success": false,
  "message": "IP address 203.0.113.1 is not whitelisted for this API key.",
  "code": 403,
  "whitelisted_ips": ["198.51.100.10"]
}
```

HTTP status: **403 Forbidden**.

## Key tidak valid atau nonaktif

```json
{
  "success": false,
  "message": "Invalid API key."
}
```

HTTP status: **401 Unauthorized**.

## Keamanan

* Simpan API key di server backend, bukan di browser atau aplikasi mobile yang bisa di-decompile.
* Jangan commit key ke repositori publik.
* Jika key bocor, buat ulang dari Dashboard dan perbarui di aplikasi Anda.
* Premium: aktifkan whitelist IP hanya untuk IP server yang memanggil API.
