Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

REQUEST

This API is used to authenticate user based on the credentials that provided on the body of API. You can call this API without Header.

The user can be Admin, Agent or Client. The structure of API as below:

POST/auth

BODY

You have to put the Authentication Credential into the body of API. The Credential includes the Username and Password of the User.

See example as below:

Code Block
{
	"password": "string",
	"email_or_name": "string"
}

JSON RESPONSE

There is message return as JSOM format. It will return the result of API and the related information as well.

If successful, It will return code 200 and message as below:

Code Block
{
 	"success": true/false,
  	"payload": { Related Information of the User }
 	"token":"User Token",
   	"cdr_api_token": "cdr_api_token"
}

 

If missing body, It will return code 400 and message as below:

Code Block
{
   "error_type": "validation_error",
   "success": false,
   "errors": [   {
      "password": ["Missing data for required field."],
      "email_or_name": ["Missing data for required field."]
   }]
}

 

If the credentials wrong, it will return code 401 and message as below:

Code Block
{
  	"error_type": "operation_error",
   	"success": false,
   	"error":    {
      	"message": "Can't find user with credentials provided",
      	"code": 100,
      	"reason": "incorrect_credentials"
   	}
}
Panel

On this page:

Table of Contents

EXAMPLE

We will know more about the API through the example below:

Request

I will call API to autheticate the admin account:

Code Block
curl \
-X POST -d "{ \"password\": \"dnladminpass\", \"email_or_name\": \"admin\"}" \
"http://88.99.175.131:8000/v1/auth"
 

Response

Code Block
{
	"success": true,
   	"payload":    {
      	"cdr_api_token_expiration": "186544678",
      	"user":       {
         	"login_ip": "183.182.110.28",
         	"first_name": "admin",
         	"fullname": "admin admin",
         	"create_time": "2017-09-08T22:00:00+00:00",
         	"passwd": "$2a$12$.vfsbhghghjfgfghdfdghhh7iyoz/euRq6r6",
         	"report_count": "1 Hour",
         	"is_online": 1,
         	"last_name": "admin",
         	"role_name": "Administrator",
         	"client_id": null,
         	"cdr_api_token": "eHC0k8DDj4nqlIBYpVtSXizPEI8lrOyUe8UMEhZykNmVdx2SSt",
         	"user_id": 1,
         	"all_termination": true,
         	"show_carrier_trunk_drop_only": true,
         	"default_mod": "0",
         	"user_type": "admin",
         	"client_limits":          [
            	{"client_id": 2916},
            	{"client_id": 2917}
         		],
       	"role_id": 0,
      	"last_login_time": "2018-02-24T21:05:36.094423+00:00",
      	"reseller_id": 0,
       	"cdr_expire": "2018-02-25T14:11:53+00:00",
      	"outbound_report": true,
       	"email": "[email protected]",
       	"carrier_name": null,
       	"default_mod2": "0",
       	"active": true,
       	"landing_page": "/routing/rate_table",
       	"create_user_id": null,
       	"card_id": 0,
       	"name": "admin",
       	"client": null,
       	"report_group": true,
       	"last_seen": "2018-02-24T22:11:18.724125+00:00",
       	"report_fields": "111",
       	"is_preload": true,
       	"default_billing_decimal": 0,
       	"avatar_id": 1366,
       	"auth_ip": [],
       	"agent": null
      	},
 	"token": "eyaskjksadkasd9.9123kjsadhkj123jhasdjajsjsdhKS.IH5uHASSJsadnbads980asTHo9dhljM",
  	"cdr_api_token": "eHC0hakjsdhjhjqeweqweq32njkasdjSSt"
   }
}