Grafana Cloud

Conversations API

Use conversations to start, continue, inspect, and stream Assistant interactions.

Examples use the base URL and service account token described in Grafana Assistant HTTP API reference.

Start or continue a conversation

Create a new conversation with the Assistant or continue an existing one.

Endpoint

POST /assistant/chats

Permissions

The service account must have these Assistant RBAC permissions:

  • grafana-assistant-app.chats:access

The service account also needs any Grafana RBAC permissions required by the prompt, such as data source query or dashboard read permissions.

Request

Send a JSON request body.

FieldRequiredDescription
promptYesThe task or question for Assistant.
chatIdNoThe ID of an existing conversation to continue.
JSON
{
  "prompt": "How many datasources do I have?",
  "chatId": "optional-existing-chat-id"
}

Response

The response includes the conversation ID to use when fetching messages or streaming events.

JSON
{
  "status": "success",
  "data": {
    "chatId": "18289896-b393-4136-9014-c2630a62f67f"
  }
}

Examples

Bash
curl -X POST "${ASSISTANT_API_URL}/assistant/chats" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${SERVICE_ACCOUNT_TOKEN}" \
  -d '{
    "prompt": "How many datasources do I have?"
  }'

Use the returned chatId to fetch messages or stream chat events.

Only one Assistant task can be active for an existing chat. If you submit another request while a task is running, the API returns HTTP 409 Conflict. Wait for the active task to finish before retrying.

Caution

Automation runs can’t be continued with this endpoint: the reply doesn’t use the run’s earlier messages, and it doesn’t appear when you read the conversation. Continue them in Assistant Workspace.

Fetch conversation messages

Retrieve the current chat metadata and messages.

Endpoint

GET /chats/{chatId}

Permissions

The service account must have these Assistant RBAC permissions:

  • grafana-assistant-app.chats:access

Request

ParameterRequiredDescription
chatIdYesThe conversation ID returned when you start or continue a conversation.

Response

The response includes conversation metadata and messages. For a conversation that an automation run created, the response also includes automationId, but only when the caller can see that automation.

JSON
{
  "status": "success",
  "data": {
    "id": "18289896-b393-4136-9014-c2630a62f67f",
    "name": "Assistant Conversation",
    "created": "2025-10-20T10:30:00Z",
    "modified": "2025-10-20T10:35:00Z",
    "userId": "sa-5594@serviceaccount.grafana",
    "category": "assistant",
    "messages": [
      {
        "id": "msg-1",
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "How many datasources do I have?"
          }
        ]
      },
      {
        "id": "msg-2",
        "role": "assistant",
        "content": [
          {
            "type": "text",
            "text": "You have 5 datasources configured..."
          }
        ]
      }
    ]
  }
}

Examples

Bash
CHAT_ID="18289896-b393-4136-9014-c2630a62f67f"

curl -X GET "${ASSISTANT_API_URL}/chats/${CHAT_ID}" \
  -H "Authorization: Bearer ${SERVICE_ACCOUNT_TOKEN}"

Fetch the full transcript

Retrieve every message in a conversation, including automation runs and investigations started through the API.

Endpoint

GET /chats/{chatId}/all-messages

Permissions

The service account must have these Assistant RBAC permissions:

  • grafana-assistant-app.chats:access

Request

ParameterRequiredDescription
chatIdYesThe conversation ID.

Response

The response lists the messages in order in data.messages. Each message includes its role, content, sequence, and an audience. Messages whose audience isn’t user, and messages with hidden set to true, hold Assistant’s internal work; skip them to show the conversation people see. In some conversations, a tool call and its result are in the same assistant message, and several entries can share an id, so don’t use id as a unique key.

JSON
{
  "status": "success",
  "data": {
    "messages": [
      {
        "id": "msg-1",
        "role": "user",
        "audience": "user",
        "sequence": 1,
        "content": [
          {
            "type": "text",
            "text": "How many datasources do I have?"
          }
        ]
      },
      {
        "id": "msg-2",
        "role": "assistant",
        "audience": "user",
        "sequence": 2,
        "content": [
          {
            "type": "text",
            "text": "You have 5 datasources configured..."
          }
        ]
      }
    ]
  }
}

Examples

Bash
CHAT_ID="18289896-b393-4136-9014-c2630a62f67f"

curl -X GET "${ASSISTANT_API_URL}/chats/${CHAT_ID}/all-messages" \
  -H "Authorization: Bearer ${SERVICE_ACCOUNT_TOKEN}"

Stream chat events

Subscribe to real-time conversation updates using SSE.

Endpoint

GET /api/events/chats/{chatId}

This endpoint uses a different base path than standard api/v1 endpoints:

https://your-stack.grafana.net/api/plugins/grafana-assistant-app/resources/api/events/chats/{chatId}

The example uses ASSISTANT_EVENTS_URL as shorthand for the events base URL:

Bash
ASSISTANT_EVENTS_URL="https://your-stack.grafana.net/api/plugins/grafana-assistant-app/resources/api/events"

Permissions

The service account must have these Assistant RBAC permissions:

  • grafana-assistant-app.chats:access

Request

ParameterRequiredDescription
chatIdYesThe conversation ID returned when you start or continue a conversation.

Response

The response is an SSE stream. Listen for the event types your integration needs, and ignore event types you don’t recognize.

Conversations you start with POST /assistant/chats send these events:

Event typeDescription
message.createdA new message is added to the conversation.
message.stream.startA message starts streaming.
message.content.deltaAn incremental update to message content.
message.stream.completeA message finishes streaming.
AGENT_STARTEDAssistant begins working on the task.
AGENT_COMPLETEDAssistant finishes successfully.
AGENT_FAILEDAssistant encounters an error.
REMOTE_TOOL_REQUESTAssistant requests frontend tool execution.

Automation runs don’t send message content or AGENT_* events, so an integration that waits for AGENT_COMPLETED doesn’t finish. To follow an automation run, refetch the full transcript when you receive an event, and poll it as a fallback.

Examples

Bash
CHAT_ID="18289896-b393-4136-9014-c2630a62f67f"

curl -N "${ASSISTANT_EVENTS_URL}/chats/${CHAT_ID}" \
  -H "Authorization: Bearer ${SERVICE_ACCOUNT_TOKEN}" \
  -H "Accept: text/event-stream"

For integration examples:

  1. Navigate to AI > Assistant in the main menu.
  2. Click Integration hub.
  3. Review the SDK and integration examples. Direct HTTP API testing may not be available from the Integration hub.