ping!
Ke aplikasi
Developer · API internal

Akun & preferensi

Identitas sesi, pembaruan nama/username, dan pengaturan notifikasi serta tampilan ringkas.

Unduh OpenAPI 3.1
Di 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.

Kontrak nyata, nilai contoh

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

GET/api/meSession cookie

Source : app/api/me/route.ts

Mengembalikan identitas sesi dan ringkasan dompet. username dapat null. role berasal dari server; client tidak dapat menentukan role sendiri.

GET /api/me · JavaScript
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

PATCH/api/meSession cookie

Source : app/api/me/route.ts

Memperbarui nama dan username. Kedua field wajib dikirim bersama. Endpoint ini bukan untuk mengganti email, password, role, atau userId.

Ubah profil
Body JSONTipeWajibKeterangan
namestringYaNama 1–60 karakter setelah trim. Wajib bersama username.
usernamestringYa3–24 karakter: huruf, angka, titik, atau underscore; input di-trim.
PATCH /api/me · JavaScript
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;
Ubah profil
Kode errorHTTPTindakan
VALIDATION_ERROR400Periksa tipe, field wajib, format UUID, dan field tambahan.

Baca preferensi

GET/api/profile/settingsSession cookie

Source : app/api/profile/settings/route.ts

Membaca preferensi akun. Jika belum ada pengaturan tersimpan, notifications bernilai true dan compact bernilai false.

GET /api/profile/settings · JavaScript
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

PATCH/api/profile/settingsSession cookie

Source : app/api/profile/settings/route.ts

Kirim minimal satu boolean. Field yang tidak dikirim tetap dipertahankan; body {} dan field tambahan ditolak.

Simpan preferensi
Body JSONTipeWajibKeterangan
notificationsbooleanTidakSesuai tipe yang ditampilkan.
compactbooleanTidakSesuai tipe yang ditampilkan.
PATCH /api/profile/settings · JavaScript
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;
Simpan preferensi
Kode errorHTTPTindakan
VALIDATION_ERROR400Periksa tipe, field wajib, format UUID, dan field tambahan.

Schema · Me

Schema · Me
FieldTipeWajibKeterangan
userobjectYaSesuai tipe yang ditampilkan.
balanceintegerYaRupiah utuh, bukan sen atau string berformat.
heldintegerYaRupiah utuh, bukan sen atau string berformat.
availableintegerYaRupiah utuh, bukan sen atau string berformat.

Schema · Profile

Schema · Profile
FieldTipeWajibKeterangan
namestringYaSesuai tipe yang ditampilkan.
usernamestring | nullYaSesuai tipe yang ditampilkan.
emailstringYaSesuai tipe yang ditampilkan.

Schema · UserSettings

Schema · UserSettings
FieldTipeWajibKeterangan
notificationsbooleanYaNotifikasi SMS; default true jika belum disimpan.
compactbooleanYaTampilan ringkas; default false jika belum disimpan.
Ping! · Panduan yang tumbuh bersama produknya.Bantuan