Skip to main content
Creates a new agent in your workspace programmatically. The created agent can be used via the chat completions endpoint or accessed through the Langdock UI.

Before You Start

  • API key scope: Requires an API key with the Agent API scope. Created agents are automatically shared with the API key for use in chat completions.
  • Legacy Assistants API: This is the new Agents API with native Vercel AI SDK compatibility. If you’re using the legacy Assistants API, see the migration guide.

Base URL

Dedicated deploymentsReplace api.langdock.com with <your-deployment-url>/api/public in all requests.

Parameters

The dataAnalyst parameter is deprecated and has no effect. Requests that include it still succeed for backward compatibility, but Langdock ignores the value and does not enable file or code execution. Omit this parameter from new integrations.

Access Configuration

Use access to share the agent with users, groups, or your workspace. The existing Agent API scope is sufficient; the key owner’s workspace sharing permissions still apply.
  • Roles - "user" allows using the agent; "editor" allows editing it. Set an entry’s role to null to revoke that direct grant.
  • Targets - New user grants require active users in the same workspace. Groups must belong to the workspace and be manageable by the key owner, unless workspace permissions allow sharing with any group. IDs must be unique within each array.
  • Ownership - Owner and API-key grants cannot be changed through access.
New user and group grants send in-app notifications after saving. Repeated grants, role changes, and revocations do not send notifications. No email is sent.

Actions Configuration

Each action in the actions array should contain:
  • actionId (required) - UUID of the action from an enabled integration
  • requiresConfirmation (optional) - Whether to require user confirmation before executing (default: true)
Only actions from integrations enabled in your workspace can be used.

Skills

  • Pass Skill UUIDs from the Skills API in skillIds.
  • The key owner must be able to attach each Skill. File templates are rejected.

Subagents

  • Each object needs agentId. requiresConfirmation is optional and defaults to false.
  • Omit the field or send [] to attach none. Duplicate agentId values keep the first object.

Workflows

  • Pass workflow UUIDs in workflowIds.
  • Omit the field or send [] to attach none. Duplicate IDs are removed.

Input Fields Configuration

When using inputType: "STRUCTURED", you can define form fields in the inputFields array: Supported Field Types:
  • TEXT - Single line text input
  • MULTI_LINE_TEXT - Multi-line text area
  • NUMBER - Numeric input
  • CHECKBOX - Boolean checkbox
  • FILE - File upload
  • SELECT - Dropdown selection
  • MULTI_SELECT - Multi-select
  • DATE - Date picker
  • EMAIL - Email address

Obtaining Attachment IDs

To include attachments with your agent, first upload files using the Upload Attachment API. This will return attachment UUIDs that you can include in the attachments array.

Examples

Creating a Basic Agent

Validation Rules

The API enforces several validation rules:
  • Model - Must be in your workspace’s active models list
  • Actions - Must belong to integrations enabled in your workspace
  • Attachments - Must exist in your workspace and not be deleted
  • Folders - Must exist in your workspace and not be deleted
  • Skills - Each ID must be a Skill the key owner can attach. File templates are rejected
  • Subagents - Each agentId must be an agent in your workspace that the key owner can use. Agents set to Direct only are rejected
  • Workflows - Each ID must be an active workflow in your workspace that the key owner can use. Templates are rejected. When the list is not empty, the key owner needs Workflows enabled
  • Permissions - Your API key must have the createAgents permission
  • Sharing - Sharing permissions and targets are validated before any changes are saved
  • Name - Must be between 1-80 characters
  • Description - Maximum 800 characters
  • Instruction - Maximum 50000 characters
  • Creativity - Must be between 0 and 1

Important Notes

Pre-selected OAuth connections are not supported via the API. Users must configure OAuth connections through the Langdock UI.
  • Created agents are automatically shared with your API key for use in chat completions
  • The key owner becomes the owner and can manage the agent in the UI
  • Attachments are bidirectionally linked to the agent
  • createdBy and workspaceId are automatically set from your API key

Response Format

agent.access is included only when the API key has an explicit editor or owner grant on the agent. It lists direct user, group, and workspace grants, excluding owner and API-key grants. sharingManagedByAdmin is read-only; when true, sharing cannot be changed through this API.

Success Response (201 Created)

Error Handling

Langdock intentionally blocks browser-origin requests to protect your API key and ensure your applications remain secure. For more information, please see our guide on API Key Best Practices.