---
docId: doc_d60f6062b9f548d19f2fe48f9f20d0ac
title: Copy an agent
description: "Copy an agent’s configuration and choose whether to connect its files."
api:
  group: agentes
  auth: bearer
  operations:
    - operationId: copyAgent
      method: POST
      path: '/v1/agents/{agentId}/copies'
      postmanName: Copy an agent
---

<script>
  import { Ways } from '$lib/components';
</script>

# Copy an agent

Create a new agent with another agent’s configuration. Send the copy’s `name` and, to choose a specific version, `fromVersionId`. If you omit the version, the published version is copied. The copy is published as `v1`.

## Copy the files too

With `"files": { "include": true }`:

- **Nothing is duplicated.** The copy is connected to the same [files](/api-reference/files) as the original. Changing a file's content or name changes it for both agents; pausing or disconnecting it only affects the agent where you do it.
- **The copy is created inactive** (`status: "inactive"`), while its files are being connected. When the request finishes successfully, [activate it](/api-reference/agents/update).
- **If the response is `503` with `details.code: "KNOWLEDGE_ENGINE_UNAVAILABLE"`**, the copy already exists, but its files didn't finish connecting: activating or publishing it answers `409` with `details.code: "COPY_INCOMPLETE"`. Its id comes in `details.agentId`: [delete it](/api-reference/agents/delete) and copy again in a few minutes.
- **Required permission**: being able to edit the original agent or having the Integrations permission. Without it, the response is `403` and nothing is created: copy only the configuration.

## Example

<Ways tabs="api,sdk">
<Ways.Way name="api">

```bash
curl https://api.platic.ai/v1/agents/$AGENT_ID/copies \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Sales (copy)" }'
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
await platic.agents.copy("agent_123", { name: "Sales (copy)" });
```

</Ways.Way>
</Ways>

## Path parameters

| Parameter | Type | Description | Required |
|-----------|------|-------------|----------|
| `agentId` | string | Id of the agent being copied | ✓ |

## Request body

| Field | Type | Description | Required |
|-------|------|-------------|----------|
| `name` | string | Name of the new agent, 1 to 100 characters | ✓ |
| `fromVersionId` | string | Version to copy, for example `v3`. Defaults to the published one | - |
| `files` | object | `{ "include": true }` connects the copy to the same files as the original, each with the same active or paused state. If you omit `files` or use `false`, the copy has no files | - |

```json
{
  "name": "Sales (copy)",
  "fromVersionId": "v3",
  "files": { "include": true }
}
```

## Response

`201 Created` with the new agent:

```json
{
  "status": "success",
  "data": {
    "id": "Cp7nRe5KwT2jY8bA3dGh",
    "name": "Sales (copy)",
    "imageUrl": "/images/agents/avatars/p12.jpg",
    "status": "inactive",
    "owners": [],
    "draft": { "versionId": "v1", "number": 1 },
    "publication": { "versionId": "v1", "number": 1 },
    "hasUnpublishedChanges": false,
    "createdAt": "2026-10-28T13:00:00.000Z"
  }
}
```

The fields are those from [Get an agent](/api-reference/agents/get#response-fields). In the example the copy is inactive because it was requested with `files.include`; without it, the copy is created active.

## Errors

| Status | `details.code` | When |
|--------|----------------|------|
| `400` | `INVALID_REQUEST` | The body doesn't have the expected shape, for example `name` is missing |
| `403` | `RESOURCE_NOT_ACCESSIBLE` | You asked for `files.include` without being able to edit the original agent or having the Integrations permission |
| `404` | `AGENT_NOT_FOUND` | The original agent doesn't exist in the workspace or was deleted |
| `404` | `VERSION_NOT_FOUND` | `fromVersionId` doesn't exist on that agent |
| `409` | `KNOWLEDGE_NOT_ENABLED` | You asked for `files.include` and files aren't enabled in this workspace. Copy only the configuration |
| `422` | `INVALID_SUBAGENT_LINK` | The version you copy links a subagent that was already deleted. Copy another version, or remove the link and copy the new version. Nothing is created |
| `422` | `INVALID_ESCALATION` | An escalation in the version you copy no longer exists or is archived. `details.escalations` carries each one with `escalationId` and `reason`. Nothing is created |
| `503` | `SUPPORT_SERVICE_UNAVAILABLE` | The version's escalations couldn't be checked. Nothing is created; try again |
| `503` | `KNOWLEDGE_ENGINE_UNAVAILABLE` | The copy exists, but its files didn't finish connecting. Delete it and copy again |

```json
{
  "code": 404,
  "error": "Not Found - The resource doesn't exist",
  "details": {
    "code": "VERSION_NOT_FOUND",
    "message": "Version v9 of agent Xq8mTe2LwP4kZ1aB9cDf not found"
  }
}
```

## Notes

- The copy's `v1` records where it comes from in `copiedFrom` (`agentId` and `versionId`). See [Get a version](/api-reference/agents/versions/get).
- It doesn't copy the version history, channels or tools. Files only with `files.include`.
- The copy uses the same photo as the original. Change it with [Update an agent](/api-reference/agents/update).
- If you create it with an OAuth token, the person who owns the token becomes the copy's owner.
