Skip to content
Get started

Add an assignment to a variation

client.agentVariations.addAssignment(stringagentVariationID, AgentVariationAddAssignmentParams { subAgentId, toolId, toolSetId } body, RequestOptionsoptions?): VariationAssignment { id, agent, tool, toolSet }
POST/v1/agent_variations/{agentVariationId}/assignments

Assigns a tool, tool set, or sub-agent to a variation. Exactly one target ID must be set.

ParametersExpand Collapse
agentVariationID: string
body: AgentVariationAddAssignmentParams { subAgentId, toolId, toolSetId }
subAgentId?: string
toolId?: string
toolSetId?: string
ReturnsExpand Collapse
VariationAssignment { id, agent, tool, toolSet }

VariationAssignment is a read-only reference to a single tool, tool set, or sub-agent attached to a variation. Clients read the full set of assignments via AgentVariationInfo.assignments; mutations go through the dedicated add/remove assignment endpoints under /v1/agent_variations/{id}/assignments.

The id identifies the assignment row itself (not the referenced resource) and is the handle used to remove the assignment. It is returned by the add endpoint and present on every entry in AgentVariationInfo.assignments.

id?: string
agent?: BareMetadata { id, name }

BareMetadata contains the minimal metadata for a resource: the ID and an optional human-readable name. These are used for reference fields where the full metadata (account scoping, timestamps, labels, external IDs) is not needed — e.g., the tool references inside an agent variation spec or the tools assigned to an objective. Both fields are server-populated; clients provide IDs through sibling fields rather than by constructing a BareMetadata themselves.

id?: string
name?: string

Human-readable name of the referenced resource, populated by the server on reads for convenience. Absent on references to resources that do not have a name (e.g., objective tasks).

tool?: BareMetadata { id, name }

BareMetadata contains the minimal metadata for a resource: the ID and an optional human-readable name. These are used for reference fields where the full metadata (account scoping, timestamps, labels, external IDs) is not needed — e.g., the tool references inside an agent variation spec or the tools assigned to an objective. Both fields are server-populated; clients provide IDs through sibling fields rather than by constructing a BareMetadata themselves.

id?: string
name?: string

Human-readable name of the referenced resource, populated by the server on reads for convenience. Absent on references to resources that do not have a name (e.g., objective tasks).

toolSet?: BareMetadata { id, name }

BareMetadata contains the minimal metadata for a resource: the ID and an optional human-readable name. These are used for reference fields where the full metadata (account scoping, timestamps, labels, external IDs) is not needed — e.g., the tool references inside an agent variation spec or the tools assigned to an objective. Both fields are server-populated; clients provide IDs through sibling fields rather than by constructing a BareMetadata themselves.

id?: string
name?: string

Human-readable name of the referenced resource, populated by the server on reads for convenience. Absent on references to resources that do not have a name (e.g., objective tasks).

Add an assignment to a variation

import Cadenya from '@cadenya/cadenya';

const client = new Cadenya({
  apiKey: process.env['CADENYA_API_KEY'], // This is the default and can be omitted
});

const variationAssignment = await client.agentVariations.addAssignment('agentVariationId');

console.log(variationAssignment.id);
{
  "id": "id",
  "agent": {
    "id": "id",
    "name": "name"
  },
  "tool": {
    "id": "id",
    "name": "name"
  },
  "toolSet": {
    "id": "id",
    "name": "name"
  }
}
Returns Examples
{
  "id": "id",
  "agent": {
    "id": "id",
    "name": "name"
  },
  "tool": {
    "id": "id",
    "name": "name"
  },
  "toolSet": {
    "id": "id",
    "name": "name"
  }
}