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

# REST API

> Create and configure agents, start runs and read their record, and manage skills, knowledge and workflows over HTTPS.

Base URL `https://api.xpander.ai`, JSON in and out, one of three credentials on every request (below). Everything xpander Chat does, from creating an agent to reading a task's execution log, is an endpoint here.

## Overview

The REST API is how your own systems drive agents on xpander. It lets you:

* **Manage Agents**: Create, update, deploy, and delete AI agents
* **Agent Workspace**: Run bash commands, edit files, search code, and share artifacts inside a per-agent workspace
* **Workflows**: Create and run workflow definitions
* **Skills**: Connect to external services, search and manage operations
* **Custom Functions**: Create, generate, and execute user-defined Python skills
* **Export & Import**: Share agents as templates across organizations
* **Execute Tasks**: Invoke agents and workflows synchronously, asynchronously, or with streaming
* **Control Knowledge**: Manage knowledge bases and documents
* **LLM Providers**: Discover available LLM providers and models

## Base URL

```
https://api.xpander.ai
```

## Authentication

Every request must carry one of these credentials:

* `x-api-key: <api-key>`: an xpander API key. The examples on these pages use this header.
* `Authorization: Bearer <jwt>`: an OAuth 2.1 access token issued by xpander's authorization server.
* `Authorization: Basic <base64 api-key>`: the same API key, base64-encoded, for clients that only speak Basic auth.

```bash theme={"dark"}
curl -X GET "https://api.xpander.ai/v1/agents" \
  -H "x-api-key: YOUR_API_KEY"
```

API keys come in two kinds. A **personal key** is tied to your user: an agent created with it is owned by your user, and it reaches the agents you can see. An **organization key** acts for the organization; an admin can limit which agents it may reach. Your organization's admin invites you to xpander and manages keys under Settings.

A personal key also reaches your own Omni, the built-in agent: [Get Omni Agent](https://docs.xpander.ai/api-reference/v1/agents/get-omni-agent.md) returns its id.

## Quick Start

```bash cURL theme={"dark"}
# List all agents
curl -X GET "https://api.xpander.ai/v1/agents" \
  -H "x-api-key: YOUR_API_KEY"

# Invoke an agent
curl -X POST "https://api.xpander.ai/v1/agents/{agent_id}/invoke" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": {
      "text": "Analyze this data"
    }
  }'
```

```python Python theme={"dark"}
import requests

API_KEY = "your-api-key"
BASE_URL = "https://api.xpander.ai/v1"
agent_id = "<agent-id>"

# List all agents
response = requests.get(
    f"{BASE_URL}/agents",
    headers={"x-api-key": API_KEY}
)
agents = response.json()

# Invoke an agent
response = requests.post(
    f"{BASE_URL}/agents/{agent_id}/invoke",
    headers={"x-api-key": API_KEY},
    json={"input": {"text": "Analyze this data"}}
)
result = response.json()
```

```javascript JavaScript theme={"dark"}
const API_KEY = 'your-api-key';
const BASE_URL = 'https://api.xpander.ai/v1';
const agentId = '<agent-id>';

// List all agents
const agents = await fetch(`${BASE_URL}/agents`, {
  headers: { 'x-api-key': API_KEY }
}).then(r => r.json());

// Invoke an agent
const result = await fetch(`${BASE_URL}/agents/${agentId}/invoke`, {
  method: 'POST',
  headers: {
    'x-api-key': API_KEY,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    input: { text: 'Analyze this data' }
  })
}).then(r => r.json());
```

## API Endpoints

> [card] [Agents](https://docs.xpander.ai/api-reference/v1/agents/list-agents.md)
>
> Create, manage, and invoke AI agents

> [card] [Agent Workspace](https://docs.xpander.ai/api-reference/v1/agents/workspace/file-read.md)
>
> Read, edit, and share files in a per-agent workspace

> [card] [Workflows](https://docs.xpander.ai/api-reference/v1/workflows/list-workflows.md)
>
> Create and run workflow definitions

> [card] [Skills](https://docs.xpander.ai/api-reference/v1/tools/list-tools.md)
>
> Discover skills, connect, inspect operation schemas, and invoke operations

> [card] [Custom Functions](https://docs.xpander.ai/api-reference/v1/custom_functions/list-custom-functions.md)
>
> Create and execute user-defined Python skills

> [card] [Tasks](https://docs.xpander.ai/api-reference/v1/tasks/list-tasks.md)
>
> Monitor and manage task executions

> [card] [Knowledge](https://docs.xpander.ai/api-reference/v1/knowledge/list-knowledge-bases.md)
>
> Manage knowledge bases and documents

> [card] [LLM Providers](https://docs.xpander.ai/api-reference/v1/misc/list-llm-providers.md)
>
> Discover available LLM providers and models

## Errors

A `422` names the field that failed validation, in FastAPI's shape:

```json theme={"dark"}
{
  "detail": [
    {
      "type": "missing",
      "loc": ["body", "input"],
      "msg": "Field required",
      "input": {}
    }
  ]
}
```

## Next Steps

> [card] [Agent Endpoints](https://docs.xpander.ai/api-reference/v1/agents/list-agents.md)
>
> Explore agent management endpoints

> [card] [Workflow Endpoints](https://docs.xpander.ai/api-reference/v1/workflows/list-workflows.md)
>
> Create and run workflows

> [card] [Examples](https://github.com/xpander-ai/xpander.ai)
>
> View code examples

> [card] [OpenAPI Spec](https://api.xpander.ai/openapi.json)
>
> Download OpenAPI specification


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