Skip to main content
1

[Server side] Set up scoped auth token generation

In your backend, build an API endpoint that makes a POST to https://api.prequel.co/actions/generate-scoped-auth-token to request to generate a scoped auth token from the Prequel API. Be sure to pass your API Key as a header (X-API-KEY) in the request as well as the desired API version (X-Prequel-Api-Version). Your API endpoint should return the scoped token that was returned from the Prequel API.Note: If you are using a self-hosted deployment or a non-US deployment, replace api.prequel.co with the appropriate host.

POST request body

This request body is for the API Version 2023-12-01. Your POST request body should have the following structure:
Example request body
Example request body

Getting the recipient ID

The recipient_id is Prequel’s unique identifier for the recipient to which the destination is being added. In your system, there is a separate identifier for that customer. You can either you can look them up using the Prequel API or track Prequel’s recipient UUIDs in your system.

POST response body

The POST response body will have the following structure:
Example response body
Example response body
Note: scoped auth tokens have a TTL of one hour.
2

[Client side] Set up fetchToken calls

In your frontend, define a set of fetchToken functions. These functions will consume various inputs (see examples below) and query the API endpoint you built in Step 1 to generate auth tokens required by the Prequel API. These fetchToken functions will be used as parameters to and called by Prequel’s React hooks.There are two fetchToken types you will need to implement, depending on the hooks you use:
fetchToken types

Example: FetchAuthToken

Required by: useModels, useProducts hooksThis function contains an empty request body (as should your subsequent request to the Prequel API) because there is no relevant customer-specific scoping required for the fetching of your organization’s models and products.
fetchToken

Example: FetchAuthTokenWithDestination

Required by: useCreateDestination, useTestConnection hooksThis function passes a destination object as the request body (in addition to - not in place of - to subsequent requests to the Prequel API) so that the generated token can be appropriately scoped to a specific destination.
fetchTokenWithDestination
3

[Client side] Install Prequel React hooks

Install the @prequel/react package from npm.
Install @prequel/react
4

[Client side] Render the form

In your frontend, define a DestinationForm component. The component will leverage the useDestination hook and the useDestinationForm hook to render a dynamic form that can be used to test & add a new destination. A brief example is show below. See our sample React app for a more comprehensive implementation.
DestinationForm
5

[Client side] Test and create destinations

Once your form is rendering as desired, you should augment form functionality to test a destination connection before creating that destination. It’s recommended that you only allow users to create destinations that are connecting successfully. You can leverage the useTestConnection hook as demonstrated below. See our sample React app for a more comprehensive implementation.
TestConnectionComponent