Skip to main content

Autentikasi

Semua endpoint POST di halaman ini menggunakan JSON body dengan Content-Type: application/json.

Base URL:

https://api.snapotp.com

Register

POST /api/auth/register
Content-Type: application/json

Body

{
"username": "johndoe",
"email": "john@example.com",
"password": "secret123",
"name": "John Doe"
}

Contoh Permintaan (cURL)

curl -X POST "https://api.snapotp.com/api/auth/register" \
-H "Content-Type: application/json" \
-d '{
"username": "johndoe",
"email": "john@example.com",
"password": "secret123",
"name": "John Doe"
}'

Login

POST /api/auth/login
Content-Type: application/json

Body

{
"username": "johndoe",
"password": "secret123"
}

Contoh Permintaan (cURL)

curl -X POST "https://api.snapotp.com/api/auth/login" \
-H "Content-Type: application/json" \
-d '{
"username": "johndoe",
"password": "secret123"
}'

Response

{
"success": true,
"data": {
"token": "Bearer token",
"user": {
"id": 1,
"username": "johndoe",
"name": "John Doe",
"email": "john@example.com",
"credit_balance": 5000,
"role_id": 3
}
}
}

Login dengan Google

POST /api/auth/google
Content-Type: application/json

Body

{
"google_id": "google_user_id",
"email": "john@example.com",
"name": "John Doe"
}

Contoh Permintaan (cURL)

curl -X POST "https://api.snapotp.com/api/auth/google" \
-H "Content-Type: application/json" \
-d '{
"google_id": "google_user_id",
"email": "john@example.com",
"name": "John Doe"
}'

Lupa Password

POST /api/auth/forgot-password
Content-Type: application/json

Body

{
"email": "john@example.com"
}

Contoh Permintaan (cURL)

curl -X POST "https://api.snapotp.com/api/auth/forgot-password" \
-H "Content-Type: application/json" \
-d '{ "email": "john@example.com" }'

Reset Password

POST /api/auth/reset-password
Content-Type: application/json

Body

{
"token": "reset_token",
"password": "newpassword123"
}

Contoh Permintaan (cURL)

curl -X POST "https://api.snapotp.com/api/auth/reset-password" \
-H "Content-Type: application/json" \
-d '{
"token": "reset_token",
"password": "newpassword123"
}'

Info Pengguna (Me)

GET /api/auth/me
Authorization: Bearer <token>

Contoh Permintaan (cURL)

curl "https://api.snapotp.com/api/auth/me" \
-H "Authorization: Bearer <token>"