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

# Agent Get API

> Retrieve details of an existing agent

Retrieves the current settings and details available for an existing agent in your workspace. The endpoint returns the agent's active (published) version. If the agent has never been published, it returns the current draft instead. Set `version` to `draft` to read the editable draft.

## Before You Start

* **API key scope**: Requires an API key with the **Agent API** scope and access to the agent you want to retrieve.
* **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](https://docs.langdock.com/en/developer/agents-api/assistant-to-agent-migration.md).

## Base URL

```
https://api.langdock.com/agent/v1/get
```

> [!WARNING]
>
> **Dedicated deployments**
>
> Replace `api.langdock.com` with `<your-deployment-url>/api/public` in all requests.

## Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `agentId` | string | Yes | UUID of the agent to retrieve |
| `version` | string | No | `published` (default) or `draft` |

## Examples

### Basic Retrieval

```javascript theme={null}
const axios = require("axios");

async function getAgent() {
  const response = await axios.get(
    "https://api.langdock.com/agent/v1/get",
    {
      params: {
        agentId: "550e8400-e29b-41d4-a716-446655440000"
      },
      headers: {
        Authorization: "Bearer YOUR_API_KEY"
      }
    }
  );

  console.log("Agent details:", response.data.agent);
}
```

## Validation Rules

The API enforces the following validation rules:

* **Agent access** - Your API key must have access to the agent
* **Draft read** - `version=draft` needs the same edit access as an [agent update](https://docs.langdock.com/en/developer/agents-api/agent-update.md#validation-rules)
* **Workspace match** - Agent must belong to the same workspace as 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. Sharing settings are current and independent of the returned agent version.

### Success Response (200 OK)

```typescript theme={null}
{
  status: "success";
  agent: {
    id: string;
    name: string;
    description: string | null;
    instruction: string | null;
    emojiIcon: string | null;
    model: string | null;
    temperature: number;
    conversationStarters: string[];
    inputType: "PROMPT" | "STRUCTURED" | "INTEGRATION" | "SCHEDULED" | "WEBHOOK";
    webSearchEnabled: boolean;
    imageGenerationEnabled: boolean;
    canvasEnabled: boolean;
    extendedThinking: boolean;
    actions: Array<{
      actionId: string;
      requiresConfirmation: boolean;
    }>;
    inputFields: Array<{
      type: "TEXT" | "MULTI_LINE_TEXT" | "NUMBER" | "CHECKBOX" | "FILE" | "SELECT" | "MULTI_SELECT" | "DATE" | "EMAIL";
      label: string;
      description: string | null;
      required: boolean;
      order: number;
      slug: string;
      options: string[];
      fileTypes: string | null;
      emailDomain: string | null;
    }>;
    attachments: string[];
    knowledgeFolderIds: string[];
    skillIds: string[];
    owner: {
      id: string;
      name: string | null;
      email: string;
    } | null;
    createdAt: string;
    updatedAt: string;
    access?: {
      users: Array<{ id: string; role: "user" | "editor" }>;
      groups: Array<{ id: string; role: "user" | "editor" }>;
      workspace: "user" | "editor" | null;
      sharingManagedByAdmin: boolean;
    };
  };
}
```

The `actions` array omits ids whose action is missing or soft-deleted. It still includes live actions that are unavailable in the workspace.

`skillIds` lists attached Skills. File templates stay on the agent and do not appear in this array.

## Error Handling

```typescript theme={null}
try {
  const response = await axios.get('https://api.langdock.com/agent/v1/get', ...);
} catch (error) {
  if (error.response) {
    switch (error.response.status) {
      case 400:
        console.error('Invalid agent ID format or unrecognized version');
        break;
      case 401:
        console.error('Invalid or missing API key');
        break;
      case 403:
        console.error('Draft: agent not found or API key cannot edit');
        break;
      case 404:
        console.error('Published agent not found or API key has no access');
        break;
      case 500:
        console.error('Server error');
        break;
    }
  }
}
```

> [!NOTE]
>
> 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](https://docs.langdock.com/en/admin/ai-adoption-and-rollout/best-practices/api-key-best-practices.md).


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