# Batch

## Batch Update Messages

`client.messages.batch.update(BatchUpdateParamsbody, RequestOptionsoptions?): BatchUpdateResponse`

**put** `/messages/batch`

Batch Update Messages

### Parameters

- `body: BatchUpdateParams`

  - `task_id: string`

  - `updates: Record<string, TaskMessageContent>`

    - `TextContent`

      - `author: MessageAuthor`

        The role of the messages author, in this case `system`, `user`, `assistant`, or `tool`.

        - `"user"`

        - `"agent"`

      - `content: string`

        The contents of the text message.

      - `attachments?: Array<Attachment> | null`

        Optional list of file attachments with structured metadata.

        - `file_id: string`

          The unique ID of the attached file

        - `name: string`

          The name of the file

        - `size: number`

          The size of the file in bytes

        - `type: string`

          The MIME type or content type of the file

      - `format?: TextFormat`

        The format of the message. This is used by the client to determine how to display the message.

        - `"markdown"`

        - `"plain"`

        - `"code"`

      - `style?: MessageStyle`

        The style of the message. This is used by the client to determine how to display the message.

        - `"static"`

        - `"active"`

      - `type?: "text"`

        The type of the message, in this case `text`.

        - `"text"`

    - `ReasoningContent`

      - `author: MessageAuthor`

        The role of the messages author, in this case `system`, `user`, `assistant`, or `tool`.

      - `summary: Array<string>`

        A list of short reasoning summaries

      - `content?: Array<string> | null`

        The reasoning content or chain-of-thought text

      - `style?: MessageStyle`

        The style of the message. This is used by the client to determine how to display the message.

      - `type?: "reasoning"`

        The type of the message, in this case `reasoning`.

        - `"reasoning"`

    - `DataContent`

      - `author: MessageAuthor`

        The role of the messages author, in this case `system`, `user`, `assistant`, or `tool`.

      - `data: Record<string, unknown>`

        The contents of the data message.

      - `style?: MessageStyle`

        The style of the message. This is used by the client to determine how to display the message.

      - `type?: "data"`

        The type of the message, in this case `data`.

        - `"data"`

    - `ToolRequestContent`

      - `arguments: Record<string, unknown>`

        The arguments to the tool.

      - `author: MessageAuthor`

        The role of the messages author, in this case `system`, `user`, `assistant`, or `tool`.

      - `name: string`

        The name of the tool that is being requested.

      - `tool_call_id: string`

        The ID of the tool call that is being requested.

      - `style?: MessageStyle`

        The style of the message. This is used by the client to determine how to display the message.

      - `type?: "tool_request"`

        The type of the message, in this case `tool_request`.

        - `"tool_request"`

    - `ToolResponseContent`

      - `author: MessageAuthor`

        The role of the messages author, in this case `system`, `user`, `assistant`, or `tool`.

      - `content: unknown`

        The result of the tool.

      - `name: string`

        The name of the tool that is being responded to.

      - `tool_call_id: string`

        The ID of the tool call that is being responded to.

      - `is_error?: boolean | null`

        Whether the tool call resulted in an error. `None` when the harness does not report a status.

      - `style?: MessageStyle`

        The style of the message. This is used by the client to determine how to display the message.

      - `type?: "tool_response"`

        The type of the message, in this case `tool_response`.

        - `"tool_response"`

### Returns

