Step 2: Obtain your access token

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

Content-Type

Yes

String

The media type of the body sent to the API.
Enter: application/json.

Accept

Yes

String

The media type of response the client can accept.
Enter: application/json.

Request Body

The following table describes each parameter in the request body.

ParameterRequiredData TypeDescription
usernameYesStringThe API user's username.
passwordYesStringThe 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 itemTypeDescription
successbooleanAn indication of whether the request was successful or not.
messagestringResponse message.
tokenstringThe access token returned upon successful authorization, used to authenticate subsequent requests.
error_codeintThe error code returned if the request is unsuccessful. For a list of possible error codes, see Appendix B - Error Codes.