REST API
Overview
The REST API connector enables your Leena AI Agents to integrate with any third-party service or custom application via their REST API, facilitating flexible data exchange with systems that do not have a dedicated Leena AI connector.
The REST API connector supports standard HTTP operations (GET, POST, PUT, PATCH, DELETE, and more), configurable headers, query parameters, and multiple request body formats. This makes it the universal building block for connecting Leena AI to internal tools, homegrown applications, and any SaaS platform that exposes a REST API.
API Details
Leena AI executes HTTP requests directly against the REST API endpoints you configure. Since this connector is generic, the API documentation to refer to is that of the third-party service or custom application you are integrating with.
Setup
The REST API connector supports eight authentication methods:
| Auth Type | Description |
|---|---|
| Basic auth | Authenticates using a username and password sent as an HTTP Basic Authorization header |
| Bearer token | Authenticates using a static token sent as a Bearer Authorization header |
| OAuth 2.0 | Authenticates via the OAuth 2.0 authorization code flow; an admin authorizes once and Leena AI manages token refresh |
| OAuth 2.0 client credentials | Authenticates using the OAuth client's Client ID, Client Secret, and Scope (client credentials grant type) |
| User OAuth 2.0 | Authenticates via the OAuth 2.0 authorization code flow at the individual user level; each end user authorizes their own access, and API calls are made in that user's context |
| No auth | No authentication headers are added; suitable for open endpoints or APIs where authentication is handled via custom headers in the action |
| Leena app secret | Authenticates requests to Leena AI's own APIs using the workspace's app credentials; no additional fields are required |
| Leena bot token | Authenticates requests to Leena AI's own APIs using a bot-scoped token managed by the platform; no additional fields are required |
Prerequisites
Before setting up the REST API connector, ensure you have:
- The base endpoint(s) and API documentation of the service you want to integrate with
- Valid credentials for the chosen authentication method (username/password, API token, or OAuth client credentials)
- For OAuth-based methods, the ability to register an OAuth application with the third-party provider and to add Leena AI's Redirect URI to it
- Network access from Leena AI to the target API (allowlist Leena AI's IP addresses if the target service restricts inbound traffic)
- Access to your Leena AI workspace with connector management permissions
Get credentials
The credential procurement steps depend on the target service and the chosen authentication method:
For Basic auth: Obtain a username and password (typically a service account) from the target application.
For Bearer token: Generate an API token or personal access token from the target application's developer or security settings.
For OAuth-based methods (OAuth 2.0, OAuth 2.0 client credentials, User OAuth 2.0):
- Register an OAuth application in the target service's developer console.
- Note down the Client ID and Client Secret issued for the application.
- Note down the provider's Authorization URL and Token URL (published in the provider's OAuth/API documentation).
- Identify the Scopes required for the API operations Leena AI will perform.
- For the authorization code flows (OAuth 2.0 and User OAuth 2.0), you will add Leena AI's auto-generated Redirect URI to the OAuth application's allowed redirect URIs during connection setup.
For Leena app secret and Leena bot token: No credentials need to be procured — these are managed by the Leena AI platform.
Add connection
Here is how to add a connection on Leena AI:
-
Log in to your Leena AI workspace
-
Navigate to Settings > Integrations
-
Search for "REST API" and select it from the list to add its new connector
-
Start configuring the connector
- Auth type: Select one of the supported authentication methods; the remaining fields depend on your selection
-
Fill in the authentication fields based on the selected auth type
Basic auth:
Field Description Username Username for HTTP Basic authentication Password Password for HTTP Basic authentication Bearer token:
Field Description Token Static token sent as a Bearer Authorization header on every request OAuth 2.0:
Field Description Redirect URI Auto-generated by Leena AI; copy this URL and add it to your OAuth app configuration Authorization URL OAuth 2.0 authorization endpoint of the provider Token URL OAuth 2.0 token endpoint of the provider Client ID OAuth application client ID Client secret OAuth application client secret Scope Space or comma-separated list of scopes required for API access OAuth 2.0 client credentials:
Field Description Token URL OAuth 2.0 token endpoint of the provider Client ID OAuth application client ID Client secret OAuth application client secret Scope Space-separated list of scopes required for API access User OAuth 2.0:
Field Description Redirect URI Auto-generated by Leena AI; copy this URL and add it to your OAuth app configuration Authorization URL OAuth 2.0 authorization endpoint of the provider Token URL OAuth 2.0 token endpoint of the provider Client ID OAuth application client ID Client secret OAuth application client secret Scope Space or comma-separated list of scopes required for API access No auth, Leena app secret, Leena bot token: No additional fields are required.
-
Complete the connection setup
- For the OAuth 2.0 and User OAuth 2.0 methods, copy the auto-generated Redirect URI into your OAuth application's allowed redirect URIs, then complete the authorization flow when prompted (with User OAuth 2.0, each end user completes their own authorization when they first use a skill backed by this connection)
- Save the connector
Actions
The following action is supported for the REST API connector:
Execute REST API
Executes a REST API request via the REST API connector. The Agent can leverage the skill (workflow), which has been designed with the fully configured HTTP request, once the user raises a query that requires it. Here are some common use cases:
- Custom Integrations: Call internal or homegrown application APIs that don't have a dedicated connector
- Data Retrieval: Fetch records from any third-party REST endpoint for use in a workflow
- Data Submission: Create or update records in external systems via POST/PUT/PATCH requests
- File Exchange: Upload files using form data or binary payloads, or download content using non-JSON response types
Input Parameters
Here are the input parameters required to set up this action:
Mandatory
| Name | Description |
|---|---|
| URL | The full URL of the REST API endpoint to call |
| Method | The HTTP method for the request, options: GET (default), POST, PUT, PATCH, DELETE, HEAD, OPTIONS |
| Body | The request body format, options: NONE (default), JSON (auto-adds a Content-Type: application/json header), X-WWW-FORM-URL-ENCODED, FORM DATA, XML, TEXT, BINARY |
Optional
| Name | Description |
|---|---|
| Response type | The expected format of the response, options: json (default), text, raw, arraybuffer, blob, document, stream |
| Headers | List of HTTP header key-value pairs to send with the request |
| Params | List of query parameter key-value pairs to append to the URL |
| Include response headers in output | Whether to return the response headers along with the response body when the action executes (off by default) |
Body payload fields
Depending on the selected Body format, one of the following payload fields becomes available:
| Name | Available when Body is | Description |
|---|---|---|
| JSON payload | JSON | The JSON request body, structured per the target API's specification |
| URL encoded payload | X-WWW-FORM-URL-ENCODED | List of key-value pairs sent as a URL-encoded form body |
| Form data payload | FORM DATA | List of form fields; each field has a key, a type (Text or File), and either a text value with an optional content type, or a file provided as a URL/Base64 |
| XML payload | XML | The XML request body |
| Plain text payload | TEXT | The plain text request body |
| URL / Base64 | BINARY | The binary content to send, provided either as a URL or as a Base64-encoded string |
Response
The action returns the response from the target REST API in the selected response type. When "Include response headers in output" is enabled, the response headers are returned alongside the body, allowing downstream workflow steps to use values such as pagination links or rate-limit information.
Updated 21 days ago
