Proxy API
Send requests directly to an integration provider, on behalf of Connected Users.
Proxy API was formerly known as the Connect API.
Introduction
Once your users have connected their third-party app accounts in the Connect Portal, you can access their app account via the Proxy API.
The Proxy API allows you to directly access any of the third-party provider’s API methods. With the SDK, you can use paragon.request
to send an API request to a third-party app on behalf of one of your Connected Users.
Along with Workflows, the Proxy API is one of two primary ways to build integrations with Paragon.
When to use the Proxy API
The Proxy API is the most flexible way to interact with your users’ third-party apps, and is a useful code-based approach for situations including:
-
Performing a simple one-off request (e.g. fetching a list of Salesforce contacts)
-
Accessing API methods that may not be available in Workflow Integration Actions
-
Writing custom code for complex or unique integration use cases
-
Migrating existing integration code to Paragon
Making requests with the Proxy API
Every integration in your dashboard has a code example of using paragon.request
, which takes three arguments:
-
integrationType
: 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.- When using a custom integration, the
integrationType
name is prefixed with"custom."
For example, a custom integration titled “TaskLab” would be called"custom.tasklab"
.
- When using a custom integration, the
-
path
: 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. -
requestOptions
: Request options to include, such as:-
body
: An object representing JSON contents of the request. -
method
: An HTTP verb such as “GET” or “POST”. Defaults to GET.
-
The function returns a Promise for the request output, which will have a shape that varies depending on the integration and API endpoint.
Client-side SDK Usage
Server-side Usage
Base URL:
-
Cloud:
https://proxy.useparagon.com
-
On-premise environments:
https://worker-proxy.
[your on-prem host name]
If you’d like to issue a request from your server to an integration on behalf of an end-user, you can make a request to one of the following paths:
-
/projects/<Project ID>/sdk/proxy/<Integration Type>/<API Path>
-
or
/projects/<Project ID>/sdk/proxy/custom/<Integration ID>/<API Path>
for Custom Integrations.
-
A Bearer token must also be specified with a Paragon User Token.
-
This endpoint accepts any HTTP verb you want to use with the API.
-
Body contents must be specified as
application/json
.
Example:
Requesting files or binary response data
By default, the Proxy API will attempt to parse the response data from the integration API as JSON. To receive the raw response data (including all HTTP headers that were received from the integration API), you can pass the X-Paragon-Use-Raw-Response
header to the request.
This can be used when downloading binary/file data, such as images or PDF files, where the response cannot be encoded as JSON.
The JavaScript SDK currently does not support returning non-JSON payloads. As an alternative, you can use your preferred request client to make the below API request.
Below is an example of using the Connect API to download a file from Google Drive using their files.get
endpoint.
Changing the Base URL
In some cases, the Base URL included automatically in the Proxy API isn’t the one you want to send requests to.
To change the Base URL of a Proxy request, simply use a fully-qualified URL rather than a relative path:
In this example, the URL that will be requested is https\://sheets.googleapis.com/v4/spreadsheets
.
Note: Integrations have a permitted list of hosts that can be reached with the Proxy API. If you get the error “This domain is invalid for the current integration”, you may be using an unpermitted host.