Using the API

🚧

Caution: Interacting with the API in this tool and testing endpoints involves live data. API calls in this sandbox environment will impact real data.

API Authentication

Authentication is required for the API.

The Ternary API supports two ways to authenticate to the API.

Short-Lived Access Token

Constraints

  • Access tokens have a twenty-four (24) hour lifetime

Creation

This token depends on your session with the Ternary web app. You can view & copy this token in your browser's Dev Tools console. In Chrome, shown below, your token can be found at the following path Application - Storage - Cookies - https//my.ternary.app - TERNARY-ACCESS-TOKEN

Usage

Include the access token as a bearer token in the Authorization header. The access token bears all the privileges of its corresponding human user.

API Request

curl 'https://core-api.ternary.app/api/some_api_endpoint'
-H "Authorization: Bearer ${ACCESS_TOKEN}"

Long-Lived API Key

You can also authenticate by a long-lived API key. You can use the key anywhere you regularly use a personal access token.

Constraints

  • API Key maximum lifetime is ninety (90) days and will automatically expire unless configured to expire sooner
  • API Keys belong to a specific human User (we do not yet support service accounts)

Creation
You can navigate to API key creation by clicking on the account dropdown in the top right -> "Settings" -> "API Keys" tab -> "Add API Key" button.


Usage

Include the API key as a bearer token in the Authorization header. The API key bears all the privileges of its corresponding human user.

API Request

curl 'https://core-api.ternary.app/api/some_api_endpoint'
-H "Authorization: Bearer ${API_KEY}"

Example Request

This sample workflow will guide you through using your TERNARY_ACCESS_TOKENto query the endpoint /me to see your current user attributes.

Log In to Ternary

Locate and Copy TERNARY-ACCESS-TOKEN

Steps below are using Chrome

  • Open Chrome DevTools

  • Select Application Tab


  • Filter TERNARY_ACCESS_TOKENand copy the Valueto your clipboard


Navigate to API Reference for /me

  • Navigate to the endpoint to test the query.

  • Paste TERNARY_ACCESS_TOKEN into Authorizationinput

  • ClickTry It! to perform the request and observe the Response.

Finding Your tenantID

tenantID is your organizations unique identifier and used throughout the API as a query parameter. It is found within the browser URL tenant_id=<YOUR_TENANT_ID>