Skip to content

Latest commit

 

History

History
153 lines (114 loc) · 1.6 KB

user.spec.md

File metadata and controls

153 lines (114 loc) · 1.6 KB

User API Spec

Register User

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"
}

Login User

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."
}

Get User

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."
}

Update 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."
}

Logout User

Endpoint: DELETE /api/users/logout

Request Header:

  • X-API-TOKEN: token

Response Body (Success):

{
  "data": "OK"
}

Response Body (Failed):

{
  "errors": "Unauthorized user."
}