API

Accessing the API Documentation

Navigate to your SELMA Settings and down to API at the bottom or go to https://subdomain.selmasis.com/api/docs to view the API docs

You can try out and view responses for the various endpoints on this page, but first you must become ‘Authorised’.

Authentication

  1. Make a request to retrieve a ‘token’ from https://subdomain.selmasis.com/auth
    1. curl:
      1. curl --location --request POST 'https://subdomain.selmasis.com/auth' --header 'Authorization: Basic' --header 'Content-Type: application/json' --data-raw '{"email":"email@example.com","password":"password123"}'
    2. HTTP/REST
      1. POST https://subdomain.selmasis.com/auth Authorization: Basic Content-Type: application/json {"email":"email@example.com","password":"password123"}
  2. The token will be returned as a response.
  3. Add the token to the field when you click on the ‘Authorize’ button at the top of the /docs page. Remember to add “Bearer ” in front of the token (eg “Bearer eyJ0eXAiOiJKV1QiLCJhbGci...“)

You should be able to make requests on this page now.

Requests

To use the bearer token in API requests outside of the docs page make sure to add the bearer token to the header in all requests, these tokens are valid for 30 minutes.

curl:

curl --location 'https://subdomain.selmasis.com/api/example' \ --header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1....'

HTTP/REST:

GET /api/exmaple HTTP/1.1 Host: subdomain.selmasis.com Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGc…