---
title: "Add Context History Item"
method: POST
path: "/api/v1/contexts/{context_id}/history"
tags: ["contexts"]
---

# Add Context History Item

`POST /api/v1/contexts/{context_id}/history`

## Path parameters

- `context_id` string, uuid, required

## Request body

- union
  - ArtifactInput — Represents a file, data structure, or other resource generated by an agent during a task.
    - `artifactId` string, required
    - `description` string, nullable
    - `extensions` string[], nullable
    - `metadata` object, nullable
    - `name` string, nullable
    - `parts` PartInput[], required
      - union
        - TextPart — Represents a text segment within a message or artifact.
          - `kind` 'text'
          - `metadata` object, nullable
          - `text` string, required
        - FilePart — Represents a file segment within a message or artifact. The file content can be provided either directly as bytes or as a URI.
          - `file` union, required
            - FileWithBytes — Represents a file with its content provided directly as a base64-encoded string.
              - …
            - FileWithUri — Represents a file with its content located at a specific URI.
              - …
          - `kind` 'file'
          - `metadata` object, nullable
        - DataPart — Represents a structured data segment (e.g., JSON) within a message or artifact.
          - `data` object, required
          - `kind` 'data'
          - `metadata` object, nullable
  - MessageInput — Represents a single message in the conversation between a user and an agent.
    - `contextId` string, nullable
    - `extensions` string[], nullable
    - `kind` 'message'
    - `messageId` string, required
    - `metadata` object, nullable
    - `parts` PartInput[], required
      - union
        - TextPart — Represents a text segment within a message or artifact.
          - `kind` 'text'
          - `metadata` object, nullable
          - `text` string, required
        - FilePart — Represents a file segment within a message or artifact. The file content can be provided either directly as bytes or as a URI.
          - `file` union, required
            - FileWithBytes — Represents a file with its content provided directly as a base64-encoded string.
              - …
            - FileWithUri — Represents a file with its content located at a specific URI.
              - …
          - `kind` 'file'
          - `metadata` object, nullable
        - DataPart — Represents a structured data segment (e.g., JSON) within a message or artifact.
          - `data` object, required
          - `kind` 'data'
          - `metadata` object, nullable
    - `referenceTaskIds` string[], nullable
    - `role` 'agent' | 'user', required — Identifies the sender of the message. `user` for the client, `agent` for the service.
    - `taskId` string, nullable

## Response `201`

Successful Response

- unknown

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/i-am-bee/apis/agentstack-server.md) · [All operations](https://skmtc.net/i-am-bee/apis/agentstack-server/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/i-am-bee/agentstack-server/revisions/7d68b3f8bf7f/schema)
