# Custom API (/docs/agent/knowledge-and-tools/custom-api)

> Connect your agent to any external service using custom API integration.

Custom API integration connects your agent to external services through
REST APIs, allowing it to fetch data or perform actions using third-party
services.

## Key benefits [#key-benefits]

- Access external data sources in real-time
- Connect to your own backend services
- Integrate with virtually any REST API endpoint
- Extend your agent's capabilities with custom functionality

## Setup option 1: from the main dashboard [#setup-option-1-from-the-main-dashboard]

### Open the integrations page [#open-the-integrations-page]

Go to the Integrations page in your dashboard and select the **All
Integrations** tab.

![Connecting from dashboard](/docs-images/guides/custom-api-integration/dashboard-1.png)

### Connect a Custom API [#connect-a-custom-api]

Find the Custom API card and click **Connect**. Configure your API (see
configuration details below) and test it in the **Test** tab.

![Custom API config in dashboard](/docs-images/guides/custom-api-integration/dashboard-2.png)

### Attach to your agent [#attach-to-your-agent]

Go to your agent's edit page, open the **Integrations** tab, and attach
the integration from the dropdown.

## Setup option 2: from agent configuration [#setup-option-2-from-agent-configuration]

### Open the agent's integrations tab [#open-the-agents-integrations-tab]

Go to your agent's edit page and select the **Integrations** tab.

### Connect a Custom API [#connect-a-custom-api-1]

Under **Connect New Integrations**, find Custom API and click
**Connect**. Configure and test your API. The integration will
automatically attach to your agent.

## Setup option 3: from the chat interface [#setup-option-3-from-the-chat-interface]

### Ask in chat [#ask-in-chat]

Use natural language like "Connect my CRM api" or "Connect my Airtable
api". A connection widget will automatically appear.

### Add the integration [#add-the-integration]

Click **Add integration** to navigate to the integration tab. Under
**Connect New Integrations**, find Custom API Integration and click
**Connect**. Configure your integration.

## Setup option 4: with the API [#setup-option-4-with-the-api]

Create the integration once, then attach it to any agent. Your API key goes in
the `Authorization: Bearer` header. Resellers can do this for a client's agent
by adding `user_id`. See [Acting as clients](/docs/reseller/your-clients/acting-as-clients).

### Create the integration [#create-the-integration]

API reference: [Create a custom API integration](/docs/api-reference/integrations/createCustomApiIntegration)

```bash
curl -X POST "https://omnidim.io/api/v1/integrations/custom-api" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Order status",
    "description": "Look up an order'\''s delivery status by order number.",
    "url": "https://api.acme-corp.io/orders/status",
    "method": "POST",
    "headers": [{ "key": "Authorization", "value": "Bearer YOUR_TOKEN" }],
    "body_params": [
      {
        "key": "order_number",
        "description": "The order number the caller reads out",
        "type": "string",
        "required": true,
        "isLLMGenerated": true
      }
    ]
  }'
```

You get back its `integration_id`. Saved keys and tokens come back hidden as
`********`, here and every time you read the integration.

```json
{
  "success": true,
  "integration_id": 4821,
  "integration": {
    "name": "Order status",
    "url": "https://api.acme-corp.io/orders/status",
    "method": "POST",
    "headers": [{ "key": "Authorization", "value": "********" }]
  }
}
```

If the name is already used in your account, you get a `400` and nothing is
saved.

### Attach it to an agent [#attach-it-to-an-agent]

API reference: [Attach an integration to an agent](/docs/api-reference/integrations/attachAgentIntegration)

```bash
curl -X POST "https://omnidim.io/api/v1/agents/158910/integrations" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "integration_id": 4821 }'
```

From the next call, the agent can use it. An agent or integration that doesn't
exist, or isn't yours, returns `404`.

### Check or remove it [#check-or-remove-it]

