Endpoint: POST /api/contacts
Request Header:
- X-API-TOKEN: token
Request Body:
{
"first_name": "Kevin Abrar",
"last_name": "Khansa",
"email": "[email protected]",
"phone": "60"
}
Response Body (Success):
{
"data": {
"id": 1,
"first_name": "Kevin Abrar",
"last_name": "Khansa",
"email": "[email protected]",
"phone": "60"
}
}
Response Body (Failed):
{
"errors": "first_name is required."
}
Endpoint: GET /api/contacts/{contactId}
Request Header:
- X-API-TOKEN: token
Response Body (Success):
{
"data": {
"id": 1,
"first_name": "Kevin Abrar",
"last_name": "Khansa",
"email": "[email protected]",
"phone": "60"
}
}
Response Body (Failed):
{
"errors": "Contact ID: {contactId} not found."
}
Endpoint: PUT /api/contacts/{contactId}
Request Header:
- X-API-TOKEN: token
Request Body (Success):
{
"first_name": "Kevin Abrar",
"last_name": "Khansa",
"email": "[email protected]",
"phone": "60"
}
Response Body (Success):
{
"data": {
"id": 1,
"first_name": "Kevin Abrar",
"last_name": "Khansa",
"email": "[email protected]",
"phone": "60"
}
}
Response Body (Failed):
{
"errors": "Contact ID: {contactId} not found."
}
Endpoint: DELETE /api/contacts/{contactId}
Request Header:
- X-API-TOKEN: token
Response Body (Success):
{
"data": "OK"
}
Response Body (Failed):
{
"errors": "Contact ID: {contactId} not found."
}
Endpoint: GET /api/contacts/search
Request Header:
- X-API-TOKEN: token
Query Params:
- name: string, either contact first_name or last_name, optional
- phone: string, contact phone, optional
- email: string, email address, optional
- page: number, default 1
- size: number, default 10
Response Body (Success):
{
"data": [
{
"id": 1,
"first_name": "Kevin Abrar",
"last_name": "Khansa",
"email": "[email protected]",
"phone": "60"
},
{
"id": 2,
"first_name": "Intan",
"last_name": "Khansa",
"email": "[email protected]",
"phone": "60"
}
],
"paging": {
"current_page": 1,
"total_page": 10,
"size": 10
}
}
Response Body (Failed):
{
"errors": "Unauthorized user."
}