Link Component
Terminal provides a hosted ‘Link’ that makes it easy to authenticate with any telematics provider. With only a few steps you will be able to provide customers/partners an easy self-serve flow to connect their telematics account.
Accessing Terminal Link
Terminal Link is a user-friendly, hosted page designed to facilitate authentication with any telematics provider. It provides a simple, self-serve flow for customers or partners to connect their telematics accounts.
You have two options to integrate Terminal Link into your application:
- Directly link to the hosted page.
- Embed it within your application using one of our SDKs.
Terminal provides a React hook that makes it easy to embed the link in your application.
View the package on NPM here: @terminal-api/link-react
Installation
Usage
Creating a Connection
Terminal handles capturing, validating and securely storing customer’s credentials to ensure that each TSP integration is as consistent as possible.
Here’s an overview of the steps involved when using the React hook:
Steps
- Initialize auth link with desired options (see available options below)
- Open link and wait for user to complete authentication
- Handle
onSuccess
callback and exchange public token for a connection token on your backend usingPOST /tsp/v1/public-token/exchange
Re-Authenticating a Connection
In certain scenarios, connections may become disconnected. This can occur when customers modify their password or withdraw access.
In such cases, Terminal updates the Connection status to disconnected
and prompts you to reauthenticate the customer’s TSP to continue syncing.
The reauthentication process mirrors the link flow, but requires the connectionId
parameter to specify which connection needs to be updated.
Examples
Available Options
The link SDK provides a number of options to customize the behavior of the link.
Can either provide a publishableKey
or url
to configure the link.
Your publishable key.
Optional connection ID to update. If not provided, a new connection will be created.
Base URL for the link. Defaults based on the publishable key (production or sandbox).
Can also provide a configured link URL directly.
Called when link is successfully completed.
Terminal provides a React hook that makes it easy to embed the link in your application.
View the package on NPM here: @terminal-api/link-react
Installation
Usage
Creating a Connection
Terminal handles capturing, validating and securely storing customer’s credentials to ensure that each TSP integration is as consistent as possible.
Here’s an overview of the steps involved when using the React hook:
Steps
- Initialize auth link with desired options (see available options below)
- Open link and wait for user to complete authentication
- Handle
onSuccess
callback and exchange public token for a connection token on your backend usingPOST /tsp/v1/public-token/exchange
Re-Authenticating a Connection
In certain scenarios, connections may become disconnected. This can occur when customers modify their password or withdraw access.
In such cases, Terminal updates the Connection status to disconnected
and prompts you to reauthenticate the customer’s TSP to continue syncing.
The reauthentication process mirrors the link flow, but requires the connectionId
parameter to specify which connection needs to be updated.
Examples
Available Options
The link SDK provides a number of options to customize the behavior of the link.
Can either provide a publishableKey
or url
to configure the link.
Your publishable key.
Optional connection ID to update. If not provided, a new connection will be created.
Base URL for the link. Defaults based on the publishable key (production or sandbox).
Can also provide a configured link URL directly.
Called when link is successfully completed.
Terminal provides a javascript SDK that makes it easy to embed the link in your application.
View the package on NPM here: @terminal-api/link-sdk
Installation
NPM
Script Tag
Usage
Creating a Connection
Terminal handles capturing, validating and securely storing customer’s credentials to ensure that each TSP integration is as consistent as possible.
Here’s an overview of the steps involved when using the JS SDK:
Steps
- Initialize auth link with desired options (see available options below)
- Open link and wait for user to complete authentication
- Handle
onSuccess
callback and exchange public token for a connection token on your backend usingPOST /tsp/v1/public-token/exchange
Re-Authenticating a Connection
In certain scenarios, connections may become disconnected. This can occur when customers modify their password or withdraw access.
In such cases, Terminal updates the Connection status to disconnected
and prompts you to reauthenticate the customer’s TSP to continue syncing.
The reauthentication process mirrors the link flow, but requires the connectionId
parameter to specify which connection needs to be updated.
Examples
Available Options
The link SDK provides a number of options to customize the behavior of the link.
Can either provide a publishableKey
or url
to configure the link.
Your publishable key.
Optional connection ID to update. If not provided, a new connection will be created.
Base URL for the link. Defaults based on the publishable key (production or sandbox).
Can also provide a configured link URL directly.
Called when link is successfully completed.
The easiest way to get started with Terminal is to redirect your users to our hosted link. This is a great option if you don’t want to embed the link in your application or if you are using a language that we don’t have an SDK for.
We will handle the entire authentication flow and redirect the user back to your application when they are done.
Usage
Creating a Connection
Terminal handles capturing, validating and securely storing customer’s credentials to ensure that each TSP integration is as consistent as possible. Here’s an overview of the steps involved in that flow.
Steps
- Create auth link with desired options (see available options below)
- Ask user to login to their TSP and direct to link
- User is redirected back to the
redirect_url
with the following paramaters:result
: Indicates the outcome of the authentication process. It will be either:success
: The user successfully authenticated.exit
: The user exited the authentication process without completing it.
token
: A public token that is provided whenresult === success
. This token is used to exchange for a connection token on your backend.state
: An opaque value that you can set in the link params for additional security:- If provided in the initial request, it will be returned unchanged.
- You should compare the returned state with the one you initially set.
- If they don’t match, it may indicate a potential security issue (e.g., a CSRF attack), and you should abort the authentication process.
- Pass public token to your backend and exchange public token for a connection token
- Wait for initial sync to complete by either:
- Polling
/connections/current
until sync iscomplete
- Subscribing to
sync.complete
webhooks (docs)
- Polling
- Ingest data from Terminal
Example Link Here’s an example of a Link URL for authenticating new connections:
Re-Authenticating a Connection
There are rare times where connections may get disconnected. Common reasons for this include when customers change their password or revoke access.
When this happens - Terminal will update the status of the Connection to disconnected
and prompt you to reauthenticate the customer’s TSP in order to resume syncing.
Reauthentication is similar to the link flow but includes the connectionId
in the URL path to denote which connection you would like to update.
Steps
- Get re-auth link for disconnected connection (see example below)
- Explain to user they need to enter their credentials again and direct them to link to perform authentication
- Resume ingesting data after catch up sync completes
Example Link Here’s an example of a Link URL for re-authenticating existing connections:
Special Note
During re-auth, you must link the same TSP account. Should your customer want to change accounts then they will need to create a new connection
Available Options
You can use the following options when directing customers to the link in order to control behaviour. Please note these settings do not apply to the re-authentication flow.
Base URL
The base URL for the link is determined by the environment you are using. You can use the following table to determine which environment you should use.
Our SDKs automatically determine the correct base URL based on the publishable key you provide.
Environment | URL |
---|---|
prod | https://link.withterminal.com/?key={PUBLISHABLE_KEY}&redirect_url={REDIRECT_URL} |
sandbox | https://link.sandbox.withterminal.com/?key={PUBLISHABLE_KEY}&redirect_url={REDIRECT_URL} |
Query Parameters
The following options can be appended as query parameters to the link URL in order to modify the settings of the resulting connection.
Your application’s publishable key
Example: pk_prod_SDFsdflokjsdfloiLKDNF
Where you want to direct users after they succesfully complete or exit the link flow. This is required for initial authentication in order to exchange the public token but is optional during re-authentication.
Example: https://app.example.com/telematics-success
Optional state parameter for maintaining application state and preventing CSRF attacks. This opaque value is returned unchanged, allowing verification of the request source. It should be unique for each flow initiation.
A friendly name to give the resulting connection - if not provided, we will attempt to pull this from the TSP
ID field to reference an identifier from your system with the resulting connection. You can learn more about External IDs here.
A list of tags that can be used to associate searchable references or categories to your connections. Tags can be passed as a string of comma-separated values. You can learn more about tags here.
A specific provider you would like the customer to authenticate with - skips the first screen
Example: geotab
Whether to automatically schedule future syncing after the initial sync
Allowed values: automatic
manual
Number of days of historical data to backfill (can not use alongside
backfill_start_from
)
ISO8601 date to start backfilling from (can not use alongside backfill_days
)