- `BatchUpdateResponse = Array<TaskMessage>`

  - `content: TaskMessageContent`

    The content of the message. This content is not OpenAI compatible. These are messages that are meant to be displayed to the user.

    - `TextContent`

      - `author: MessageAuthor`

        The role of the messages author, in this case `system`, `user`, `assistant`, or `tool`.

        - `"user"`

        - `"agent"`

      - `content: string`

        The contents of the text message.

      - `attachments?: Array<Attachment> | null`

        Optional list of file attachments with structured metadata.

        - `file_id: string`

          The unique ID of the attached file

        - `name: string`

          The name of the file

        - `size: number`

          The size of the file in bytes

        - `type: string`

          The MIME type or content type of the file

      - `format?: TextFormat`

        The format of the message. This is used by the client to determine how to display the message.

        - `"markdown"`

        - `"plain"`

        - `"code"`

      - `style?: MessageStyle`

        The style of the message. This is used by the client to determine how to display the message.

        - `"static"`

        - `"active"`

      - `type?: "text"`

        The type of the message, in this case `text`.

        - `"text"`

    - `ReasoningContent`

      - `author: MessageAuthor`

        The role of the messages author, in this case `system`, `user`, `assistant`, or `tool`.

      - `summary: Array<string>`

        A list of short reasoning summaries

      - `content?: Array<string> | null`

        The reasoning content or chain-of-thought text

      - `style?: MessageStyle`

        The style of the message. This is used by the client to determine how to display the message.

      - `type?: "reasoning"`

        The type of the message, in this case `reasoning`.

        - `"reasoning"`

    - `DataContent`

      - `author: MessageAuthor`

        The role of the messages author, in this case `system`, `user`, `assistant`, or `tool`.

      - `data: Record<string, unknown>`

        The contents of the data message.

      - `style?: MessageStyle`

        The style of the message. This is used by the client to determine how to display the message.

      - `type?: "data"`

        The type of the message, in this case `data`.

        - `"data"`

    - `ToolRequestContent`

      - `arguments: Record<string, unknown>`

        The arguments to the tool.

      - `author: MessageAuthor`

        The role of the messages author, in this case `system`, `user`, `assistant`, or `tool`.

      - `name: string`

        The name of the tool that is being requested.

      - `tool_call_id: string`

        The ID of the tool call that is being requested.

      - `style?: MessageStyle`

        The style of the message. This is used by the client to determine how to display the message.

      - `type?: "tool_request"`

        The type of the message, in this case `tool_request`.

        - `"tool_request"`

    - `ToolResponseContent`

      - `author: MessageAuthor`

        The role of the messages author, in this case `system`, `user`, `assistant`, or `tool`.

      - `content: unknown`

        The result of the tool.

      - `name: string`

        The name of the tool that is being responded to.

      - `tool_call_id: string`

        The ID of the tool call that is being responded to.

      - `is_error?: boolean | null`

        Whether the tool call resulted in an error. `None` when the harness does not report a status.

      - `style?: MessageStyle`

        The style of the message. This is used by the client to determine how to display the message.

      - `type?: "tool_response"`

        The type of the message, in this case `tool_response`.

        - `"tool_response"`

  - `task_id: string`

    ID of the task this message belongs to

  - `id?: string | null`

    The task message's unique id

  - `created_at?: string | null`

    The timestamp when the message was created

  - `streaming_status?: "IN_PROGRESS" | "DONE" | null`

    - `"IN_PROGRESS"`

    - `"DONE"`

  - `updated_at?: string | null`

    The timestamp when the message was last updated

### Example

```typescript
import Agentex from 'agentex';

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

const taskMessages = await client.messages.batch.update({
  task_id: 'task_id',
  updates: {
    foo: {
      author: 'user',
      content: 'content',
      type: 'text',
    },
  },
});

console.log(taskMessages);
```

#### Response

```json
[
  {
    "content": {
      "author": "user",
      "content": "content",
      "attachments": [
        {
          "file_id": "file_id",
          "name": "name",
          "size": 0,
          "type": "type"
        }
      ],
      "format": "markdown",
      "style": "static",
      "type": "text"
    },
    "task_id": "task_id",
    "id": "id",
    "created_at": "2019-12-27T18:11:19.117Z",
    "streaming_status": "IN_PROGRESS",
    "updated_at": "2019-12-27T18:11:19.117Z"
  }
]
```

## Batch Create Messages

`client.messages.batch.create(BatchCreateParamsbody, RequestOptionsoptions?): BatchCreateResponse`

**post** `/messages/batch`

Batch Create Messages

### Parameters

