> ## Documentation Index
> Fetch the complete documentation index at: https://velt-raghul-agent-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Agent Group

Use this API to create an agent group. Groups are lightweight named collections that reference existing agents via an `agentIds` array — agents themselves remain independent documents and can belong to multiple groups.

`metadata` is an **optional, free-form** object — mirroring the agent create contract. The workspace `apiKey` is merged into `metadata.apiKey` server-side. **`metadata` is immutable after creation** — there is no way to modify it via [Update Group](/api-reference/rest-apis/v2/agents/groups/update). If you need document or organization context on a group, embed it inside `metadata` on create.

The schema uses `.strict()` so unknown top-level fields are rejected with a clear validation error.

**Limits:**

* Workspace cap: `MAX_GROUPS_PER_API_KEY = 50` (enforced via Firestore `count()` on create)
* Per-group cap: `MAX_AGENTS_PER_GROUP = 100` (enforced inside a Firestore transaction)

# Endpoint

`POST https://api.velt.dev/v2/agents/groups/create`

# Headers

<ParamField header="x-velt-api-key" type="string" required>
  Your API key.
</ParamField>

<ParamField header="x-velt-auth-token" type="string" required>
  Your [Auth Token](/security/auth-tokens).
</ParamField>

# Body

#### Params

<ParamField body="data" type="object" required>
  <Expandable title="properties">
    <ParamField body="name" type="string" required>
      Trimmed, non-empty. Capped at `MAX_GROUP_NAME_LENGTH`.
    </ParamField>

    <ParamField body="description" type="string">
      Trimmed. Capped at `MAX_GROUP_DESCRIPTION_LENGTH`.
    </ParamField>

    <ParamField body="agentIds" type="string[]">
      Initial members. Each id must be min 1 char. Capped at `MAX_AGENTS_PER_GROUP`. Built-in agent ids are accepted without a Firestore lookup; custom agent ids are validated in a single batched read. Unknown ids return `NOT_FOUND`.
    </ParamField>

    <ParamField body="metadata" type="object">
      Free-form metadata. Persisted verbatim; the workspace `apiKey` is merged in as `metadata.apiKey`. Immutable after creation.
    </ParamField>
  </Expandable>
</ParamField>

## **Example Requests**

#### 1. Minimal group

```JSON theme={null}
{
  "data": {
    "name": "Brand QA"
  }
}
```

#### 2. Full group with members and metadata

```JSON theme={null}
{
  "data": {
    "name": "Brand QA",
    "description": "All brand-quality agents",
    "agentIds": ["abc123def456", "spell-check"],
    "metadata": {
      "organizationId": "server_org_001",
      "documentId": "server_doc_001",
      "clientOrganizationId": "org_001",
      "clientDocumentId": "doc_001"
    }
  }
}
```

# Response

#### Success Response

```JSON theme={null}
{
  "result": {
    "status": "success",
    "message": "Agent group created successfully",
    "data": {
      "group": {
        "id": "grp_9f3ac2",
        "name": "Brand QA",
        "description": "All brand-quality agents",
        "agentIds": ["abc123def456", "spell-check"],
        "metadata": {
          "apiKey": "ak_xxx",
          "organizationId": "server_org_001",
          "documentId": "server_doc_001",
          "clientOrganizationId": "org_001",
          "clientDocumentId": "doc_001"
        },
        "createdAt": 1711900000000,
        "updatedAt": 1711900000000
      }
    }
  }
}
```

#### Failure Response

```JSON theme={null}
{
  "error": {
    "message": "ERROR_MESSAGE",
    "status": "RESOURCE_EXHAUSTED"
  }
}
```

**Errors:**

* `INVALID_ARGUMENT` — Zod validation failure (missing `name`, unknown top-level field, etc.)
* `RESOURCE_EXHAUSTED` — workspace already has `MAX_GROUPS_PER_API_KEY` groups, OR initial `agentIds` exceeds `MAX_AGENTS_PER_GROUP`
* `NOT_FOUND` — one of the initial `agentIds` does not exist

<ResponseExample>
  ```js theme={null}
  {
    "result": {
      "status": "success",
      "message": "Agent group created successfully",
      "data": {
        "group": {
          "id": "grp_9f3ac2",
          "name": "Brand QA",
          "agentIds": [],
          "metadata": { "apiKey": "ak_xxx" },
          "createdAt": 1711900000000,
          "updatedAt": 1711900000000
        }
      }
    }
  }
  ```
</ResponseExample>
