Every request to WorkN APIs must be authenticated using an access token, a unique string of characters used to authenticate and authorize API requests. Typically, this token is included in the Authorization header of HTTP requests to provide access to protected resources.
To obtain a valid token for all subsequent authenticated calls, the initial request you make is a POST call to the Log In endpoint, providing the required information. The call must be made for an API User that has been configured and granted permissions to make API calls within the system.
Request
POST https://prod1.serveture.com/public-api/user_login/
Request Headers
The following table describes each parameter that must be included in the request header.
Parameter | Required | Data Type | Description |
---|---|---|---|
| Yes | String | The media type of the body sent to the API. |
| Yes | String | The media type of response the client can accept. |
Request Body
The following table describes each parameter in the request body.
Parameter | Required | Data Type | Description |
---|---|---|---|
username | Yes | String | The API user's username. |
password | Yes | String | The API user's password. |
Example Request
{
"method": "POST",
"url": "http://prod1.serveture.com/public-api/user_login/",
"headers": {
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization": "Token <place token returned from Login endpoint here>"
},
"body": {
"username": "string",
"password": "string"
}
}
Example Response
{
"success": true,
"message": "Successful Call!",
"token": "8ebd63e6c7381ab4368dbbe400h9374c544aeed8"
}
The example response above provides a shortened version of the response code. In addition to the token, upon successful authorization, you will always receive additional information about the marketplace your API user is authorized for (market_place_info), including lists of enterprises (enterprise_list) and branches (branch_list). For details, check the Log In endpoint documentation.
Response Definitions
The following table describes each item in the example response.
Response item | Type | Description |
---|---|---|
success | boolean | An indication of whether the request was successful or not. |
message | string | Response message. |
token | string | The access token returned upon successful authorization, used to authenticate subsequent requests. |
error_code | int | The error code returned if the request is unsuccessful. For a list of possible error codes, see Appendix B - Error Codes. |