Skip to Content
Docs
API

API Overview

Everything the DocsGPT web app does goes through its HTTP API, so the same API lets you chat with agents from your own code, manage agents and sources from scripts and CI, and receive events.

Base URL

  • Your instance: the address the API listens on, http://localhost:7091 by default. When the API also serves the web UI (the default for docsgpt up, the standalone Docker image and pip installs), the API is on the same origin as the web app. API_URL is the address DocsGPT puts in the links it generates, such as webhook URLs.
  • DocsGPT Cloud: https://gptcloud.arc53.com.

Choose a credential

CredentialLooks likeHow to send itWhat it can callWhere to get it
Agent API keya UUIDapi_key in the request body of /api/answer, /stream, /api/search, /api/agent_starters and /api/store_attachment; Authorization: Bearer <key> for /v1/* and /mcpOne published agent: ask it questions, search its sources, attach filesPublish the agent, then open Access Details. See Agent API keys
Personal access tokendgpt_pat_...Authorization: Bearer <token>The management API, limited by the token’s scopes, plus chat for benchmarkingSettings β†’ Access Tokens. See Personal access tokens
Session tokena JWTAuthorization: Bearer <token>Everything the signed-in user can do in the web appDepends on AUTH_TYPE; see below
Webhook URLa URL with a secret token in its pathCall the URLStart one run of one agentAccess Details β†’ Webhook URL. See Agent webhooks

An agent API key acts as the agent: its prompt, sources, tools and model come from the agent, and the conversation is recorded under the agent’s owner. Its usage counts against whoever pays for the agent’s outside access: the owner of a personal agent, or the Admin who turned it on for a team agent (see Who pays). A key holder can’t approve anything on the owner’s behalf, so write actions on the owner’s connected accounts and saved credentials are refused unless the owner allows them (see Letting API callers make changes).

A personal access token is for automation: create and update agents, upload sources, edit prompts and tools. Each token has scopes, and an endpoint that isn’t mapped to a scope can’t be called with a token at all. The REST API reference lists the scope every endpoint needs. Tokens work only when AUTH_TYPE is unset or oidc.

A session token is what the web app sends. How you get one depends on AUTH_TYPE (see Authentication settings):

  • unset (the default): no token is needed. Every request acts as the one user local, so anyone who can reach the API can call all of it.
  • simple_jwt: the one shared token that the API prints at startup, or that docsgpt token prints for a docsgpt up install.
  • session_jwt: GET /api/generate_token returns a new token with a new, empty identity.
  • oidc: the token DocsGPT issues after a sign-in with your identity provider. For scripts, use a personal access token instead.

Work in a team workspace

A session token or a personal access token works in your Personal workspace unless the request names a team workspace:

  • Send the X-DocsGPT-Workspace header with a team id, or with personal.
  • Where a client can’t set headers, such as an EventSource or a download link, send the workspace query parameter instead. The header wins when both are sent.

Only lists, creates and new conversations read it: GET /api/get_agents lists the team’s agents, POST /api/create_agent creates one the team owns, and a new chat lives in the team. A request about one item, such as PUT /api/update_agent/<agent_id>, goes by that item’s own workspace. A team you’re not in answers 404 with "error": "workspace_not_found", the same as a team that doesn’t exist, and a create from a Viewer answers 403 with "error": "workspace_role_required".

GET /api/workspaces lists where you can work: Personal first, then each team with its id, name, your role (owner, admin, editor or viewer) and member_count. With a personal access token it needs teams:read.

curl -H "Authorization: Bearer $DOCSGPT_TOKEN" \
     -H "X-DocsGPT-Workspace: <team id>" \
     "$DOCSGPT_URL/api/get_agents"

An agent API key doesn’t need either: it always runs its own agent, wherever that agent lives. Moving items between workspaces (/api/workspace_moves) needs a signed-in session; see Personal access tokens.

Which page covers what

To…UsePage
Ask an agent a question, with or without streamingPOST /api/answer, POST /streamAgent API
Search an agent’s sources without calling a modelPOST /api/searchAgent API
List an agent’s starters (suggested first questions)POST /api/agent_startersAgent API
Connect an OpenAI SDK or an OpenAI-compatible tool/v1/chat/completions, /v1/modelsOpenAI-compatible API
Search an agent’s sources from an MCP client (Claude, Cursor, …)/mcpMCP server
Start an agent run from another system/api/webhooks/agents/<token>Agent webhooks
Follow ingestion, approvals and other live eventsGET /api/eventsRealtime events
Move agents between instances/api/export_agent, /api/import_agentAgent API
Manage agents, sources, prompts, tools, schedules and morethe management endpointsREST API reference

Swagger UI and the OpenAPI document

Every instance describes its own management API, so what you read there matches the version you run:

  • GET /swagger.json: the Swagger 2.0 (OpenAPI 2) document, for code generators and API clients such as Postman.
  • GET /api/docs: the Swagger UI for that document.

Releases up to 0.21 serve the Swagger UI at / instead. When the API also serves the web UI, the web UI takes /, so on those releases use /swagger.json. On an API without the web UI, / redirects to /api/docs.

The Swagger UI has no way to sign in, so its Try it out requests carry no token. They work on an instance with AUTH_TYPE unset; otherwise call the endpoints with curl or a client and an Authorization header.

The DocsGPT Cloud Swagger UI is at gptcloud.arc53.com. It describes the version DocsGPT Cloud runs, which can differ from yours. The REST API reference in these docs is generated from the same document for the current code.

What the Swagger document leaves out

These routes are not in /swagger.json. Each has its own page:

  • /v1/chat/completions and /v1/models: OpenAI-compatible API.
  • GET /api/events and GET /api/messages/<message_id>/events: Realtime events.
  • /mcp: DocsGPT’s own MCP server. Its search_docs tool searches an agent’s sources; send the agent’s API key as Authorization: Bearer <key>.
  • /api/devices/*, including the device command stream: Remote device.
  • GET /api/artifacts/<id>/download: Artifacts.
  • /api/auth/oidc/* and /scim/v2/*: SSO with OIDC.
  • GET /api/health (returns {"status": "ok"}, for health checks), GET /api/config (the authentication settings the web app reads) and GET /api/generate_token.

/mcp, the two event streams, the device command stream and artifact downloads are served only by the ASGI app, as docsgpt api, docsgpt dev and the Docker images run it. Under flask run they return 404 (see ASGI-only features).

Edit this page on GitHub

Last updated on

On this page