REST APIs
Call any internal or external REST API, just like in Postman
REST API Integrations can be easily created from the Integrations page and allow you to create a resource for a commonly used API. You can configure a base URL, shared headers, and the API's authentication scheme.
Setting up a REST API
1. Select REST API from the integrations page
2. Fill out the form with the following configuration:
- Display Name - Name that will be displayed to users when selecting this integration in Superblocks resources
- Base URL - Main API URL, to which endpoint paths can be appended
- Authentication - Choose from the following options detailed further here:
- Headers - HTTP headers to send with requests to this API
- Params - URL query parameters to send with requests to this API
Note, if you need to retrieve credentials on demand with a custom workflow instead of using the pre-built authentication flows, enable "Fetch credentials dynamically". This allows you to run a Superblocks Workflow (which can issue an API call or connect to a secrets manager) to fetch the token and return it for use within your REST API integration form:
Screenshot of Fetch Credentials Dynamically
3. Click "Create Integration"
info
If using Superblocks Cloud, add these Superblocks IPs to your allowlist (not necessary for On-Premise-Agent)
Example configuration below using the Zendesk API with Basic authentication:
4. Set environments
After creating the integration, you can optionally set different connection settings for your Production and Staging environments. Be sure to click Test Connection
for each environment.
success
REST API Connected You can now write REST API calls to read from and write to APIs in any Application, Workflow, or Scheduled Job.
Calling a REST API in Superblocks
In an Application, Workflow, or Scheduled Job, add a step for your REST API integration and configure the following:
Method -
GET
,POST
,PUT
,DELETE
,PATCH
URL Path
Additional Headers and Query Params, if required
Body Content Type, if required. This can reference any previous steps or UI components.
JSON: Define the JSON body to send in the HTTP request.
Form Data: Specify the key-value pairs to send to represent form fields and values.
File Form: Set the File Name of the file that will be sent along with the File Contents. For example, to refer to a file that was uploaded with a File Picker component, you can use the following syntax:
{{ await <FilePickerComponentName>.files[0].readContentsAsync() }}
. (Note: the File Form Key is the key that the file would be set under. It defaults tofile
and can be updated to fit the requirements of your API.)
Click "Run" to execute your API and see the resulting output.
info
Note, it is also possible to call APIs from Python steps using requests
or JavaScript steps with axios
. Use these methods for more advanced conditional logic around API execution.
Troubleshooting
Use the Executed Request panel in a REST API step to see the equivalent request in curl
command format. Copy and paste this command into your terminal to compare the output. For example, if the command succeeds in your terminal but not in Superblocks, one potential area to investigate is how the API interacts with different User-Agent
header values.