---
title: aiThreadMessage query | Wartiva GraphQL API
description: Sends a message to an AI chat thread and returns the assistant's reply. Wartiva GraphQL API reference with arguments, fields, and examples.
url: https://wartiva.com/api-docs/queries/ai-thread-message.html
updated: 2026-10-07
---

AI · GraphQL query

# `aiThreadMessage` query

Sends a message to an AI chat thread and returns the assistant's reply. The thread's type, set when it was created with [aiThreadCreate](https://wartiva.com/api-docs/queries/ai-thread-create.html), decides how the message is handled: general conversation, search-query generation, search questions, GraphQL-query generation, or questions about one object. `timeRange` and `locationFilter` apply only to the search thread types. Both the message and the reply are stored on the thread. Returns an error when the AI service is not available; check [aiStatus](https://wartiva.com/api-docs/queries/ai-status.html).

## Response

Returns an [`AiThreadEntry!`](https://wartiva.com/api-docs/types/ai-thread-entry.html)

## Arguments

| Name | Description |
|---|---|
| `threadId` - [`AiThreadId!`](https://wartiva.com/api-docs/types/ai-thread-id.html) | The thread ID. |
| `message` - [`String!`](https://wartiva.com/api-docs/types/string.html) | Natural language input to base the query generation on. |
| `timeRange` - [`DateTimeRangeInput`](https://wartiva.com/api-docs/types/date-time-range-input.html) | The time range to filter objects in the query. If not provided, the default is the last 30 days. |
| `locationFilter` - [`LocationFilterInput`](https://wartiva.com/api-docs/types/location-filter-input.html) | Limits the search results to objects matching the location search input. |
| `aiModel` - [`AiModelInput`](https://wartiva.com/api-docs/types/ai-model-input.html) | Optionally specify AI model to utilize. |

## Example

### Query

```graphql
query aiThreadMessage(
  $threadId: AiThreadId!,
  $message: String!,
  $timeRange: DateTimeRangeInput,
  $locationFilter: LocationFilterInput,
  $aiModel: AiModelInput
) {
  aiThreadMessage(
    threadId: $threadId,
    message: $message,
    timeRange: $timeRange,
    locationFilter: $locationFilter,
    aiModel: $aiModel
  ) {
    timestamp
    isFromUser
    message
  }
}

```

### Variables

```json
{
  "threadId": AiThreadId,
  "message": "abc123",
  "timeRange": DateTimeRangeInput,
  "locationFilter": LocationFilterInput,
  "aiModel": AiModelInput
}

```

### Response

```json
{
  "data": {
    "aiThreadMessage": {
      "timestamp": "2021-10-07T18:23:25.829Z",
      "isFromUser": true,
      "message": "abc123"
    }
  }
}

```

## Related operations

- [`aiGenerateGraphQLQuery`](https://wartiva.com/api-docs/queries/ai-generate-graphql-query.html) query: Asks the AI assistant to write a Wartiva GraphQL query from a natural-language request, for the object type the thread was created with (see…
- [`aiGenerateSearchQuery`](https://wartiva.com/api-docs/queries/ai-generate-search-query.html) query: Asks the AI assistant to turn a natural-language request into a graph search query, such as "Windows endpoints with an unencrypted disk", that can…
- [`aiQueryObject`](https://wartiva.com/api-docs/queries/ai-query-object.html) query: Asks the AI assistant a natural-language question about the specific graph object the thread was created for (see aiThreadCreate with an object id).
- [`aiQuerySearch`](https://wartiva.com/api-docs/queries/ai-query-search.html) query: Asks the AI assistant a natural-language question that it answers by searching the security graph, for example "which endpoints have not reported in…

---

Wartiva is in early access. Request access: https://wartiva.com/early-access.html  
All pages: https://wartiva.com/llms.txt
