Table of Contents


Authentication

In order to work with Magentrix REST API, you first need to get a session token using the below authentication methods. Then you can use the Session ID as a Bearer token to perform other actions such as "Creating" or "Updating" records.
 
Note that Magentrix Session IDs don't support sliding expiration. Therefore, in your application you need to monitor the validity of your Session ID and renew it as needed.
 

Authentication Via Token

You may use the Private App feature under the user's setting to generate a secure API Key (token). Using this key, you can call the endpoint below to get a new Session ID which can be used for subsequent API calls.

POST https://<your-portal-domain>/rest/2.0/token
-H "Content-Type: application/json" 
-H "Accept: application/json"
-d {   
     "grant_type" : "refresh_token",
     "refresh_token" : "<api key>"
   }

 

Authentication via Username/Password

 In order to perform the authentication, the following HTTP POST call must be made: 

POST https://<your-portal-domain>/rest/2.0/createsession
 -H "Content-Type: application/json"
 -H "Accept: application/json"
 -d { 
      "UserName" : "<username>",     
      "Password" : "<password>" 
    }


Sample of authentication success response:

{
  "SessionId": "<sessionId>",
  "DateIssued": "<issueDate>",
  "ValidUntil": "<validUntilDate>",
  "IsSuccess": true,
  "Errors": []
}

Date sample: 2019-11-21T21:25:28.0583347Z

Sample of authentication failed response:

{
  "SessionId": null,
  "DateIssued": "2019-11-22T18:34:50.4506867Z",
  "ValidUntil": "0001-01-01T00:00:00",
  "IsSuccess": false,
  "Errors": [
    {
      "Code": null,
      "PropertyName": null,
      "Message": "Login failed."
    }
  ]
}