---
title: "Create Agent"
method: POST
path: "/extensions/roboledger/{graph_id}/operations/create-agent"
tags: ["RoboLedger: Ledger & Events"]
---

# Create Agent

`POST /extensions/roboledger/{graph_id}/operations/create-agent`

## Request

- Base URL: `https://api.robosystems.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://api.robosystems.ai/extensions/roboledger/{graph_id}/operations/create-agent`
- Auth: one of:
  - API key in header `X-API-Key`
  - HTTP bearer

Create a counterparty record (customer, vendor, employee, etc.). The (source, external_id) pair is a dedup key — a second insert with the same pair returns 409. Use update-agent to patch fields.

**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.

## Path parameters

- `graph_id` string, required

## Headers

- `Idempotency-Key` string, nullable

## Request body

- CreateAgentRequest: Create a new economic counterparty. `agent_type` is the relationship category (customer, vendor, employee, etc.) — the same legal entity may have multiple Agent rows if they play multiple roles (e.g. a vendor who also became a customer). `source` distinguishes integration-imported rows from native-created ones; `external_id` carries the source-system's primary key for sync.
  - `agent_type` string, required: Relationship category: 'customer' | 'vendor' | 'employee' | 'owner' | 'supplier' | 'government' | 'lender' | 'self' | 'other'.
  - `name` string, required: Display name shown in lists and on transactions.
  - `legal_name` string, nullable: Full registered legal name (when different from `name`).
  - `tax_id` string, nullable: Tax ID (EIN / SSN / VAT). Used for 1099 / withholding reporting.
  - `registration_number` string, nullable: Registry-issued company number (e.g. state corp file number).
  - `duns` string, nullable: Dun & Bradstreet DUNS number.
  - `lei` string, nullable: Legal Entity Identifier (ISO 17442).
  - `email` string, nullable
  - `phone` string, nullable
  - `address` object, nullable: Free-form address object (e.g. {"line1": "...", "city": "...", "state": "...", "postal_code": "..."}).
  - `source` string: Provenance: 'native' (created in-app), 'quickbooks' / 'xero' / 'plaid' (synced from integration). Drives reconciliation behavior.
  - `external_id` string, nullable: Source system primary key — used to match on subsequent syncs.
  - `is_active` boolean: Inactive agents stay in history but can't be picked for new txns.
  - `is_1099_recipient` boolean: Marks a vendor as 1099-eligible. Drives year-end 1099 reporting.
  - `metadata` object

## Response `200`

Successful Response

- OperationEnvelopeLedgerAgentResponse
  - `operation` string, required: Kebab-case operation name
  - `operationId` string, required: op_-prefixed ULID for audit and SSE correlation
  - `status` 'completed' | 'pending' | 'failed', required: Operation lifecycle state
  - `result` LedgerAgentResponse
    - `id` string, required
    - `agent_type` string, required
    - `name` string, required
    - `legal_name` string, nullable
    - `tax_id` string, nullable
    - `registration_number` string, nullable
    - `duns` string, nullable
    - `lei` string, nullable
    - `email` string, nullable
    - `phone` string, nullable
    - `address` object, nullable
    - `source` string, required
    - `external_id` string, nullable
    - `is_active` boolean, required
    - `is_1099_recipient` boolean, required
    - `classification` AgentClassification: A counterparty's default account for one entity's lines, learned from committed lines or set by hand.
      - `entity_id` string, required: The entity whose lines it is for.
      - `element_id` string, required: The default chart account.
      - `account_name` string, nullable: The account's name.
      - `mode` string, required: `suggest`: offered on each new line. `always_ask`: never offered.
      - `confirmations` integer, required: Committed lines that went to this account.
      - `overrides` integer, required: Committed lines that went elsewhere while it was the default.
      - `set_by` string, nullable: Who set or last moved it.
      - `set_at` string, nullable: When it was set or last moved.
      - `learned_from` string, nullable: The committed line it was learned from, when it was.
    - `classifications` AgentClassification[]: The default account for each entity's bank lines, one per entity.
      - `entity_id` string, required: The entity whose lines it is for.
      - `element_id` string, required: The default chart account.
      - `account_name` string, nullable: The account's name.
      - `mode` string, required: `suggest`: offered on each new line. `always_ask`: never offered.
      - `confirmations` integer, required: Committed lines that went to this account.
      - `overrides` integer, required: Committed lines that went elsewhere while it was the default.
      - `set_by` string, nullable: Who set or last moved it.
      - `set_at` string, nullable: When it was set or last moved.
      - `learned_from` string, nullable: The committed line it was learned from, when it was.
    - `created_at` string, date-time, nullable
    - `updated_at` string, date-time, nullable
    - `created_by` string, nullable
  - `at` string, required: ISO-8601 UTC timestamp
  - `createdBy` string, nullable: User ID that initiated the operation
  - `idempotentReplay` boolean: True when this envelope came from the idempotency cache — the underlying command did not execute again. False on fresh executions.

## Other responses

- `400`: Invalid request
- `401`: Authentication required
- `403`: Access denied
- `404`: Resource not found
- `409`: Idempotency-Key conflict — key reused with different body
- `422`: Validation error
- `429`: Rate limit exceeded
- `500`: Internal server error

---

[API](https://skmtc.dev/robosystems/apis/robosystems-api.md) · [All operations](https://skmtc.dev/robosystems/apis/robosystems-api/llms.txt) · [OpenAPI document](https://skmtc.dev/robosystems/apis/robosystems-api/revisions/e661e2d5ca6a?raw)