- `body: BatchCreateParams`

  - `contents: Array<TaskMessageContent>`

    - `TextContent`

      - `author: MessageAuthor`

        The role of the messages author, in this case `system`, `user`, `assistant`, or `tool`.

        - `"user"`

        - `"agent"`

      - `content: string`

        The contents of the text message.

      - `attachments?: Array<Attachment> | null`

        Optional list of file attachments with structured metadata.

        - `file_id: string`

          The unique ID of the attached file

        - `name: string`

          The name of the file

        - `size: number`

          The size of the file in bytes

        - `type: string`

          The MIME type or content type of the file

      - `format?: TextFormat`

        The format of the message. This is used by the client to determine how to display the message.

        - `"markdown"`

        - `"plain"`

        - `"code"`

      - `style?: MessageStyle`

        The style of the message. This is used by the client to determine how to display the message.

        - `"static"`

        - `"active"`

      - `type?: "text"`

        The type of the message, in this case `text`.

        - `"text"`

    - `ReasoningContent`

      - `author: MessageAuthor`

        The role of the messages author, in this case `system`, `user`, `assistant`, or `tool`.

      - `summary: Array<string>`

        A list of short reasoning summaries

      - `content?: Array<string> | null`

        The reasoning content or chain-of-thought text

      - `style?: MessageStyle`

        The style of the message. This is used by the client to determine how to display the message.

      - `type?: "reasoning"`

        The type of the message, in this case `reasoning`.

        - `"reasoning"`

    - `DataContent`

      - `author: MessageAuthor`

        The role of the messages author, in this case `system`, `user`, `assistant`, or `tool`.

      - `data: Record<string, unknown>`

        The contents of the data message.

      - `style?: MessageStyle`

        The style of the message. This is used by the client to determine how to display the message.

      - `type?: "data"`

        The type of the message, in this case `data`.

        - `"data"`

    - `ToolRequestContent`

      - `arguments: Record<string, unknown>`

        The arguments to the tool.

      - `author: MessageAuthor`

        The role of the messages author, in this case `system`, `user`, `assistant`, or `tool`.

      - `name: string`

        The name of the tool that is being requested.

      - `tool_call_id: string`

        The ID of the tool call that is being requested.

      - `style?: MessageStyle`

        The style of the message. This is used by the client to determine how to display the message.

      - `type?: "tool_request"`

        The type of the message, in this case `tool_request`.

        - `"tool_request"`

    - `ToolResponseContent`

      - `author: MessageAuthor`

        The role of the messages author, in this case `system`, `user`, `assistant`, or `tool`.

      - `content: unknown`

        The result of the tool.

      - `name: string`

        The name of the tool that is being responded to.

      - `tool_call_id: string`

        The ID of the tool call that is being responded to.

      - `is_error?: boolean | null`

        Whether the tool call resulted in an error. `None` when the harness does not report a status.

      - `style?: MessageStyle`

        The style of the message. This is used by the client to determine how to display the message.

      - `type?: "tool_response"`

        The type of the message, in this case `tool_response`.

        - `"tool_response"`

  - `task_id: string`

  - `created_at?: string | null`

    Optional base timestamp. Each message in the batch is stamped with base + i milliseconds to guarantee unique, monotonic ordering. If omitted, the server stamps datetime.now(UTC) at insert time.

### Returns

- `BatchCreateResponse = Array<TaskMessage>`

  - `content: TaskMessageContent`

    The content of the message. This content is not OpenAI compatible. These are messages that are meant to be displayed to the user.

    - `TextContent`

      - `author: MessageAuthor`

        The role of the messages author, in this case `system`, `user`, `assistant`, or `tool`.

        - `"user"`

        - `"agent"`

      - `content: string`

        The contents of the text message.

      - `attachments?: Array<Attachment> | null`

        Optional list of file attachments with structured metadata.

        - `file_id: string`

          The unique ID of the attached file

        - `name: string`

          The name of the file

        - `size: number`

          The size of the file in bytes

        - `type: string`

          The MIME type or content type of the file

      - `format?: TextFormat`

        The format of the message. This is used by the client to determine how to display the message.

        - `"markdown"`

        - `"plain"`

        - `"code"`

      - `style?: MessageStyle`

        The style of the message. This is used by the client to determine how to display the message.

        - `"static"`

        - `"active"`

      - `type?: "text"`

        The type of the message, in this case `text`.

        - `"text"`

    - `ReasoningContent`

      - `author: MessageAuthor`

        The role of the messages author, in this case `system`, `user`, `assistant`, or `tool`.

      - `summary: Array<string>`

        A list of short reasoning summaries

      - `content?: Array<string> | null`

        The reasoning content or chain-of-thought text

      - `style?: MessageStyle`

        The style of the message. This is used by the client to determine how to display the message.

      - `type?: "reasoning"`

        The type of the message, in this case `reasoning`.

        - `"reasoning"`

    - `DataContent`

      - `author: MessageAuthor`

        The role of the messages author, in this case `system`, `user`, `assistant`, or `tool`.

      - `data: Record<string, unknown>`

        The contents of the data message.

      - `style?: MessageStyle`

        The style of the message. This is used by the client to determine how to display the message.

      - `type?: "data"`

        The type of the message, in this case `data`.

        - `"data"`

    - `ToolRequestContent`

      - `arguments: Record<string, unknown>`

        The arguments to the tool.

      - `author: MessageAuthor`

        The role of the messages author, in this case `system`, `user`, `assistant`, or `tool`.

      - `name: string`

        The name of the tool that is being requested.

      - `tool_call_id: string`

        The ID of the tool call that is being requested.

      - `style?: MessageStyle`

        The style of the message. This is used by the client to determine how to display the message.

      - `type?: "tool_request"`

        The type of the message, in this case `tool_request`.

        - `"tool_request"`

    - `ToolResponseContent`

      - `author: MessageAuthor`

        The role of the messages author, in this case `system`, `user`, `assistant`, or `tool`.

      - `content: unknown`

        The result of the tool.

      - `name: string`

        The name of the tool that is being responded to.

      - `tool_call_id: string`

        The ID of the tool call that is being responded to.

      - `is_error?: boolean | null`

        Whether the tool call resulted in an error. `None` when the harness does not report a status.

      - `style?: MessageStyle`

        The style of the message. This is used by the client to determine how to display the message.

      - `type?: "tool_response"`

        The type of the message, in this case `tool_response`.

        - `"tool_response"`

  - `task_id: string`

    ID of the task this message belongs to

  - `id?: string | null`

    The task message's unique id

  - `created_at?: string | null`

    The timestamp when the message was created

  - `streaming_status?: "IN_PROGRESS" | "DONE" | null`

    - `"IN_PROGRESS"`

    - `"DONE"`

  - `updated_at?: string | null`

    The timestamp when the message was last updated

