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 TypeDescription
Basic authAuthenticates using a username and password sent as an HTTP Basic Authorization header
Bearer tokenAuthenticates using a static token sent as a Bearer Authorization header
OAuth 2.0Authenticates via the OAuth 2.0 authorization code flow; an admin authorizes once and Leena AI manages token refresh
OAuth 2.0 client credentialsAuthenticates using the OAuth client's Client ID, Client Secret, and Scope (client credentials grant type)
User OAuth 2.0Authenticates 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 authNo authentication headers are added; suitable for open endpoints or APIs where authentication is handled via custom headers in the action
Leena app secretAuthenticates requests to Leena AI's own APIs using the workspace's app credentials; no additional fields are required
Leena bot tokenAuthenticates 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):

  1. Register an OAuth application in the target service's developer console.
  2. Note down the Client ID and Client Secret issued for the application.
  3. Note down the provider's Authorization URL and Token URL (published in the provider's OAuth/API documentation).
  4. Identify the Scopes required for the API operations Leena AI will perform.
  5. 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:

  1. Log in to your Leena AI workspace

  2. Navigate to Settings > Integrations

  3. Search for "REST API" and select it from the list to add its new connector

  4. Start configuring the connector

    1. Auth type: Select one of the supported authentication methods; the remaining fields depend on your selection
  5. Fill in the authentication fields based on the selected auth type

    Basic auth:

    FieldDescription
    UsernameUsername for HTTP Basic authentication
    PasswordPassword for HTTP Basic authentication

    Bearer token:

    FieldDescription
    TokenStatic token sent as a Bearer Authorization header on every request

    OAuth 2.0:

    FieldDescription
    Redirect URIAuto-generated by Leena AI; copy this URL and add it to your OAuth app configuration
    Authorization URLOAuth 2.0 authorization endpoint of the provider
    Token URLOAuth 2.0 token endpoint of the provider
    Client IDOAuth application client ID
    Client secretOAuth application client secret
    ScopeSpace or comma-separated list of scopes required for API access

    OAuth 2.0 client credentials:

    FieldDescription
    Token URLOAuth 2.0 token endpoint of the provider
    Client IDOAuth application client ID
    Client secretOAuth application client secret
    ScopeSpace-separated list of scopes required for API access

    User OAuth 2.0:

    FieldDescription
    Redirect URIAuto-generated by Leena AI; copy this URL and add it to your OAuth app configuration
    Authorization URLOAuth 2.0 authorization endpoint of the provider
    Token URLOAuth 2.0 token endpoint of the provider
    Client IDOAuth application client ID
    Client secretOAuth application client secret
    ScopeSpace or comma-separated list of scopes required for API access

    No auth, Leena app secret, Leena bot token: No additional fields are required.

  6. Complete the connection setup

    1. 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)
    2. 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

NameDescription
URLThe full URL of the REST API endpoint to call
MethodThe HTTP method for the request, options: GET (default), POST, PUT, PATCH, DELETE, HEAD, OPTIONS
BodyThe 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

NameDescription
Response typeThe expected format of the response, options: json (default), text, raw, arraybuffer, blob, document, stream
HeadersList of HTTP header key-value pairs to send with the request
ParamsList of query parameter key-value pairs to append to the URL
Include response headers in outputWhether 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:

NameAvailable when Body isDescription
JSON payloadJSONThe JSON request body, structured per the target API's specification
URL encoded payloadX-WWW-FORM-URL-ENCODEDList of key-value pairs sent as a URL-encoded form body
Form data payloadFORM DATAList 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 payloadXMLThe XML request body
Plain text payloadTEXTThe plain text request body
URL / Base64BINARYThe 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.


Did this page help you?