The purpose of this guide is to provide background and instruction for utilizing Sharpen’s API Gateway (not legacy API).
The API Gateway is Sharpen’s external API interface to microservice-based functions. If you’re dealing with an API that contains api.sharpencx.com or api.fathomvoice.com, this is not the api gateway. Instead the api gateway will contain api.sharpen.cx in its URL.
Whereas the legacy api leveraged cKey1 and cKey2 on behalf of the organization as a whole, the api gateway leverages user-based api keys and secrets based on a unique JWT (Json Web Token). The api gateway leverages POST, GET, PUT, DELETE, etc. methods instead of just POST from the legacy API.
Table of Contents
Where to access
The API gateway api calls and documentation can be accessed one of two ways; the API Gateway web page, or the preconfigured collection from the Postman collection below. The preconfigured collection contains configurations and examples for Authorization and common SharpenDB2 requests.
API Gateway documentation: Sharpen Public API
Postman download: Postman download
While there are many REST API tools available, we recommend Postman. The export below is in Postman json export v2.1
API Gateway Postman export:
Setting up authorization
In order to send API calls using the API gateway, a system of BearerAuth, apiKey, and apiSecret are used. To start off, you need to gather your Json Web Token
Gathering your JWT(Json Web Token)
Create Authorization API call method
Using Postman, import the API collection above
Once imported, navigate to the ‘Create New Authentication’ API call under the ‘Authorization setup' folder
Identify the ‘Authorization’ tab once selecting the api from the folder list
Choose ‘Basic Auth’ from the drop down
Enter the credentials of the Sharpen account corresponding with the account you’re interfacing with
Click ‘Send’
Response should look like
Login to App method (alternative to the method above)
Gathering apiKey and apiSecret
Navigate to the ‘Create API Key’ api call under the ‘Authorization Setup’ folder within the imported Postman collection.
Click the ‘Authorization’ tab and choose ‘Bearer Token’.
Insert the token gathered in step 7 of “Gathering your JWT” here
Navigate to the ‘Body’ tab
If you want an expiration on the token, update the date/time to the proper expiration time. If you do not want an expiration, modify the body to look like this.
Click ‘Send’
The return should look like this
The language of the response needs translation to what is expected later in the flow
clientId = api-key
clientSecret = api-secret
Executing API call
The examples below are some of many types of API calls which can be run. These show how to create a table and query SharpenDB from the API Gateway. Please refer to the core API Gateway reference to see all available API calls.
Create Table
Identify the ‘Create Table’ request under the ‘SharpenDB2’ folder in the Postman collection
Under the ‘Authorization’ tab, set the ‘Type’ to “No Auth”
Under the ‘Headers’ tab add the following keys (
x-api-key
andx-api-secret
)Enter the values in correspondence with what was retrieved in the ‘Gathering apiKey and apiSecret’ section of this document
Under the ‘Body’ tab enter your query in JSON format
Click ‘Send’
The request and response should look something like this…
Query
Identify the ‘SharpenDB2 Select’ request under the ‘SharpenDB2’ folder in the Postman collection
Under the ‘Authorization’ tab, set the ‘Type’ to “No Auth”
Under the ‘Headers’ tab add the following keys (
x-api-key
andx-api-secret
)Enter the values in correspondence with what was retrieved in the ‘Gathering apiKey and apiSecret’ section of this document
Under the ‘Body’ tab enter your query in JSON format
Click ‘Send’
The request and response should look something like this…
QUERY Examples
The examples below show how to convert common mySQL queries into json bodies for the api requests above.