---
# System prepended metadata

title: Rest API template

---

# 1. Request/Response Format
## 1.1. General
- Dates are UTC time and returned in ISO8601 format:
```
YYYY-MM-DDTHH:mm:ssZ   //Ex. 2022-02-22T20:02:22Z
YYYY-MM-DD             //Ex. 2022-02-22
HH:MM                  //Ex. 20:02
```

## 1.2. Parameters
Pagination
```
page: int
pageSize: int
```

## 1.3. Response
Paging Array response
```json
{
    "code": String,
    "message": String
    "page": int
    "total_pages": int
    "total_results": int
    "data" : [
        ...
    ]
}
```
Array response
```json
{
    "code": String,
    "message": String
    "data" : [
        ...
    ]
}
```
Object response
```json
{
    "code": String,
    "message": String
    "data" : {
       ... 
    }
}
```
Code: Business error code
```
"email_not_found"
"user_deleted"
```
Message: Business message
```
"Email is requered"
```

## 1.4. HTTP Error Code
```
400 Bad Request
401 Unauthorized
404 Not Found
500 Internal Server Error
```

# 2. JWT Auth 
### Authentication
``` json
//Request:
[POST] https://api.domain.com/api/v1/auth/login
# Body
{
  "email": "string",
  "password": "string"
}
//Response:
{
  "access_token": "string",
  "refresh_token": "string"
}
```
### Get user with session
```json
//Request:
[GET] https://api.domain.com/api/v1/auth/profile
# Headers
{
  "Authorization": "Bearer {your access token}"
}
//Response:
{
  "id": 1,
  "email": "string",
  "name": "string",
  "avatar": "url",
    ...
}
```
### Get a new Access Token with a Refresh Token
```json
//Request:
[POST] https://api.domain.com/api/v1/refresh-token
# Body
{
  "refreshToken": "{your refresh token}"
}
//Response:
{
  "access_token": "string",
  "refresh_token": "string"
}
```