### Example

```typescript
import Agentex from 'agentex';

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

const taskMessages = await client.messages.batch.create({
  contents: [
    {
      author: 'user',
      content: 'content',
      type: 'text',
    },
  ],
  task_id: 'task_id',
});

console.log(taskMessages);
```

#### Response

```json
[
  {
    "content": {
      "author": "user",
      "content": "content",
      "attachments": [
        {
          "file_id": "file_id",
          "name": "name",
          "size": 0,
          "type": "type"
        }
      ],
      "format": "markdown",
      "style": "static",
      "type": "text"
    },
    "task_id": "task_id",
    "id": "id",
    "created_at": "2019-12-27T18:11:19.117Z",
    "streaming_status": "IN_PROGRESS",
    "updated_at": "2019-12-27T18:11:19.117Z"
  }
]
```

## Domain Types

### Batch Update Response

- `BatchUpdateResponse = Array<TaskMessage>`

  - `content: TaskMessageContent`

    The content of the message. This content is not OpenAI compatible. These are messages that are meant to be displayed to the user.

    - `TextContent`

      - `author: MessageAuthor`

        The role of the messages author, in this case `system`, `user`, `assistant`, or `tool`.

        - `"user"`

        - `"agent"`

      - `content: string`

        The contents of the text message.

      - `attachments?: Array<Attachment> | null`

        Optional list of file attachments with structured metadata.

        - `file_id: string`

          The unique ID of the attached file

        - `name: string`

          The name of the file

        - `size: number`

          The size of the file in bytes

        - `type: string`

          The MIME type or content type of the file

      - `format?: TextFormat`

        The format of the message. This is used by the client to determine how to display the message.

        - `"markdown"`

        - `"plain"`

        - `"code"`

      - `style?: MessageStyle`

        The style of the message. This is used by the client to determine how to display the message.

        - `"static"`

        - `"active"`

      - `type?: "text"`

        The type of the message, in this case `text`.

        - `"text"`

    - `ReasoningContent`

      - `author: MessageAuthor`

        The role of the messages author, in this case `system`, `user`, `assistant`, or `tool`.

      - `summary: Array<string>`

        A list of short reasoning summaries

      - `content?: Array<string> | null`

        The reasoning content or chain-of-thought text

      - `style?: MessageStyle`

        The style of the message. This is used by the client to determine how to display the message.

      - `type?: "reasoning"`

        The type of the message, in this case `reasoning`.

        - `"reasoning"`

    - `DataContent`

      - `author: MessageAuthor`

        The role of the messages author, in this case `system`, `user`, `assistant`, or `tool`.

      - `data: Record<string, unknown>`

        The contents of the data message.

      - `style?: MessageStyle`

        The style of the message. This is used by the client to determine how to display the message.

      - `type?: "data"`

        The type of the message, in this case `data`.

        - `"data"`

    - `ToolRequestContent`

      - `arguments: Record<string, unknown>`

        The arguments to the tool.

      - `author: MessageAuthor`

        The role of the messages author, in this case `system`, `user`, `assistant`, or `tool`.

      - `name: string`

        The name of the tool that is being requested.

      - `tool_call_id: string`

        The ID of the tool call that is being requested.

      - `style?: MessageStyle`

        The style of the message. This is used by the client to determine how to display the message.

      - `type?: "tool_request"`

        The type of the message, in this case `tool_request`.

        - `"tool_request"`

    - `ToolResponseContent`

      - `author: MessageAuthor`

        The role of the messages author, in this case `system`, `user`, `assistant`, or `tool`.

      - `content: unknown`

        The result of the tool.

      - `name: string`

        The name of the tool that is being responded to.

      - `tool_call_id: string`

        The ID of the tool call that is being responded to.

      - `is_error?: boolean | null`

        Whether the tool call resulted in an error. `None` when the harness does not report a status.

      - `style?: MessageStyle`

        The style of the message. This is used by the client to determine how to display the message.

      - `type?: "tool_response"`

        The type of the message, in this case `tool_response`.

        - `"tool_response"`

  - `task_id: string`

    ID of the task this message belongs to

  - `id?: string | null`

    The task message's unique id

  - `created_at?: string | null`

    The timestamp when the message was created

  - `streaming_status?: "IN_PROGRESS" | "DONE" | null`

    - `"IN_PROGRESS"`

    - `"DONE"`

  - `updated_at?: string | null`

    The timestamp when the message was last updated

