Create an agent

Create a new AI agent. Supports the Idempotency-Key header for safe retries.

POST /api/v1/agents

Create a new AI agent. Honors the Idempotency-Key header so retries don't create duplicates, see Idempotency.

Scope: agents:write

Request body

FieldTypeRequiredNotes
handlestringyescamelCase alphanumeric. Must be unique within the org (case-insensitive).
namestringyesDisplay name.
instructionsstringyes*Plain text. Required unless instructions_html is provided.
instructions_htmlstringnoRich text (HTML subset). Plain text is auto-derived for the system prompt.
descriptionstring | nullnoShort summary, surfaced in the dashboard agent list.
modelstringnoModel ID. Defaults to org default.
colorstringnoHex color. Defaults to #6366f1.
avatarstringnoEmoji or URL.
include_system_promptbooleannoDefaults to true.
toolsarraynoArray of { name, connector_id } tool refs. See below.
connectorsarraynoArray of connector IDs. Derived from tools[].connector_id if omitted.
sub_agentsarraynoArray of agent IDs to delegate to (handoff pattern). Cannot include this agent's own ID.
data_sourcesarraynoArray of { source_id, scope, documents } data source refs.

Sub-shapes

Tool reference

{
  "name": "zendesk_get_ticket",
  "connector_id": "connector_64f1c0ef2ec711ef6dc1dcf"
}

name is the base tool name (never the multi-instance suffix). connector_id may be null for built-in / knowledge tools.

Data source reference

{
  "source_id": "source_64f1c0ef2ec711ef6dc1dcf",
  "scope": "selected",
  "documents": ["doc_abc...", "doc_def..."]
}

scope is "all" or "selected". When "selected", documents[] is required.

Example request

curl -X POST https://dashboard.getmacha.com/api/v1/agents \
  -H "Authorization: Bearer $MACHA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "handle": "wismo",
    "name": "WISMO",
    "instructions": "Answer Where Is My Order questions using the Shopify order tool. Never make up tracking info.",
    "model": "gpt-5",
    "tools": [
      { "name": "shopify_get_order",        "connector_id": "connector_abc..." },
      { "name": "shopify_search_orders",    "connector_id": "connector_abc..." },
      { "name": "zendesk_add_public_reply", "connector_id": "connector_def..." }
    ]
  }'

Example response (201)

{
  "data": {
    "id": "agent_6a39a4f1c0ef2ec711ef6dc1",
    "handle": "wismo",
    "name": "WISMO",
    "model": "gpt-5",
    "is_active": true,
    "color": "#6366f1",
    "tools_count": 3,
    "sub_agents_count": 0,
    "created_at": "2026-06-24T10:42:00.000Z",
    "updated_at": "2026-06-24T10:42:00.000Z"
  },
  "meta": { "request_id": "req_..." }
}

Errors

StatusCodeWhen
401unauthorizedBad / missing key.
403insufficient_scopeKey lacks agents:write.
409agent_handle_takenAnother agent already uses this handle.
409idempotency_key_reusedIdempotency-Key already used with a different body.
422validation_failedMissing required field, bad handle format, unknown sub-agent, plan limit reached.
429rate_limitedPer-key ceiling exceeded.

© 2026 AGZ Technologies Private Limited