> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agnost.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Capture Event

> Record one turn-pair or tool call within a session

Generate `event_id` client-side (UUID) so child events can reference their parent before the parent's response returns.

## Body

| Field            | Type            | Required | Description                                                                                           |
| ---------------- | --------------- | -------- | ----------------------------------------------------------------------------------------------------- |
| `event_id`       | `string` (UUID) | Required | Client-generated UUID. Use as `parent_id` on child events.                                            |
| `session_id`     | `string` (UUID) | Required | Session UUID from `capture-session`.                                                                  |
| `primitive_name` | `string`        | Required | Agent name (turn-pair) or tool name (tool call).                                                      |
| `args`           | `string`        | Required | Input: user message or JSON-encoded tool args.                                                        |
| `result`         | `string`        | Required | Output: assistant reply or JSON-encoded tool result.                                                  |
| `success`        | `boolean`       | Optional | Defaults to `true`.                                                                                   |
| `latency`        | `integer` (ms)  | Optional | Execution time in milliseconds.                                                                       |
| `timestamp`      | `integer` (ms)  | Optional | Unix time in ms when the event occurred. Defaults to server time.                                     |
| `parent_id`      | `string` (UUID) | Optional | Parent event UUID. Set on tool calls to point at the agent turn (or parent tool) that triggered them. |
| `metadata`       | `object`        | Optional | Free-form event metadata.                                                                             |

## Core rules

* **One session per conversation**: reuse `session_id` on every event.
* **One event per turn-pair**: `primitive_name` is the agent name, `args` is the user input, `result` is the assistant output. Don't emit separate output events.
* **Merge assistant turns**: if one user turn is followed by N assistant turns (with tool calls between), concatenate the N texts into a single `result`.
* **Tool calls = own event**: `primitive_name` is the tool name, `args`/`result` are plain text or JSON-encoded strings.
* **Sub-tools chain**: when a tool invokes another tool, set `parent_id` to the parent **tool's** `event_id`.


## OpenAPI

````yaml POST /api/v1/capture-event
openapi: 3.0.3
info:
  title: Agnost AI API
  description: >
    Complete REST API for Agnost AI: an analytics and monitoring platform for AI
    agents.


    **Authentication**:

    - SDK ingestion endpoints (`/api/v1/*`) use `x-org-id` header (UUID)

    - Dashboard endpoints use `Authorization: Bearer <jwt>` + `x-org-id` header,
    or `x-api-key` header

    - API key management uses JWT only (no API key auth)
  version: 2.1.1
  contact:
    name: Agnost AI
    url: https://agnost.ai
servers:
  - url: https://api.agnost.ai
    description: Production
security: []
tags:
  - name: SDK
    description: Event ingestion endpoints used by SDKs
  - name: Dashboard
    description: Analytics and metrics for the dashboard
  - name: Organizations
    description: Organization management
  - name: Alerts
    description: Alert configuration and monitoring
  - name: SOPs
    description: Standard Operating Procedures
  - name: Sentiments
    description: Sentiment and intent analysis
  - name: Conversations
    description: Conversation message and span retrieval
  - name: Classification
    description: LLM-based classification operations
  - name: Onboarding
    description: First-run helpers used during organization setup
  - name: Connections
    description: External integrations (Slack)
  - name: Billing
    description: Stripe billing management
  - name: API Keys
    description: API key management
  - name: Auth
    description: OAuth authentication callbacks
  - name: System
    description: Health checks, webhooks, internal endpoints
paths:
  /api/v1/capture-event:
    post:
      tags:
        - SDK
      summary: Capture event
      description: >-
        Record one turn-pair or tool call. Generate `event_id` client-side so
        children can reference parents.
      operationId: captureEvent
      parameters:
        - name: x-org-id
          in: header
          required: true
          description: Your organization ID (UUID, case-insensitive).
          schema:
            type: string
            example: <org-id>
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - event_id
                - session_id
                - primitive_name
                - args
                - result
              properties:
                event_id:
                  type: string
                  format: uuid
                  description: Client-generated UUID. Use as `parent_id` on child events.
                  example: e8b1c52f-3a9d-4e7c-8f0b-2d6a91c4ef58
                session_id:
                  type: string
                  format: uuid
                  description: Session UUID from `capture-session`.
                  example: a3f9c182-7d4e-4b6a-9e21-c5d8f0b4e731
                primitive_name:
                  type: string
                  description: Agent name (turn-pair) or tool name (tool call).
                  example: your-agent-name
                args:
                  type: string
                  description: Input — user message or JSON-encoded tool args.
                  example: your input in plain text or JSON-encoded string
                result:
                  type: string
                  description: Output — assistant reply or JSON-encoded tool result.
                  example: your output in plain text or JSON-encoded string
                success:
                  type: boolean
                  description: Defaults to `true`.
                latency:
                  type: integer
                  description: Execution time in **ms**.
                  example: 5200
                timestamp:
                  type: integer
                  format: int64
                  description: >-
                    Unix time in **ms** when the event occurred. Defaults to
                    server time.
                  example: 1714867201000
                parent_id:
                  type: string
                  format: uuid
                  description: >-
                    Parent event UUID. Set on tool calls to point at the agent
                    turn (or parent tool) that triggered them.
                  example: 4c7d2e8a-1b95-4f3d-a08e-7b3c9d12f5e6
                metadata:
                  type: object
                  additionalProperties:
                    type: string
                  description: Free-form event metadata.
                  example:
                    language: hi-IN
      responses:
        '200':
          description: Event recorded
          content:
            application/json:
              schema:
                type: object
                properties:
                  event_id:
                    type: string
                    format: uuid
        '400':
          $ref: '#/components/responses/BadRequest'
components:
  responses:
    BadRequest:
      description: Invalid request body
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      properties:
        error:
          type: string
      required:
        - error
      example:
        error: Invalid request body

````