### Batch Create Response

- `BatchCreateResponse = Array<TaskMessage>`

  - `content: TaskMessageContent`

    The content of the message. This content is not OpenAI compatible. These are messages that are meant to be displayed to the user.

    - `TextContent`

      - `author: MessageAuthor`

        The role of the messages author, in this case `system`, `user`, `assistant`, or `tool`.

        - `"user"`

        - `"agent"`

      - `content: string`

        The contents of the text message.

      - `attachments?: Array<Attachment> | null`

        Optional list of file attachments with structured metadata.

        - `file_id: string`

          The unique ID of the attached file

        - `name: string`

          The name of the file

        - `size: number`

          The size of the file in bytes

        - `type: string`

          The MIME type or content type of the file

      - `format?: TextFormat`

        The format of the message. This is used by the client to determine how to display the message.

        - `"markdown"`

        - `"plain"`

        - `"code"`

      - `style?: MessageStyle`

        The style of the message. This is used by the client to determine how to display the message.

        - `"static"`

        - `"active"`

      - `type?: "text"`

        The type of the message, in this case `text`.

        - `"text"`

    - `ReasoningContent`

      - `author: MessageAuthor`

        The role of the messages author, in this case `system`, `user`, `assistant`, or `tool`.

      - `summary: Array<string>`

        A list of short reasoning summaries

      - `content?: Array<string> | null`

        The reasoning content or chain-of-thought text

      - `style?: MessageStyle`

        The style of the message. This is used by the client to determine how to display the message.

      - `type?: "reasoning"`

        The type of the message, in this case `reasoning`.

        - `"reasoning"`

    - `DataContent`

      - `author: MessageAuthor`

        The role of the messages author, in this case `system`, `user`, `assistant`, or `tool`.

      - `data: Record<string, unknown>`

        The contents of the data message.

      - `style?: MessageStyle`

        The style of the message. This is used by the client to determine how to display the message.

      - `type?: "data"`

        The type of the message, in this case `data`.

        - `"data"`

    - `ToolRequestContent`

      - `arguments: Record<string, unknown>`

        The arguments to the tool.

      - `author: MessageAuthor`

        The role of the messages author, in this case `system`, `user`, `assistant`, or `tool`.

      - `name: string`

        The name of the tool that is being requested.

      - `tool_call_id: string`

        The ID of the tool call that is being requested.

      - `style?: MessageStyle`

        The style of the message. This is used by the client to determine how to display the message.

      - `type?: "tool_request"`

        The type of the message, in this case `tool_request`.

        - `"tool_request"`

    - `ToolResponseContent`

      - `author: MessageAuthor`

        The role of the messages author, in this case `system`, `user`, `assistant`, or `tool`.

      - `content: unknown`

        The result of the tool.

      - `name: string`

        The name of the tool that is being responded to.

      - `tool_call_id: string`

        The ID of the tool call that is being responded to.

      - `is_error?: boolean | null`

        Whether the tool call resulted in an error. `None` when the harness does not report a status.

      - `style?: MessageStyle`

        The style of the message. This is used by the client to determine how to display the message.

      - `type?: "tool_response"`

        The type of the message, in this case `tool_response`.

        - `"tool_response"`

  - `task_id: string`

    ID of the task this message belongs to

  - `id?: string | null`

    The task message's unique id

  - `created_at?: string | null`

    The timestamp when the message was created

  - `streaming_status?: "IN_PROGRESS" | "DONE" | null`

    - `"IN_PROGRESS"`

    - `"DONE"`

  - `updated_at?: string | null`

    The timestamp when the message was last updated
