Use this file to discover all available pages before exploring further.
Below are all the public functions exposed on the Paragon SDK, which can be accessed as the named paragon export from @useparagon/connect, and the public endpoints of the Paragon REST API.Install Paragon’s JavaScript SDK with:
npm install @useparagon/connect
The SDK can be imported in your client-side JavaScript files as a module:
SDK
JavaScript
import { paragon } from '@useparagon/connect';
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
import { paragon } from "@useparagon/connect";// If your login URL is https://dashboard.mycompany.paragon.so:paragon.configureGlobal({ host: "mycompany.paragon.so",});
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.
Once 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.
Call paragon.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.
For integrations that support multiple account types, you can optionally designate a specific accountType to skip the account selection dialog.Example values: default, sandbox
Example of using accountType
paragon.connect("salesforce", { // Only allow production-type Salesforce accounts to connect accountType: "default",});
For Field Mapping inputs that use Dynamic Application Fields. Keys must match the Application Object Name from the dashboard; values describe application fields and/or loaders for integration object types and fields. See Passing dynamic fields through the SDK.
Pass this option to associate a new credential with an identifier from your own system. The externalId will be available on the credential object returned by paragon.getUser.This option cannot be used with selectedCredentialId, which is used to replace or manage existing connected accounts. Existing credentials currently cannot be updated with an external ID.
Used for Multi-Account Authorization. Pass this option to open the Connect Portal for an existing credential ID and update/manage settings (headful) or to start an install flow to replace an existing credential ID with a new account (with the Headless Connect Portal).
Used for Multi-Configuration. Pass this option to open the Connect Portal for a specific configuration (unique set of User Settings and Workflow Enablements for a connected credential).
This function must be called after the Paragon SDK has completed authentication. You can 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.
Call paragon.subscribe to subscribe to different events and changes from the Paragon SDK. You can find the possible eventNames below:
Event Type
Usage in paragon.subscribe
Usage in paragon.connect
Integration enabled
"onIntegrationInstall"
"onInstall"
Integration disabled
"onIntegrationUninstall"
"onUninstall"
Workflow state change
"onWorkflowChange"
"onWorkflowChange"
Connect Portal opened
"onPortalOpen"
"onOpen"
Connect Portal closed
"onPortalClose"
"onClose"
Subscribing to SDK Events applies to all integrations globally. Specifying callbacks to paragon.connect only applies to a currently open Connect Portal locally.
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.
The 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.
For integrations that support multiple account types, you can optionally designate a specific accountType to skip the account selection dialog.Example values: default, sandbox
Example of using accountType
paragon.connect("salesforce", { // Only allow production-type Salesforce accounts to connect accountType: "default",});
For Field Mapping inputs that use Dynamic Application Fields. Keys must match the Application Object Name from the dashboard; values describe application fields and/or loaders for integration object types and fields. See Passing dynamic fields through the SDK.
Pass this option to associate a new credential with an identifier from your own system. The externalId will be available on the credential object returned by paragon.getUser.This option cannot be used with selectedCredentialId, which is used to replace or manage existing connected accounts. Existing credentials currently cannot be updated with an external ID.
Used for Multi-Account Authorization. Pass this option to open the Connect Portal for an existing credential ID and update/manage settings (headful) or to start an install flow to replace an existing credential ID with a new account (with the Headless Connect Portal).
Used for Multi-Configuration. Pass this option to open the Connect Portal for a specific configuration (unique set of User Settings and Workflow Enablements for a connected credential).
Note: If the integration specified by 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.
Call paragon.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.
Call paragon.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
paragon.getIntegrationMetadata();
HTTP
GET https://api.useparagon.com/projects/PROJECT_ID/sdk/metadataAuthorization: Bearer PARAGON_USER_TOKEN
An integration type string, like salesforce or slack.
Example Response:
JavaScript
{ "shortDescription": "Send notifications to Slack", "longDescription": "Connect your Slack workspace to receive notifications and alerts in Slack. Stay connected to important activity by bringing it all together in your Slack workspace.\n\nOur Slack integration enables you to:\n\n• Receive alerts and notifications in your Slack workspace\n• Notify or DM specific team members based on certain activity", "availableUserSettings": [ { "id": "2d5662c9-6750-46c2-8588-2ac904532efb", "type": "DYNAMIC_ENUM", "title": "Channel", "required": false, "sourceType": "channels" } ], "availableWorkflows": [ { "id": "2248335c-671c-47e4-b9a0-3641a9f2d301", "inputs": [], "infoText": "Send a Slack notification when a Task is created", "defaultEnabled": false, "description": "Send Slack Notification" } ], "hiddenWorkflows": []}
HTTP
GET https://api.useparagon.com/projects/PROJECT_ID/sdk/integrations/INTEGRATION_TYPEAuthorization: Bearer PARAGON_USER_TOKEN
If the user is not authenticated, you’ll receive back only { authenticated: false } instead. Please check the authenticated property before using the user.integrations field.
Call paragon.setUserMetadata to associate the authenticated user with metadata from your application. This metadata can be accessed with paragon.getUser or retrieved over the API.
A partial update object where the keys are the id properties of User Settings objects (which you can get from 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.
Call paragon.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.
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.
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_SOURCE or COMBO_INPUT_DATA_SOURCE are composed of DYNAMIC_DATA_SOURCE-type sources.
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.Either action or source must be provided.
A DynamicDataSource object, as returned by paragon.getSourcesForInput. When provided, the cacheKey of the source is used to identify the data source to load options from.Either action or source must be provided.
A page cursor to use to load subsequent pages of results. The response of paragon.getFieldOptions will provide nextPageCursor to use or null if there are no more results.
When loading options for a compound data source (e.g. fieldSource of a Field Mapping input or dependentInputSource of a Combo Dropdown input), pass parameters with the user’s selection from the first input (e.g. the Record Type for Field Mapping).
The cacheKey property of the primary/first input in the compound data sources (e.g. recordSource of a Field Mapping input or mainInputSource of a Combo Dropdown input).
If you are using Multi-Account Authorization and there may be more than one account connected for a given integration, pass selectedCredentialId to load options for the current account.
HTTP
POST https://api.useparagon.com/projects/PROJECT_ID/sdk/actionsAuthorization: Bearer PARAGON_USER_TOKENContent-Type: application/json{ ...fieldOptions}
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.Either action or source must be provided.
A DynamicDataSource object, as returned by paragon.getSourcesForInput. When provided, the cacheKey of the source is used to identify the data source to load options from.Either action or source must be provided.
A page cursor to use to load subsequent pages of results. The response of paragon.getFieldOptions will provide nextPageCursor to use or null if there are no more results.
When loading options for a compound data source (e.g. fieldSource of a Field Mapping input or dependentInputSource of a Combo Dropdown input), pass parameters with the user’s selection from the first input (e.g. the Record Type for Field Mapping).
The cacheKey property of the primary/first input in the compound data sources (e.g. recordSource of a Field Mapping input or mainInputSource of a Combo Dropdown input).
If you are using Multi-Account Authorization and there may be more than one account connected for a given integration, pass selectedCredentialId to load options for the current account.
The unique value of this option to save with paragon.setPreOptions,
paragon.setPostOptions, paragon.updateIntegrationUserSettings, or
paragon.updateWorkflowUserSettings. This value can also be passed as
parameters[].source.value for dependent inputs of compound data
sources.
Call paragon.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.
The input object from availableUserSettings, availableWorkflows[n].inputs, or stage.options of an install flow stage.
Returns:Returns 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:
Call paragon.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.
Global custom dropdown data sources, keyed by the dropdown key identifier. Values can be either a static array of CustomDropdownField[] options (objects with label and value strings), or a CustomDropdownOptions object for dynamic loading:
If true, the dropdown options will be reloaded every time the dropdown is opened. Useful for dependent dropdowns where options depend on other input values. Defaults to false.
Integration-specific data sources that take priority over global sources. Keyed by integration type (e.g. "salesforce"), with the same dropdowns and mapObjectFields structure.
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.
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 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.
If you are using Custom Webhooks with a User-Level URL and Manual Setup, you can use paragon.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
// Present this value to your user to register this webhook in their account manuallyconst webhookUrl = paragon.getCustomWebhookUserManualUrl(workflowId, credentialId);
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.
Call paragon.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.
Call paragon.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.
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.
Call paragon.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
paragon.setHeadless(true);
This should be called once after SDK initialization. See the Headless Connect Portal guide for more details.
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)
This method is currently available via REST API only.
HTTP
GET https://api.useparagon.com/projects/PROJECT_ID/sdk/credentialsAuthorization: Bearer PARAGON_USER_TOKENContent-Type: application/json// Example response (may include more than is in this list):[{ "id": "00da4146-7ac4-4253-a8f7-96849b8137d9", "dateCreated": "2021-03-24T12:19:21.511Z", "dateUpdated": "2021-03-24T12:19:28.512Z", "dateDeleted": null, "projectId": "db06d291-ba2c-41c5-9a12-9362abfd6228", "integrationId": "95bedc9f-6a22-4855-b08d-e68dc073ad91", "personaId": "0563109f-5e71-46c5-8483-1ac8c0913d6c", "config": { "configuredWorkflows": { "3eb95154-3c7b-413c-bf14-ba367d95b53f": { "enabled": true, "settings": { "example-input-id": "example value" } } } }, "isPreviewCredential": false, "providerId": "50150244515"}]
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:
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.
Note: In the above example, the existing value for config must be provided in full, with the intended changes applied. This is because config will be updated by replacement.
Use 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.
The human-readable description of the account type.
In the PreOptionsStage, the user should be prompted with inputs to collect the necessary details for API key authorization or for the next OAuth stage in the flow.
Example (Shopify)
{ "stage": "preOptions", "options": [ { "id": "SHOP_NAME", "title": "Enter your Shopify username", "subtitle": "Enter your Shopify username, e.g. https://<username>.myshopify.com.", "placeholder": "username", "type": "TEXT_NO_VARS" } ]}
The list of inputs to prompt the user with in this stage. You can see a full list of input types that are used by the Connect Portal and must be rendered by your implementation in Input Types Reference.
The placeholder or example value to display to the user.
In the PostOptionsStage, the user should be prompted with inputs to finalize their account setup after the OAuth flow.
Example (Jira)
{ "stage": "postOptions", "options": [ { "id": "JIRA_CLOUD_ID", "type": "DYNAMIC_ENUM", "title": "Choose a Jira site to connect.", "subtitle": "The Jira site, where all operations will be performed.", "sourceType": "getAvailableSites", "required": true } ], "done": false}
The list of inputs to prompt the user with in this stage. You can see a full list of input types that are used by the Connect Portal and must be rendered by your implementation in Input Types Reference.
The source type of this input, defined for dynamic enum inputs. This value can be passed to paragon.getFieldOptions to load the options for the input.See a walkthrough of implementing dynamic input types in Exposing User Settings.
The callback function provided by the SDK to execute when the finish button is clicked. When this button is clicked, call finish.onClick() to mark the instruction stage as complete.
This callback is called when the install flow is ready to move to the next stage.Your app must render the appropriate UI for each stage, so that your user can provide the necessary details in that stage to connect their account.
The error object. You can read the .name of the error object to identify one of the following error types:
OAuthBlockedError: The browser blocked the OAuth prompt from appearing. This may require the user to allow popups in their browser settings.
OAuthTimeoutError: The OAuth prompt took longer than oauthTimeout milliseconds (as provided in options) to complete.
UserNotAuthenticatedError: The user is not authenticated with the Paragon SDK. Verify that paragon.authenticate has been called before starting the install flow.
NoActiveInstallFlowError: An install flow function was called, but no install flow is currently active. Call paragon.installFlow.start to start an install flow.
HeadlessModeNotEnabledError: Headless Connect Portal is not enabled. Call paragon.setHeadless to enable Headless mode.
IntegrationNotFoundError: The provided integration type is not found or has not been enabled in your Paragon project.
The number of milliseconds to wait for an OAuth prompt to complete. If the user does not complete the OAuth prompt within this time, the install flow will fail, and the onError callback will be called.If not provided, there will be no timeout for the OAuth prompt.
Set this parameter to replace an account by a selected Credential ID instead of connecting a new account.This can be used to prompt a user to reconnect a credential if authorization has been revoked and the status of the credential is INVALID.
Call paragon.installFlow.setPreOptions when the user finishes providing inputs in the PreOptionsStage.
SDK
JavaScript
await paragon.installFlow.setPreOptions(values);
This returns a Promise that resolves when the values are saved. Upon success, the install flow will move to the next stage and call 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.
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.
Call paragon.installFlow.cancel if your user abandons the integration connection process during an active install flow. This function resets the state for installFlow to begin again at another time.
SDK
JavaScript
paragon.installFlow.cancel();
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.
You can use the Paragon SDK to allow your user to select files from a File Storage integration in your app.The SDK provides an ExternalFilePicker class to load any necessary JavaScript dependencies into your page and authenticate with your user’s connected account.Supported integrations for ExternalFilePicker:
Construct a new instance of an ExternalFilePicker for an integration given by integrationType. Any required JS dependencies do not start loading until picker.init is called.
SDK
JavaScript
const picker = new paragon.ExternalFilePicker(integrationType, options);
Initialize a file picker with required configuration initConfig. 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.
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.