To send requests to Movilitas.Cloud over API, first you need to get an authentication token. By sending an authentication request over Authentication API, you get a dynamic authentication token. The token has an expiration so you need to send the request regularly.


Note: The authentication request described in this topic is only applicable to dynamic tokens. If you are using a static authentication token, ignore this description.


API Tool to Use


In this document, we provide examples by using the cURL command-line tool. You can use any API tool to perform the API requests, for example, Postman or Katalon Studio. 


Before You Begin


Make sure you have created an API key and API secret for your tenant (the company you serve in Movilitas.Cloud as an administrator). For more information, see Managing API Keys.


Procedure


1. Use POST method and the following URL:


https://api.movilitas.cloud/v1/api_auth


2. For the header, define the following:


KeyAction
Content-Type
Apply JSON format for the content. Use the value application/json.



3. In the body of the request, define the API key and API secret as described below.


FieldRequired or Optional?TypeDescription
api_keyRequiredStringThe API key value that was generated in Movilitas.Cloud.
api_secret
RequiredStringThe API secret that was given in Movilitas.Cloud.



4. Send the request. You will receive a response containing the authentication token.


You need to use the authentication token in the API requests that you send to Movilitas.Cloud.


Note: The token you receive has an expiration. Once the token expires, you must authenticate again.



Sample cURL Request


curl -X POST \
  https://api.movilitas.cloud/v1/api_auth \
  -H 'Content-Type: application/json' \
  -d '{
    "api_key": "s_ajk42KdKAhGr!7MFmcT6S8SCsCChssdhMtERSA!CpP8ed93ShmCHhhr2Nh7cGA",
    "api_secret": "Abcd1234!"
}'


Generi


Sample Response (Success 200)


{
  "success": true,
  "message": "Authentication succeeded",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXkiOiJzX2FqazQyS2RLQWhHciE3TUZtY1Q2UzhTQ3NDQ2hzc2RoTXRFUlNBIUNwUDhlZDkzU2htQ0hoaHIyTmg3Y0dBIiwiX2lkIjoiNWQyNzA4ZDc3NDQ1OTcxYjI5MmY4ZDI3IiwiaWF0IjoxNTY0MDU5ODc2LCJleHAiOjE1NjQxNDYyNzZ9.TBMv71CaxCNtE1opQMk0f1ncfbnZ0Cwnu7MWkTzkQqA",
  "currentTime": "2019-07-25T13:04:36.495Z",
  "expiresInMinutes": "1440"
}