paragon export from @useparagon/connect, and the public endpoints of the Paragon REST API.
Install Paragon’s JavaScript SDK with:
- SDK
JavaScript
For on-premise users
For on-premise users
If you are using an on-premise instance of Paragon, you can call the
paragon.configureGlobal function to point the SDK to use the base hostname of your Paragon instance.- SDK
JavaScript
SDK Methods
.authenticate
paragon.authenticate should be called at the beginning of your application’s lifecycle in all cases. This is to make sure that the userToken is always as fresh as possible, with respect to your user’s existing session on your own site.
- SDK
JavaScript
You can find your project ID in the Overview tab of any Integration
paragon.authenticate has been called, you can access the user’s integration state with paragon.getUser. paragon.authenticate only needs to be called when using the Paragon SDK - when making requests to the Paragon REST API, you should instead provide the Paragon User Token in the Authorization header.
.connect
Callparagon.connect to launch your Connect Portal for a specific integration provider. You can find the integrationType identifier you need in the Overview page for the integration.
- SDK
JavaScript
Type of integration (i.e. “salesforce”, “hubspot”, “googledrive”)
await the Promise returned by paragon.authenticate to show a loading state before users are able to access the Connect Portal.
You must have an integration configured of this integrationType in your Paragon project for the Connect Portal to appear. Otherwise, this function does nothing.
If your integration uses a Field Mapping User Setting, pass the mapping configuration through installOptions. For examples, see Passing dynamic fields through the SDK.
You can also connect multiple accounts for the same integration.
Multi Account Authorization
.subscribe
Callparagon.subscribe to subscribe to different events and changes from the Paragon SDK. You can find the possible eventNames below:
Subscribing to SDK Events applies to all integrations globally. Specifying callbacks to
paragon.connect only applies to a currently open Connect Portal locally.
- SDK
JavaScript
Event type (i.e. “onIntegrationInstall”, “onPortalOpen”) as seen in the table above
callback function that triggers on event
onOpen, onClose, onUninstall , and onWorkflowChange as a one-time event locally.
.installIntegration
This function should be used only if you are using your own components to show connected integrations and their status, instead of the Connect Portal.Otherwise, you can use the
paragon.connect function.paragon.installIntegration can be used to start the connection process for an integration without the Connect Portal appearing over your user interface. You can find the integrationType identifier you need in the Overview page for the integration.
This function resolves with the IntegrationInstallEvent in the same format available in paragon.subscribe. You can use this to get the newly created credential by awaiting the returned Promise.
This function rejects the returned Promise if the integration is already installed for the authenticated user.
- SDK
JavaScript
Type of integration (i.e. “salesforce”, “hubspot”, “googledrive”)
integrationType requires API keys or post-authentication options, the Connect Portal will still appear to capture those values from your user at that time. The Connect Portal will automatically be dismissed after those values are entered.
This function accepts the same optional install options as paragon.connect.
.uninstallIntegration
Callparagon.uninstallIntegration to disconnect an integration for the authenticated user.
When an integration is disconnected, workflows for that integration will stop running for the authenticated user and any saved User Settings will be cleared.
- SDK
- REST API
JavaScript SDK
The short name for the integration (i.e. “salesforce”, “hubspot”). Use the same name as used in
paragon.connect..getIntegrationMetadata
Callparagon.getIntegrationMetadata to get the name, brandColor, and icon, for any of your active integration providers. This is a great way to create your integrations page!
- SDK
- REST API
JavaScript
JavaScript
.getIntegrationConfig
Callparagon.getIntegrationConfig to get the user-facing descriptions, User Settings, and Workflows associated with any integration.
- SDK
- REST API
JavaScript
An integration type string, like
salesforce or slack.JavaScript
.getUser
Callparagon.getUser to retrieve the currently authenticated user and their connected integration state.
- SDK
- REST API
JavaScript
JavaScript
{ authenticated: false } instead. Please check the authenticated property before using the user.integrations field.
.setUserMetadata
Callparagon.setUserMetadata to associate the authenticated user with metadata from your application. This metadata can be accessed with paragon.getUser or retrieved over the API.
- SDK
- REST API
JavaScript SDK
Metadata object to associate with the authenticated user.
.updateIntegrationUserSettings
Callparagon.updateIntegrationUserSettings to update any integration-level User Settings for your Connected User.
- SDK
JavaScript
An integration type string, like
salesforce.A partial update object where the keys are the
id properties of User Settings objects (which you can get from paragon.getIntegrationConfig) and the values are the user’s selection for the matching input type.Any keys that are not included in the object will not be updated.The type for each value will depend on the input type. See Input Types Reference to see the value type for each input.Example
Optionally specify a Credential and Configuration to target, if using Multi-Account Authorization or Multi-Configuration.
Show child properties
Show child properties
The Credential ID (a UUID) of the connected account you want to update, if using Multi-Account Authorization.
The Configuration ID (a UUID or an External ID prefixed with
ext:), if using Multi-Configuration..getDataSourceOptions
Callparagon.getDataSourceOptions to get configuration details for compound data sources used for dynamic User Settings types in the Headless Connect Portal.
Compound data sources, for Field Mapping and Combo Dropdown inputs, have multiple data sources within them (Field Mappings have both Object Types and Field Names as sources).
To load options for a data source, see paragon.getFieldOptions.
SDK 2.3.0+: Consider using
paragon.getSourcesForInput instead, which provides a simpler way to get all data sources needed for any input type in a single call.- SDK
JavaScript
An integration type string, like
salesforce.A source type string, which can be found in the
sourceType property of a
User Setting object from paragon.getIntegrationConfig or
from stage.options of PostOptionsStage..getFieldOptions
Load options from an integration data source for dynamic User Settings types in the Headless Connect Portal, using the Connected User’s account.paragon.getFieldOptions can only be called for data sources with type DYNAMIC_DATA_SOURCE (for dynamic enum input types).
-
Compound data sources like
FIELD_MAPPER_DATA_SOURCEorCOMBO_INPUT_DATA_SOURCEare composed ofDYNAMIC_DATA_SOURCE-type sources. -
When rendering Field Mapping or Combo Dropdown inputs, first identify each data source with
paragon.getSourcesForInput(orparagon.getDataSourceOptions), and use the returned data source configuration to callparagon.getFieldOptions. See a full example.
fieldOptions below to learn more.
- SDK
- REST API
This section is an empty array for all input types except for Default value mapping, which is only supported by Jira: Issue Field Values.
The cursor value to pass as
cursor for the next page of results..getSourcesForInput
Callparagon.getSourcesForInput to get all the data sources needed to render a dynamic input (e.g. a picklist loaded from integration data from the user’s connected account).
The returned data sources can be passed directly to paragon.getFieldOptions using the source parameter to load options for your input, with pagination and search.
- SDK
JavaScript
An integration type string, like
salesforce.The input object from
availableUserSettings, availableWorkflows[n].inputs, or stage.options of an install flow stage.null for inputs that don’t require a data source (e.g. text inputs). Otherwise, returns one of the following based on the Input Type of the input:
- SingleSource
- FieldMapperSources
- ComboSources
- DefaultFieldValueSources
Returned for Example:
DynamicEnum and CustomDropdown input types."single" for SingleSource.The data source for the input. Pass this to
paragon.getFieldOptions using the source parameter to load options.DynamicEnum input
.setDataSources
Callparagon.setDataSources to register custom data sources for dropdown and field mapping inputs when using the Headless Connect Portal. This can be used in place of passing dropdowns and mapObjectFields inline with paragon.connect, for Headless Connect Portal implementations.
Data sources can be registered globally (applied to all integrations) or for specific integrations. When an integration-specific source exists, it takes priority over a global source with the same key.
This function should be called once after paragon.setHeadless and before rendering any inputs.
- SDK
JavaScript
.enableWorkflow
Callparagon.enableWorkflow to turn on a workflow for a user by ID.
- SDK
- REST API
.disableWorkflow
Callparagon.disableWorkflow to turn off a workflow for a user by ID.
- SDK
- REST API
.updateWorkflowState
Callparagon.updateWorkflowState to enable or disable workflows for a user.
- SDK
JavaScript
A partial update object where keys are workflow IDs and values are
true or false. Any workflow IDs not included in this object will not be updated in this call.on Example
Optionally specify a Credential and Configuration to target, if using Multi-Account Authorization or Multi-Configuration.
Show child properties
Show child properties
The Credential ID (a UUID) of the connected account you want to update, if using Multi-Account Authorization.
The Configuration ID (a UUID or an External ID prefixed with
ext:), if using Multi-Configuration..updateWorkflowUserSettings
Callparagon.updateWorkflowUserSettings to update any workflow-level User Settings for your Connected User.
- SDK
JavaScript
An integration type string, like
salesforce.The ID of the Workflow that the workflow-level User Setting you are modifying belongs to. If you are trying to modify an integration-level User Setting, call
paragon.updateIntegrationUserSettings instead.A partial update object where the keys are the
id properties of User Settings objects (which you can get from paragon.getIntegrationConfig) and the values are the user’s selection for the matching input type.Any keys that are not included in the object will not be updated.The type for each value will depend on the input type. See Input Types Reference to see the value type for each input.Example
Optionally specify a Credential and Configuration to target, if using Multi-Account Authorization or Multi-Configuration.
Show child properties
Show child properties
The Credential ID (a UUID) of the connected account you want to update, if using Multi-Account Authorization.
The Configuration ID (a UUID or an External ID prefixed with
ext:), if using Multi-Configuration..getCustomWebhookUserManualUrl
If you are using Custom Webhooks with a User-Level URL and Manual Setup, you can useparagon.getCustomWebhookUserManualUrl to construct the user-specific URL that must be registered by your customer in the integration to complete webhook setup.
There is no API endpoint available for this method. However, you can construct the user-specific URL without the JavaScript SDK as described in the Custom Webhooks docs.
- SDK
JavaScript
The ID of a Workflow that utilizes this Custom Webhook. If the same Custom Webhook is used in multiple Workflows, any one of these workflows can be used as
workflowId.If you are using Multi-Account Authorization and there may be more than one account connected for a given integration, pass the
credentialId to ensure that received events are routed to the correct account..workflow
Callparagon.workflow to trigger a Paragon workflow that sends a custom response back to your app. Note: The workflow must be enabled and use a Request-type trigger.
- SDK
- REST API
.request
Callparagon.request to send an API request to a third-party integration on behalf of one of your users.
Every integration in your dashboard has a code example of using paragon.request.
- SDK
JavaScript
The short name for the integration (i.e. “salesforce” or “googleCalendar”). You can find this string on the Overview tab of the integration you want to access, on your Paragon dashboard.
The path (without the hostname) of the API request you are trying to access. An example might be: “/v1/charges” for Stripe’s charge API or “chat.postMessage” for Slack’s Web API.
Optional request options to include:If
requestOptions is omitted, the SDK issues a GET request without a body..event
App Events can be sent from your application using the Paragon SDK or REST API. In both cases, you must pass two parameters:- name - the event name defined in your App Event
- payload - the event payload that should match the event schema defined in your App Event
- SDK
- REST API
.setHeadless
Callparagon.setHeadless to enable or disable Headless mode for the SDK. When headless mode is enabled, the SDK will not render the Connect Portal UI and will instead expose functions for you to build your own UI.
JavaScript
API Only
GET project’s integrations
Returns a list of the integrations enabled for the Paragon project by the ID in the URL.
- Includes the Connect Portal configuration for each integration (as
.configs) and the Workflows associated with each integration (as.workflows)
paragon.getIntegrationMetadata and paragon.getIntegrationConfig when using the JavaScript SDK.
HTTP
You can find your project ID in the Overview tab of any Integration
GET user’s Connect credentials
Returns a list of the user’s Connect credentials (i.e., the accounts connected and authorized by the end user).
- The providerId is the authenticated user’s ID assigned by their integration provider (e.g. for a Salesforce integration, this would be the user’s Salesforce user ID)
HTTP
You can find your project ID in the Overview tab of any Integration
UPDATE user’s Connect credential
Updates the user’s connected integration account, including any settings and configured workflows.
This endpoint updates by replacement with respect to the config property, so this endpoint should only be used after retrieving the existing value (which can be done by using the above endpoint: Get user’s Connect credentials).
Alternatively, you can use the SDK to update User Settings or workflow enablements:
paragon.updateIntegrationUserSettings: Update integration-level User Settings.paragon.updateWorkflowUserSettings: Update workflow-level User Settings.paragon.updateWorkflowState: Update workflow enablements.
HTTP
You can find your project ID in the Overview tab of any Integration
The ID of the Connect credential to update. Retrieve it from the
/sdk/credentials endpoint.The configuration object to update. This will replace the existing
config property entirely, so you must provide the full existing value with your intended changes applied.config must be provided in full, with the intended changes applied. This is because config will be updated by replacement.
Headless Connect installFlow
Useparagon.installFlow when implementing the Headless Connect Portal to guide your user through the installation process for an integration.
InstallFlowStage:
These are the possible install flow stages received in the onNext callback of InstallFlow that should be rendered by your app to guide the user through the installation process.
- AccountTypeStage
- PreOptionsStage
- PostOptionsStage
- InstructionStage
In the
AccountTypeStage, the user should be prompted with a list of account types that they can choose from.If you want to skip this stage, pass the first account type option (or "default") to paragon.installFlow.setAccountType to move to the next stage.Example (Salesforce)
"accountType" for AccountTypeStage.The list of account types that the user can choose from.
.installFlow.start
Callparagon.installFlow.start to begin an install flow for an integration. See an example call.
- SDK
JavaScript
The integration type string, like
salesforce..installFlow.setAccountType
Callparagon.installFlow.setAccountType when the user selects an account type in the AccountTypeStage.
- SDK
JavaScript
The account type to set. This should be the
id property of the Account Type option that the user selected..installFlow.setPreOptions
Callparagon.installFlow.setPreOptions when the user finishes providing inputs in the PreOptionsStage.
- SDK
JavaScript
onNext. If there is no stage after the PreOptionsStage, the install flow will call onComplete.
Arguments:
The values to set for the inputs in the
PreOptionsStage.This should be an object, where the keys are ids of the inputs in the PreOptionsStage, and the values are the values that the user provided for each input.Example (Shopify)
.installFlow.setPostOptions
Callparagon.installFlow.setPostOptions when the user finishes providing inputs in the PostOptionsStage.
- SDK
JavaScript
onComplete.
Arguments:
The values to set for the inputs in the
PostOptionsStage.This should be an object, where the keys are ids of the inputs in the PostOptionsStage, and the values are the values that the user provided for each input.Example (Jira)
.installFlow.cancel
Callparagon.installFlow.cancel if your user abandons the integration connection process during an active install flow. This function resets the state for paragon.installFlow to begin again at another time.
- SDK
JavaScript
If your user has completed an OAuth connection but has not completed required post-OAuth options, this function will remove the credential with status
"PENDING" automatically by calling paragon.uninstallIntegration.However, if the page has been refreshed or the SDK has been reloaded since the pending credential was connected, you will need to call paragon.uninstallIntegration manually to disconnect the pending credential from your user.External File Picker
You can use the Paragon SDK to allow your user to select files from a File Storage integration in your app. The SDK provides anExternalFilePicker class to load any necessary JavaScript dependencies into your page and authenticate with your user’s connected account.
Supported integrations for ExternalFilePicker:
.ExternalFilePicker
Construct a new instance of an ExternalFilePicker for an integration given byintegrationType. Any required JS dependencies do not start loading until picker.init is called.
- SDK
JavaScript
Type of integration (i.e. “googledrive”, “onedrive”, “sharepoint”, “box”)
JavaScript
picker.init
Initialize a file picker with required configurationinitConfig. Required configuration varies per integration; see integration-specific documentation for specific details.
This function loads required JS dependencies into the page, if they have not already been loaded. Other methods, like picker.open and picker.getInstance, cannot be called until the Promise returned by picker.init is resolved.
- SDK
JavaScript
JavaScript
picker.open
Presents the file picker in your app. Selected files or other events will be received in the callbacks you specified in the constructor.- SDK
JavaScript
picker.getInstance
Returns a reference to the third-party JS library object that this file picker is using. This object can be used for additional integration-specific customization.- SDK
JavaScript