Authentication
Semua endpoint API publik (/api/v1/*) butuh header:
Authorization: Bearer
Format API key
Dua mode:
| Prefix | Mode | Kegunaan |
|---|---|---|
sk_live_ |
live | Production — payment real, masuk ke saldo |
sk_test_ |
test | Testing — sama-sama hit BRI, bisa untuk dev/demo |
Total panjang: 32 karakter (sk_live_ atau sk_test_ + 24 char random url-safe base64).
⚠️ Saat ini, key live dan test sama-sama hit BRI portal asli. Mode purely cosmetic — Phase 6+ akan tambah test mode yang gak generate QR real (sandbox).
Generate key baru
- Klik "Generate" dengan label deskriptif (mis.
production-bot,staging-test). - Plaintext key tampil sekali. Salin ke environment variable / secret manager.
- Database menyimpan SHA-256 hash, bukan plaintext. Tidak bisa retrieved kembali.
Storage best practice
✅ Server-side only. API key SELALU di backend lo.
❌ JANGAN embed di:
- Client-side JavaScript
- Mobile app code (bisa di-extract via APK reverse)
- Public repo / git commit
- Front-end build output
Rotation
Bila key bocor / lo curiga compromised:
- Buka /dashboard/api-keys.
- Klik Revoke pada key lama. Status ->
revoked, langsung dimatikan untuk request baru. - Generate key baru, deploy ke production.
Idle revoke: kalau key gak dipakai lama, tidak otomatis revoke (Phase 6+ tambah auto-expiry).
Multiple keys per merchant
Lo bisa punya N key per akun (mis. satu per service: web-app, cron-jobs, staging, dst). Tujuan:
- Identifikasi traffic per service di field
key_prefixlog - Revoke 1 service tanpa down service lain
- Pisahkan blast radius leak
Authorization scope (Phase 4 → coming)
Saat ini semua key punya akses penuh ke endpoint API merchant. Granular permission (read-only, payment-create-only) di-build di Phase 6+.
Error response auth
{ "detail": "Invalid API key", "code": "unauthorized", "request_id": "ab12cd34" }
| Code | Penyebab |
|---|---|
unauthorized |
Token kosong, tidak valid, atau revoked |
forbidden |
Akun suspended (admin tindakan) |
Lihat Errors untuk daftar lengkap.