Skip to main content

Authentication

API SAFFMedic menggunakan JWT (JSON Web Token) untuk autentikasi.
Setiap endpoint yang membutuhkan autentikasi harus menyertakan header berikut:

Authorization: Bearer <jwt_token>
Content-Type: application/json
Accept: application/json


Registration

Mendaftarkan pengguna baru.

POST /v1/auth/register

Request

{
"name": "Parker",
"phone_number": "0000000000",
"phone_country_code": "000",
"email": "[email protected]",
"password": "password123",
"password_confirmation": "password123",
"device_id": ""
}

Response (201) Menandakan Registrasi telah berhasil dan sistem mengembalikan token JWT


{
"status": "success",
"message": "Registrasi berhasil",
"data": {
"user": {
"id": "45d65430-cff2-4184-ba12-04f892062689",
"name": "Parker",
"phone_number": "0000000000",
"phone_country_code": "000",
"email": "[email protected]",
"device_id": ""
},
"access_token": "<jwt_token>",
"token_type": "bearer",
"expires_in": 3600
}
}

LOGIN

Digunakan untuk autentikasi pengguna dan menghasilkan token JWT

POST /v1/auth/login

Request

{
"email": "[email protected]",
"password": "password123"
}

Response (200) | Login berhasil dan data pengguna dikembalikan

{
"status": "success",
"data": {
"user": {
"id": "45d65430-cff2-4184-ba12-04f892062689",
"name": "Parker",
"phone_number": "0000000000",
"phone_country_code": "000",
"email": "[email protected]",
"device_id": ""
}
}
}

PROFILE

GET /v1/auth/profile

Authorization: Bearer <jwt_token>

LOGOUT

POST /v1/auth/logout

{
"status": "success",
"message": "Logout berhasil"
}