What is the SMAS Gateway API?

The SMAS Gateway API provides a simple and easy method for developers to retrieve data and access various features offered by SMAS. By integrating the SMAS API, it becomes even easier to maintain high compliance levels among contractors working for you. The SMAS API transfers data using JSON and can only be accessed by requests made from a server. AJAX and other client-side requests will be blocked by the CORS policy.

Authentication

Currently, the SMAS API is only available to clients of SMAS. To access the Gateway API, you must have an API user account and an API Key. For more information, contact [email protected].
Warning: Once an API Key is generated, it is only shown once. This means if you lose it, a new key must be generated.

To make a request to the API, you must include the following headers in your HTTP request:

Header Purpose
API_KEY This is the API key which was generated for you
Authorization This is a BASE64 encoded string of the form 'email:password'
Content-Type This should be set to 'application/json'

If your generated API key is 3RrZKmwfSPn8OYTw9UfWpdQjAL8isgBwMq3, the API_KEY header would be:

API_KEY: 3RrZKmwfSPn8OYTw9UfWpdQjAL8isgBwMq3

If your email is '[email protected]' and your password 'test123', you would first put them into the form '[email protected]:test123' and then BASE64 encode the string. This would result in the Authorization header below:

Authorization: Basic dGVzdEB0ZXN0LmNvbTp0ZXN0MTIz

After the server authorises your request, it will process it and return a JSON response.

Making a request

Requests to the SMAS Gateway API are always prefixed with https://gateway.smasltd.com/api/v{version}/ where version is the version of the API you are making a call to. An endpoint must be added to help the server identify and return the correct response.

.NET MVC + C#

This is an example of how you could choose to call the SMAS API using C# with the MVC .NET framework.

HttpClient _client = new HttpClient();
_client.DefaultRequestHeaders.Add("API_KEY", "3RrZKmwfSPn8OYTw9UfWpdQjAL8isgBwMq3");
_client.DefaultRequestHeaders.Add("Authorization", "Basic dGVzdEB0ZXN0LmNvbTp0ZXN0MTIz");

var result = await _client.GetAsync("https://gateway.smasltd.com/api/v1/contractors/9804");

if (!result.IsSuccessStatusCode)
    return default;

var stream = await result.Content.ReadAsStringAsync();

var ReturnedSmasMember = JsonConvert.DeserializeObject<object>(stream);

Available HTTP Requests

Method Purpose
GET Retrieves a resource or list of resources
POST Creates a resource

Server Responses

Status Code Description
200 OK Successful request
201 Created The resource was successfully created
400 Bad Request The request was invalid
401 Unauthorized The authentication check failed
403 Forbidden Access to the resource was denied
404 Not Found The resource was not found
409 Conflict There was a conflict when trying to create a resource
Version 1 Endpoints