Dua cara autentikasi dengan API s.id — API key untuk server-ke-server, OAuth 2.0 untuk bertindak atas nama pengguna.
API key mengautentikasi integrasi server-ke-server. Buat satu di Dashboard → Developer → API Keys, pilih scope Anda, dan kirimkan sebagai token Bearer.
Header Otorisasi
Authorization: Bearer sk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxContoh permintaan
curl https://api.s.id/v2/links \
-H "Authorization: Bearer sk_live_..."
Scope yang tersedia
links:readList and read linkslinks:writeCreate and update links (create, edit, restore)links:archiveArchive linkslinks:analyticsRead per-link click statistics and lifetime countsqr:readRead QR code settings (global and per-link)qr:writeCustomize QR code settings (global and per-link)user:readRead the authenticated user profile and account quotamicrosites:readRead micrositesmicrosites:writeCreate, update, delete and manage components of micrositesGunakan alur authorization-code untuk bertindak atas nama pengguna s.id. Aplikasi Anda mengarahkan pengguna ke s.id untuk persetujuan, lalu menukarkan kode dengan token akses.
Alur otorisasi
GET https://dash.s.id/oauth/authorize
?client_id=YOUR_CLIENT_ID
&redirect_uri=https://yourapp.com/callback
&response_type=code
&scope=links:read links:write
&state=RANDOM_STATE
&code_challenge=CODE_CHALLENGE
&code_challenge_method=S256POST https://app.s.id/oauth/token
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code
&code=AUTH_CODE
&redirect_uri=https://yourapp.com/callback
&client_id=YOUR_CLIENT_ID
&client_secret=YOUR_CLIENT_SECRET
&code_verifier=CODE_VERIFIERGET https://app.s.id/oauth/userinfo
Authorization: Bearer ACCESS_TOKENPKCE (S256) wajib digunakan untuk public client — aplikasi tanpa client secret (SPA, mobile, CLI) — dan opsional untuk confidential client. Tambahkan code_challenge dan code_challenge_method pada langkah 1, serta code_verifier pada langkah 2. Access token yang dihasilkan bekerja seperti API key pada endpoint /v2 mana pun, sesuai scope yang diberikan pengguna.