> ## Documentation Index
> Fetch the complete documentation index at: https://docs.onyx.app/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenAPI

> Turn a REST API with an OpenAPI schema into tools for Chat and custom agents

> [!NOTE]
>
> In Onyx 5.0, OpenAPI actions moved from their own admin page to **Admin Panel → Plugins**.
> See [Where things moved](/admins/plugins/overview#where-things-moved-in-onyx-5).

An OpenAPI plugin connects Onyx to a REST API. You give Onyx an [OpenAPI](https://swagger.io/specification/) schema,
and Onyx turns each operation in the schema into a tool.
Agents read the operation descriptions and parameters to decide when and how to call the API.

OpenAPI plugins work in default Chat and in custom agents. They are not available in Craft. For Craft,
use an [MCP server](/admins/plugins/mcp) or a [custom Craft App](/admins/plugins/craft_apps#custom-apps).

Use an OpenAPI plugin for internal services, such as a ticket system or an inventory API, when no MCP server exists.

## Add an OpenAPI plugin

**1. Open the OpenAPI form**

Go to **Admin Panel → Plugins**, click **Add**, then select **OpenAPI**.

**2. Paste the schema**

Paste the schema in **OpenAPI Schema Definition**. Onyx reads the schema and lists its operations below the field.

![The Add OpenAPI plugin form with a schema and the operations that Onyx found](https://mintcdn.com/danswer/yAnT-i7LBUiCJgOS/assets/admins/plugins/openapi_add_filled.png?fit=max\&auto=format\&n=yAnT-i7LBUiCJgOS\&q=85\&s=7ab08815ee13088becf38ecb27c0a375)

The schema must include:

* A `servers` entry with the base URL of the API.
* An `operationId` for each operation. Onyx uses it as the tool name.
* A `summary` or `description` for each operation, so the agent knows when to use it.

The Onyx API server must be able to reach the server URL.

**3. Add descriptions**

| Field | Who reads it |
| - | - |
| **Description for Humans** | Users, on the Plugins page and in the agent editor. |
| **Description for Agents** | The agent. Explain when to use the API and how to choose operations. |

**4. Set default Chat availability**

Turn on **Enable in default Chat** to make the plugin available in chats without a custom agent.
Turn it off to make the plugin available only in the custom agents that you add it to.

**5. Configure authentication**

Select an authentication method. See [Authentication](#authentication).

**6. Save**

Click **Add**. The plugin shows on the Plugins page with the **OpenAPI** type.

## Authentication

| Method | Effect |
| - | - |
| **No authentication** | Onyx sends requests without credentials. |
| **Custom Authorization Header** | Onyx adds one or more headers that you set, such as `Authorization: Bearer <token>`, to every request. All users share these credentials. |
| **OAuth** | Each user signs in with their own account. Onyx sends the user's access token with each request. |
| **Pass-through** | Onyx sends the user's Onyx sign-in token to the API. This method shows only when Onyx sign-in uses OAuth, OIDC, or Google OAuth. |

### Custom authorization header

![Custom Authorization Header settings with header name and value fields](https://mintcdn.com/danswer/yAnT-i7LBUiCJgOS/assets/admins/plugins/openapi_auth_custom_authorization_header.png?fit=max\&auto=format\&n=yAnT-i7LBUiCJgOS\&q=85\&s=51c05d33811b9dde51fcacf2dc73c83e)

Enter a header name and value. Click the add button to send more than one header.

### OAuth

![OAuth settings with Authorization URL, Token URL, client ID, client secret, scopes, and PKCE](https://mintcdn.com/danswer/yAnT-i7LBUiCJgOS/assets/admins/plugins/openapi_auth_oauth.png?fit=max\&auto=format\&n=yAnT-i7LBUiCJgOS\&q=85\&s=ec56f7c1562ae5f2ca426802d059c683)

**1. Create an OAuth client in the provider**

Set the client's redirect URI to the **Redirect URI** that Onyx shows:

```text theme={null}
https://<your-onyx-domain>/oauth-config/callback
```

**2. Enter the client details**

Enter the **Authorization URL**, **Token URL**, **OAuth Client ID**, and **OAuth Client Secret**. Optionally,
enter **Scopes** as a comma-separated list.

**3. Set PKCE**

Turn on PKCE if the provider requires it. Onyx uses the `S256` method.

**4. Test the connection**

Click **Test connection** to confirm that Onyx can complete the OAuth flow.

Each user connects their own account from the [Plugins page](/overview/core_features/plugins)
before the agent can call the API for them.

## Request placeholders

Use these placeholders anywhere in the schema, for example in the server URL, a path, or a parameter default.
Onyx replaces them with the values of the current request at call time.

| Placeholder | Value |
| - | - |
| `CHAT_SESSION_ID` | The ID of the current chat session |
| `MESSAGE_ID` | The ID of the current message |
| `USER_ID` | The ID of the current user |
| `USER_EMAIL` | The email address of the current user |

## Manage the plugin

Click the plugin on the Plugins page to open its settings.

| Tab | Contents |
| - | - |
| **Configuration** | Name, descriptions, schema, and **Enable in default Chat**. |
| **Authentication** | The authentication method and credentials. |
| **Tools** | The operations that Onyx found in the schema. |

![The Tools tab with the operations from an OpenAPI schema](https://mintcdn.com/danswer/yAnT-i7LBUiCJgOS/assets/admins/plugins/openapi_tab_tools.png?fit=max\&auto=format\&n=yAnT-i7LBUiCJgOS\&q=85\&s=410aad2e90b870a72e589ecf7fd60f5b)

The **Tools** tab is read only. To add, remove, or change an operation, edit the schema in the **Configuration** tab.

Turning off **Enable in default Chat** does not remove the plugin from custom agents.
Its credentials and settings stay the same. To remove the plugin from all agents, delete it from the Plugins page.

> [!NOTE]
>
> In Terraform, `onyx_custom_tool.enabled` sets **Enable in default Chat**. It does not change custom-agent attachments.

## Use the plugin in custom agents

Open the agent editor and select the plugin under **Actions**. See [Agents](/admins/agents/overview).

## Example

Use this schema to add a plugin that creates and gets agents in Onyx. Replace the server URL with your Onyx API URL.

```json OpenAPI expandable theme={null}
{
  "openapi": "3.1.0",
  "info": {
    "title": "Agents API",
    "version": "1.0.0",
    "description": "Minimal OpenAPI schema for creating and fetching agents in Onyx"
  },
  "servers": [
    {
      "url": "https://cloud.onyx.app/api"
    }
  ],
  "paths": {
    "/persona": {
      "post": {
        "summary": "Create Agent (Persona)",
        "operationId": "create_persona",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": { "type": "string" },
                  "description": { "type": "string" },
                  "document_set_ids": {
                    "type": "array",
                    "items": { "type": "integer" }
                  },
                  "num_chunks": { "type": "number" },
                  "is_public": { "type": "boolean" },
                  "recency_bias": {
                    "type": "string",
                    "enum": ["favor_recent", "base_decay", "no_decay", "auto"]
                  },
                  "llm_filter_extraction": { "type": "boolean" },
                  "llm_relevance_filter": { "type": "boolean" },
                  "tool_ids": {
                    "type": "array",
                    "items": { "type": "integer" }
                  },
                  "system_prompt": { "type": "string" },
                  "task_prompt": { "type": "string" },
                  "datetime_aware": { "type": "boolean" }
                },
                "required": [
                  "name",
                  "description",
                  "document_set_ids",
                  "num_chunks",
                  "is_public",
                  "recency_bias",
                  "llm_filter_extraction",
                  "llm_relevance_filter",
                  "tool_ids",
                  "system_prompt",
                  "task_prompt",
                  "datetime_aware"
                ]
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Created" }
        }
      }
    },
    "/persona/{persona_id}": {
      "get": {
        "summary": "Get Agent (Persona) By ID",
        "operationId": "get_persona",
        "parameters": [
          {
            "name": "persona_id",
            "in": "path",
            "required": true,
            "schema": { "type": "integer" }
          }
        ],
        "responses": {
          "200": { "description": "OK" }
        }
      }
    }
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.