Akun & preferensi
Identitas sesi, pembaruan nama/username, dan pengaturan notifikasi serta tampilan ringkas.
Unduh OpenAPI 3.1Di halaman ini
Sebelum mengirim request
Endpoint ini bukan pengganti Better Auth. Penggantian email/password dan pengelolaan role tidak tersedia melalui PATCH /api/me. Profil dan preferensi disimpan di server untuk akun bersesi.
Endpoint, field, dan status HTTP mengikuti implementasi. Nilai ID, nomor, OTP, waktu, saldo, serta quote di contoh adalah ilustrasi, bukan data akun atau pilihan yang bisa langsung dibeli. Ganti dengan data dari instalasimu. Halaman ini tidak mengirim request atau menjalankan transaksi.
JavaScript dijalankan pada origin aplikasi setelah login. Contoh cURL memakai PING_ORIGIN dan cookie jar PING_COOKIE_JAR dari panduan autentikasi. Sukses memakai { ok: true, data }; create juga HTTP 200, bukan 201. Semua endpoint di halaman ini memerlukan sesi aktif dan dapat mengembalikan 401, 403, atau 500.
Baca akun & saldo
/api/meSession cookieSource : app/api/me/route.ts
Mengembalikan identitas sesi dan ringkasan dompet. username dapat null. role berasal dari server; client tidak dapat menentukan role sendiri.
const response = await fetch("/api/me", {
credentials: "same-origin",
cache: "no-store",
});
const body = await response.json();
if (!response.ok || !body.ok) {
throw Object.assign(
new Error(body.error?.message ?? "Request gagal"),
{ code: body.error?.code, status: response.status },
);
}
const data = body.data;Ubah profil
/api/meSession cookieSource : app/api/me/route.ts
Memperbarui nama dan username. Kedua field wajib dikirim bersama. Endpoint ini bukan untuk mengganti email, password, role, atau userId.
| Body JSON | Tipe | Wajib | Keterangan |
|---|---|---|---|
| name | string | Ya | Nama 1–60 karakter setelah trim. Wajib bersama username. |
| username | string | Ya | 3–24 karakter: huruf, angka, titik, atau underscore; input di-trim. |
const response = await fetch("/api/me", {
method: "PATCH",
credentials: "same-origin",
cache: "no-store",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"name": "Developer",
"username": "developer"
}),
});
const body = await response.json();
if (!response.ok || !body.ok) {
throw Object.assign(
new Error(body.error?.message ?? "Request gagal"),
{ code: body.error?.code, status: response.status },
);
}
const data = body.data;| Kode error | HTTP | Tindakan |
|---|---|---|
| VALIDATION_ERROR | 400 | Periksa tipe, field wajib, format UUID, dan field tambahan. |
Baca preferensi
/api/profile/settingsSession cookieSource : app/api/profile/settings/route.ts
Membaca preferensi akun. Jika belum ada pengaturan tersimpan, notifications bernilai true dan compact bernilai false.
const response = await fetch("/api/profile/settings", {
credentials: "same-origin",
cache: "no-store",
});
const body = await response.json();
if (!response.ok || !body.ok) {
throw Object.assign(
new Error(body.error?.message ?? "Request gagal"),
{ code: body.error?.code, status: response.status },
);
}
const data = body.data;Simpan preferensi
/api/profile/settingsSession cookieSource : app/api/profile/settings/route.ts
Kirim minimal satu boolean. Field yang tidak dikirim tetap dipertahankan; body {} dan field tambahan ditolak.
| Body JSON | Tipe | Wajib | Keterangan |
|---|---|---|---|
| notifications | boolean | Tidak | Sesuai tipe yang ditampilkan. |
| compact | boolean | Tidak | Sesuai tipe yang ditampilkan. |
const response = await fetch("/api/profile/settings", {
method: "PATCH",
credentials: "same-origin",
cache: "no-store",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"compact": true
}),
});
const body = await response.json();
if (!response.ok || !body.ok) {
throw Object.assign(
new Error(body.error?.message ?? "Request gagal"),
{ code: body.error?.code, status: response.status },
);
}
const data = body.data;| Kode error | HTTP | Tindakan |
|---|---|---|
| VALIDATION_ERROR | 400 | Periksa tipe, field wajib, format UUID, dan field tambahan. |
Schema · Me
| Field | Tipe | Wajib | Keterangan |
|---|---|---|---|
| user | object | Ya | Sesuai tipe yang ditampilkan. |
| balance | integer | Ya | Rupiah utuh, bukan sen atau string berformat. |
| held | integer | Ya | Rupiah utuh, bukan sen atau string berformat. |
| available | integer | Ya | Rupiah utuh, bukan sen atau string berformat. |
Schema · Profile
| Field | Tipe | Wajib | Keterangan |
|---|---|---|---|
| name | string | Ya | Sesuai tipe yang ditampilkan. |
| username | string | null | Ya | Sesuai tipe yang ditampilkan. |
| string | Ya | Sesuai tipe yang ditampilkan. |
Schema · UserSettings
| Field | Tipe | Wajib | Keterangan |
|---|---|---|---|
| notifications | boolean | Ya | Notifikasi SMS; default true jika belum disimpan. |
| compact | boolean | Ya | Tampilan ringkas; default false jika belum disimpan. |