---
title: "Create a message"
method: POST
path: "/messages/"
tags: ["Message"]
---

# Create a message

`POST /messages/`

## Request

- Base URL: `https://api.your-domain.com`
- URL: `https://api.your-domain.com/messages/`
- Auth: API key in header `X-API-KEY`
- TypeScript: <https://skmtc.dev/neulandai/apis/neuland-ai-hub-api/docs/messages/post.ts> (a function with typed inputs; its response is checked against the schema)

Send a JSON message to a chat (or start a new one) and enqueue generation.

## Query parameters

- `cookie_name` string, nullable

## Request body

- MessageIn
  - `content` string, nullable: Text content of the user message.
  - `chat_id` integer, nullable: ID of an existing chat to post into; omit to start a new chat.
  - `updated_at` string, date-time, nullable: Last-known chat timestamp, used for optimistic concurrency.
  - `project_id` integer, nullable: ID of the project to associate a new chat with.
  - `model` string, nullable: Name of the LLM model to use for a new chat.
  - `temperature` number, nullable: Sampling temperature for a new chat.
  - `similarity_top_k` integer, nullable: Number of top similar chunks to retrieve for a new chat.
  - `system_prompt` string, nullable: System prompt for a new chat.
  - `assistant_id` integer, nullable: ID of an assistant to drive a new chat.
  - `private` boolean, nullable: Whether a new chat is private to its creator.
  - `form_data` object, nullable: Form submission data, accepted only when starting a new chat with a form-input assistant.

## Response `200`

Successful Response

- Message
  - `state` string, nullable: Current lifecycle state of the record.
  - `state_reason` string, nullable: Optional explanation for the current state.
  - `state_changed_at` string, date-time, nullable: UTC timestamp when the state last changed.
  - `id` integer, nullable: Primary key for the message.
  - `created_at` string, date-time: Timestamp when the message was created.
  - `updated_at` string, date-time: Timestamp when the message was last updated.
  - `creator_user_id` integer, required: ID of the user who created the message.
  - `chat_id` integer, required: ID of the chat the message belongs to.
  - `role` string, required: Role of the message author (see llama-index MessageRole values).
  - `content` string, required: Rendered content of the message.
  - `sent_user_msg` string, nullable, required: Original user-sent message text, if applicable.
  - `parent_id` integer, nullable, required: ID of the parent message in a threaded conversation.
  - `completed` boolean: DEPRECATED. Whether the message has finished processing.
  - `error` string, nullable, required: DEPRECATED. Error message captured during processing, if any.
  - `hint` string, nullable, required: Hint shown to the user about the next action.
  - `llm_catalog_id` integer, nullable: ID of the LLM catalog entry used for this message.
  - `llm_settings_id` integer, nullable: ID of the LLM settings used for this message.
  - `usage` object, nullable: Token usage metadata recorded for this message.
  - `celery_task_id` string, nullable: ID of the Celery task processing this message, if any.

## Other responses

- `401`: Missing or invalid authentication.
- `403`: No access to the chat/project/assistant, or usage budget exceeded.
- `404`: Referenced chat or assistant does not exist.
- `422`: Validation Error

---

[API](https://skmtc.dev/neulandai/apis/neuland-ai-hub-api.md) - [All operations](https://skmtc.dev/neulandai/apis/neuland-ai-hub-api/llms.txt) - [OpenAPI document](https://skmtc.dev/neulandai/apis/neuland-ai-hub-api/revisions/b53e89b98c2b?raw)
