Using Insomnia

How to use the Insomnia tool to explore the API

Insomnia is a handy API client that can be used to quickly set up and send API requests. There are five key areas that are useful to know about when using Insomnia:

Insomnia overview
Insomnia overview
  1. Environment Variables - Up here is where you view and set your variables in order to run requests against our API. More specifically, you’ll need to set email, password, clientId, clientSecret, organisationId and officeId.
  2. Collection folders and requests - Here you’ll find a list of sample requests:
    • Queries - used for fetching data
    • Mutations - used for modifying data. If you want to add more requests you can click the ”+” icon (just below the Environment Variables section).
  3. Request panel - This is where you can view and edit the requests that you send to First AML’s Public API.
    • At the top, you’ll find the request body where you put in what GraphQL fields you wish to receive back in the request response (Tip: You can use Ctrl + Space to quickly view what fields are available to use for the current query/mutation).
    • At the bottom, you’ll find the “Query Variables” section where you put in the actual data used for querying and modifying the data.
  4. Response panel - This is where you can view the response body of the requests that you send.
  5. Schema documentation - Provided you’ve used the login request first, you can click on this to view the schema documentation for First AML’s Public API and view all the possible queries and mutations available to you.

How to set up Insomnia

  1. Head on over to Insomnia’s download page: https://insomnia.rest/download and click download.
  2. Open the downloaded Insomnia.Core-XXX.exe (if on Windows) or Insomnia.Core-XXX.dmg (if on Mac) and follow the installation instructions.
  3. Open up the Insomnia app.
  4. Download the following collection file for the First AML Public API: first-aml-public-api-insomnia.json
  5. Click the ‘Create’ button in the top right and select ‘Import from File’ and select this downloaded file:
Add workspace
Add workspace

6: Click into the First AML Public API Sandbox to open the imported request collection:

Select workspace
Select workspace

How to use variables in Insomnia

Before you can run any requests in Insomnia (except API Status), you’ll need to set up your environment variables.

In Insomnia, variables are displayed as purple tags like so:

Using variables
Using variables

To see the list of available environment variables you can press Ctrl + Space when inside of the request body or “Query Variables” sections:

Browsing variables
Browsing variables

To modify environment variables you can click on the dropdown near the top left of the screen:

Manage environments
Manage environments

Inside of here, you can modify existing variables and add new ones for environment files:

Changing variables
Changing variables

How to run a request

Once you’ve configured your environment variables, you’re ready to send your first request.

First you’ll need to run the ‘Login’ request. You can send a request by clicking the ‘Send’ button near the top of the screen:

Send
Send

Now, given all your credentials have been filled out in the Environment Variables, you should get a response on the right containing an access token. This access token will get carried over to all other existing requests as a tag with type Response → Body Attribute has been setup in the “Bearer” tab of each request like so:

Populating the bearer token
Populating the bearer token

If you create a new request you’ll need to remember to add this in. You can do this by pressing Ctrl + Space while in the ‘TOKEN’ field and searching for/selecting: Response → Body Attribute . You’ll need to fill out the tag like so:

Bearer token setup
Bearer token setup

Now you’ve done all this, you should be ready to go!


Endpoints
Overview