Endpoint: POST /api/users
Request Body:
{
"username": "kevin",
"password": "password",
"name": "Kevin Abrar Khansa"
}
Response Body (Success):
{
"data": {
"username": "kevariable",
"name": "Kevin Abrar Khansa"
}
}
Response Body (Failed):
{
"errors": "username is required"
}
Endpoint: POST /api/login
Request Body:
{
"username": "kevin",
"password": "password"
}
Response Body (Success):
{
"data": {
"username": "kevariable",
"name": "Kevin Abrar Khansa",
"token": "a14969b1-6bdb-4ab2-8714-fd5a72db0037"
}
}
Response Body (Failed):
{
"errors": "username is not exists."
}
Endpoint: GET /api/users/current
Request Header:
- X-API-TOKEN: token
Response Body (Success):
{
"data": {
"username": "kevariable",
"name": "Kevin Abrar Khansa"
}
}
Response Body (Failed):
{
"errors": "Unauthorized user."
}
Endpoint: PATCH /api/users
Request Header:
- X-API-TOKEN: token
Request Body:
{
"data": {
"password": "password",
"name": "Kevin Abrar Khansa"
}
}
Response Body (Success):
{
"data": {
"username": "kevariable",
"name": "Kevin Abrar Khansa"
}
}
Response Body (Failed):
{
"errors": "Unauthorized user."
}
Endpoint: DELETE /api/users/logout
Request Header:
- X-API-TOKEN: token
Response Body (Success):
{
"data": "OK"
}
Response Body (Failed):
{
"errors": "Unauthorized user."
}