So you have made it past OAuth, now to access your Essentials file via the API, you will want to build the request.
The request is made up of 4 parts
- The URL
- List of Headers
So let's get started...
The first part of a request that you need to supply is a base URL. In the case of the Essentials API, depending on which region you want to consume will depend on which base URL you use.
The URL that you use will need to consist of the base URL, Business id and endpoint. For example:
The Method part of the request determines the action that you want to take with the API. The methods that the Essentials API supports are;
GET - This will retrieve data
POST - Ths will create new data.
PUT - This will allow you to update existing data
DELETE - This will allow you to remove data.
One thing to note is that not all endpoints will support all Methods. Its recommend that you check out the endpoint documentation to make sure that you are using a supported Method for the endpoint that you want to use.
Headers are an essential part of any request. They carry information that the API needs to accept the request. Each API will have different headers that are required. Here are the ones that Essentials needs:
Not all API requests will require a Body but depending on the Method that you are using will determine if you need to add a Body to the request.
The POST and PUT Methods are the two methods that most likely will require a Body to be supplied. The Body is where you supply the data that you want to use in your API request.
Check out our Creating an Invoice article to explore what the Body of a POST looks like.