- See what an agent has attached: [List an agent's integrations](/docs/api-reference/integrations/listAgentIntegrations)
- Take one off an agent: [Detach an integration](/docs/api-reference/integrations/detachAgentIntegration)
- See every integration in your account: [List integrations](/docs/api-reference/integrations/listIntegrations)

## Configuration guide: basic settings [#configuration-guide-basic-settings]

- **Integration Name**: choose a descriptive name (for example, "Weather API")
- **Description**: explain the API's purpose and usage. This is important for LLM tool calling.
- **URL**: full endpoint URL (for example, `https://api.example.com/data`)
- **Method**: select HTTP method (GET, POST, PUT, DELETE)

## Configuration guide: headers [#configuration-guide-headers]

- Authorization tokens
- `Content-Type` specifications
- API keys
- Custom headers

## Configuration guide: parameters [#configuration-guide-parameters]

Specify both query parameters (GET) and body parameters (POST or PUT).

- **Name**: parameter identifier
- **Description**: purpose of this parameter
- **Required**: toggle between optional and required
- **Data Type**: select from dropdown
- **AI Generated**: toggle whether the AI should dynamically generate values

![Adding query or body parameters](/docs-images/guides/custom-api-integration/parameters.png)

## Testing your integration [#testing-your-integration]

### Open the test tab [#open-the-test-tab]

Navigate to the **Test** tab.

### Run a test [#run-a-test]

Enter test values for all parameters and click **Test API** to verify the
connection.

![Running a test before saving integration](/docs-images/guides/custom-api-integration/test.png)

### Save the integration [#save-the-integration]

After successful testing, click **Save Integration**.

## Using with your agent [#using-with-your-agent]

- Once connected, your agent will automatically use this API when appropriate
- Usage is determined based on the API description you provide

## Passing the current call's phone numbers [#passing-the-current-calls-phone-numbers]

With **Pass call metadata** on, every request your agent makes gets these
fields, when the call has them. `POST`, `PUT`, `PATCH` and `DELETE` send them
in the JSON body. `GET` has no body, so it adds them to the URL as query
parameters, for example `?from_number=%2B919876543210&to_number=...&call_sid=...`:

| Field | Value |
| --- | --- |
| `from_number` | The number the call came from: the caller on an inbound call, your agent's number on an outbound call |
| `to_number` | The number the call went to: your agent's number on an inbound call, the person called on an outbound call |
| `call_sid` | The call's ID, to match the request to the call later |

On a web call there are no phone numbers: `from_number` is `Web Call` and
`to_number` is `Assistant`.

The switch is in the integration's **Config** tab. It is on by default for new
`POST`, `PUT`, `PATCH` and `DELETE` integrations and off for new `GET` ones.
Integrations made with the API get the same default; change it in the
dashboard. Older `GET` integrations have it off: turn it on to start sending
the fields. The **Test** tab sends sample values. A live
call sends the real ones.

If you already have a parameter named `from_number`, `to_number` or `call_sid`,
the call's real value replaces it. Turn the switch off if your endpoint rejects
fields it doesn't expect. On `GET`, the phone numbers are part of the URL, so
your server's access logs will record them.

The **AI Generated** setting is separate: it lets the agent fill a parameter
from the conversation. Naming a parameter `phone_number` does not fill it with
the call's number.

## Example: Airtable [#example-airtable]

Example of using Airtable with custom API integration.

![Custom API Airtable integration sample](/docs-images/guides/custom-api-integration/airtable-example.png)

## Example: Supabase user authentication [#example-supabase-user-authentication]

Walk through creating a complete Supabase authentication integration step
by step.

### Add integration name and description [#add-integration-name-and-description]

Make sure descriptions are clear and concise. The AI uses them to
understand the integration and decide when to call it.

![Supabase custom API integration setup](/docs-images/guides/custom-api/supabase-custom-api-1.png)

### Configure URL, method, and parameters [#configure-url-method-and-parameters]

Set the API URL and HTTP method, then add the query parameters needed
for the request. Enable **AI Generated** on the query parameters so the
agent can derive the values from the conversation.

### Test and save [#test-and-save]

Click next to move to the test step, run a sample request, and save the
integration once the response is correct.

![Supabase custom API testing](/docs-images/guides/custom-api/custom-api-test.png)

## Other example use cases [#other-example-use-cases]

- **CRM integration**: retrieve customer data from Salesforce or HubSpot
- **Inventory management**: check product availability in real time
- **User verification**: authenticate users against internal databases
- **Weather data**: fetch current weather for location-based services
- **Booking systems**: check availability and make reservations

## Pro tips [#pro-tips]

- Provide detailed descriptions for AI-generated parameters
- Use specific examples in your descriptions
- Test thoroughly before deploying to production