---
docId: doc_f9de2c1cd16b46fc98dbefc77a064a44
title: Create a subagent
description: Creates a new agent and links it as a subagent to the parent agent's draft, in a single step.
api:
  group: agentes/subagentes
  auth: bearer
  operations:
    - operationId: createSubagent
      method: POST
      path: '/v1/agents/{agentId}/draft/subagents'
      postmanName: Create and link a subagent
---

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

# Create a subagent

Create a subagent and link it to the parent’s draft in one request. Send `child` with the subagent’s name and settings, and `link` with the rules for calling it. Then [publish the parent](/api-reference/agents/publications/publish) to use that link.

If the request fails, neither the subagent nor the link is created. If the agent already exists, use [Link a subagent](/api-reference/agents/subagents/link).

## Example

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

```bash
curl https://api.platic.ai/v1/agents/$AGENT_ID/draft/subagents \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "child": { "name": "Billing", "instructions": "Answer questions about invoices." },
    "link": {
      "alias": "billing",
      "mode": "delegate",
      "enabled": true,
      "description": "Questions about invoices",
      "delegationCriteria": "The customer asks about an invoice",
      "completionCriteria": "The invoice question is answered",
      "oneWayDelegation": false
    }
  }'
```

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

```ts
await platic.agents.subagents.create("agent_123", {
  child: { name: "Billing", instructions: "Answer questions about invoices." },
  link: {
    alias: "billing",
    mode: "delegate",
    enabled: true,
    description: "Questions about invoices",
    delegationCriteria: "The customer asks about an invoice",
    completionCriteria: "The invoice question is answered",
    oneWayDelegation: false,
  },
});
```

</Ways.Way>
</Ways>

## Path parameters

| Parameter | Type | Description | Required |
|-----------|------|-------------|----------|
| `agentId` | string | Parent agent id | ✓ |

## Request body

| Field | Type | Description | Required |
|-------|------|-------------|----------|
| `child.name` | string | Name of the new subagent, 1 to 100 characters | ✓ |
| `child.imageUrl` | string | URL or path of its photo. Without it, Platica assigns one | - |
| `child.instructions`, `child.guardrails`, etc. | object \| string | The subagent's [configuration](/api-reference/agents/configuration#sections) sections, directly in `child`, just like in [Create an agent](/api-reference/agents/create#request-body). They are applied over the default configuration | - |
| `link` | object | The link. See the table below | ✓ |
| `note` | string | Note for the parent's new version, up to 500 characters | - |

Fields of `link` (all required):

| Field | Type | Description |
|-------|------|-------------|
| `alias` | string | Name the model sees the subagent by. 1 to 100 characters |
| `mode` | string | `delegate`: hands it the conversation. `assist`: consults it and carries on itself |
| `enabled` | boolean | A link that is turned off stays configured, but the model doesn't see it |
| `description` | string | When to call it. Up to 2000 characters |
| `delegationCriteria` | string | With `delegate`: when to hand it the conversation. Up to 2000 characters |
| `completionCriteria` | string | With `delegate`: when to return the conversation to the parent. If empty, uses the generic criterion. Up to 2000 characters |
| `oneWayDelegation` | boolean | With `delegate`: whether it keeps the conversation and doesn't hand it back |

```json
{
  "child": {
    "name": "Billing",
    "instructions": "You help resolve payment and invoice questions for Acme Store."
  },
  "link": {
    "alias": "Billing",
    "mode": "delegate",
    "enabled": true,
    "description": "Questions about payments and invoices",
    "delegationCriteria": "When the customer asks about a payment or an invoice",
    "completionCriteria": "",
    "oneWayDelegation": false
  },
  "note": "Add billing"
}
```

## Response

`201 Created`, with the new subagent and the change to the parent's draft.

```json
{
  "status": "success",
  "data": {
    "child": {
      "id": "Ch1ld8mTe2LwP4kZ1aB9",
      "name": "Billing",
      "imageUrl": "/images/agents/avatars/p58.jpg",
      "status": "active",
      "owners": [],
      "draft": { "versionId": "v1", "number": 1 },
      "publication": { "versionId": "v1", "number": 1 },
      "hasUnpublishedChanges": false,
      "createdAt": "2026-10-28T12:10:00.000Z"
    },
    "parent": {
      "changed": true,
      "draft": { "versionId": "v5", "number": 5 },
      "version": {
        "versionId": "v5",
        "number": 5,
        "basedOnVersionId": "v4",
        "restoredFromVersionId": null,
        "copiedFrom": null,
        "createdAt": "2026-10-28T12:10:00.000Z",
        "createdBy": { "kind": "api_key", "keyId": "k3yId" },
        "source": "api",
        "via": null,
        "note": "Add billing"
      }
    }
  }
}
```

| Field | Description |
|-------|-------------|
| `child` | The new subagent, with the fields from [Get an agent](/api-reference/agents/get#response-fields). It is published as `v1` on creation |
| `parent` | The change to the parent's draft, with the fields from [Update the draft](/api-reference/agents/drafts/update#response) |

## Errors

| Status | `details.code` | When |
|--------|----------------|------|
| `400` | `INVALID_REQUEST` | The body doesn't have the expected shape, for example `child.name` or `link` is missing |
| `403` | `FORBIDDEN` | The credential can't create agents or can't edit the parent agent |
| `404` | `AGENT_NOT_FOUND` | The parent agent doesn't exist in the workspace or was deleted |
| `409` | `CONFLICT` | Someone else changed this at the same time. Try again |
| `422` | `INVALID_CONFIG` | A section of `child` or `link` contains an invalid value. `details.issues` lists the field path of each problem |
| `422` | `UNSUPPORTED_REASONING_EFFORT` | `child.model` or a model in `child.fallbackModels` asks for a [reasoning level](/api-reference/agents/configuration#reasoning-level) it doesn't accept. `details.supportedEfforts` lists the supported values. Nothing is created |
| `422` | `MODEL_FALLBACKS_REQUIRE_OWN_KEY` | `child.fallbackModels` includes fallback models, but the workspace has no connected provider key of its own. Nothing is created. See [fallback models](/api-reference/agents/configuration#fallback-models) |
| `422` | `INVALID_ESCALATION` | An escalation in `child.assistance.escalations` doesn't exist or is archived. `details.escalations` lists each one with `escalationId` and `reason`. Nothing is created |
| `503` | `SUPPORT_SERVICE_UNAVAILABLE` | The subagent's escalations couldn't be checked. Nothing is created; try again |

## Notes

- The link is part of the parent's draft: it creates a version of the parent and **doesn't publish**. The subagent starts answering when you [publish](/api-reference/agents/publications/publish) that version of the parent.
- A link always uses the subagent's **published version**. Publishing the subagent updates it for all of its parents, without touching them.
- The subagent is an agent like any other: you edit and publish it with its own id.
