HTTP APIs for external systems
The Grafana Assistant HTTP APIs enable external systems to create conversations, check status, and stream responses programmatically.
Warning
The HTTP APIs are experimental and subject to change. Use them for prototyping and testing, but be aware that breaking changes may occur in future releases.
What you’ll achieve
This article shows you how to authenticate and call the HTTP APIs to start chats, check status, and receive streamed updates:
- Authenticate requests: Use a service account token in the
Authorizationheader. - Start a chat: Create or continue a conversation and get a
chatId. - Check status: Retrieve chat metadata and messages.
- Stream responses: Subscribe to real-time updates with Server-Sent Events.
- Handle errors and limits: Interpret standard error responses and rate limits.
Before you begin
Confirm these prerequisites:
- A Grafana Cloud stack with the Grafana Assistant app installed and enabled.
- A service account token with at least the Editor role.
- Your base URL for the plugin proxy path.
- A tool to make HTTP requests, for example,
curlor a language HTTP client.
When to use the HTTP APIs
Use the HTTP APIs when:
- Integrating Grafana Assistant from external systems
- Automating observability workflows with scripts
- Building custom interfaces that interact with Assistant
- Creating programmatic agents that leverage Assistant capabilities
Authenticate requests
All API requests require authentication using a Grafana service account token.
Create a service account token
- Sign in to Grafana as an administrator
- Navigate to Administration > Service accounts
- Create a new service account or select an existing one
- Assign the Editor role (required for Assistant actions)
- Generate a token and copy it securely
Include the token in requests
Add the token to the Authorization header:
Authorization: Bearer glsa_YOUR_SERVICE_ACCOUNT_TOKENNote
Service account tokens are not required for incoming or outgoing webhooks. Learn more in the Grafana service accounts documentation.
Use API endpoints
All API endpoints are accessed through the Grafana plugin proxy:
https://your-stack.grafana.net/api/plugins/grafana-assistant-app/resources/api/v1/Start or continue a chat
Create a new conversation with the Assistant or continue an existing one.
Endpoint: POST /assistant/chats
Request body:
{
"prompt": "How many datasources do I have?",
"chatId": "optional-existing-chat-id"
}Parameters:
prompt(required): The task or question for the AssistantchatId(optional): Continue an existing conversation
Example:
curl -X POST "https://your-stack.grafana.net/api/plugins/grafana-assistant-app/resources/api/v1/assistant/chats" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{
"prompt": "How many datasources do I have?"
}'Response:
{
"status": "success",
"data": {
"chatId": "18289896-b393-4136-9014-c2630a62f67f"
}
}Use the returned chatId to check status or stream responses.
Check chat status
Retrieve the current state and messages for a chat.
Endpoint: GET /chats/{chatId}
Example:
curl -X GET "https://your-stack.grafana.net/api/plugins/grafana-assistant-app/resources/api/v1/chats/18289896-b393-4136-9014-c2630a62f67f" \
-H "Authorization: Bearer YOUR_TOKEN"Response:
{
"id": "18289896-b393-4136-9014-c2630a62f67f",
"name": "Assistant Conversation",
"created": "2025-10-20T10:30:00Z",
"modified": "2025-10-20T10:35:00Z",
"userId": "user@example.com",
"category": "assistant",
"messages": [
{
"id": "msg-1",
"role": "user",
"content": [
{
"type": "text",
"text": "How many datasources do I have?"
}
],
"timestamp": "2025-10-20T10:30:00Z"
},
{
"id": "msg-2",
"role": "assistant",
"content": [
{
"type": "text",
"text": "You have 5 datasources configured..."
}
],
"timestamp": "2025-10-20T10:35:00Z"
}
]
}Stream responses
Subscribe to real-time updates using Server-Sent Events (SSE).
Endpoint: GET /api/events/chats/{chatId}. The SSE endpoint uses a different base path than standard APIs.
Example (JavaScript):
const eventSource = new EventSource(
'https://your-stack.grafana.net/api/plugins/grafana-assistant-app/resources/api/events/chats/18289896-b393-4136-9014-c2630a62f67f'
);
eventSource.addEventListener('message', (event) => {
const data = JSON.parse(event.data);
console.log('Event:', data.type, data.data);
});
eventSource.addEventListener('error', (error) => {
console.error('SSE Error:', error);
eventSource.close();
});Event types:
MESSAGE_CREATED: New messages added to the conversationMESSAGE_UPDATED: Streaming message updates (real-time text generation)AGENT_EXECUTION_STARTED: Agent begins working on the taskAGENT_EXECUTION_COMPLETED: Agent finishes successfullyAGENT_EXECUTION_FAILED: Agent encounters an errorREMOTE_TOOL_REQUEST: Agent requests frontend tool execution
Test APIs interactively
For live API testing:
- Open Grafana Assistant from the main navigation
- Click the For developers button
- Navigate to the HTTP API section for:
- Live API testing directly from your browser
- Interactive forms to test each endpoint
- Real-time SSE streaming visualization
- Copy-to-clipboard cURL examples
Handle errors
API errors return standard HTTP status codes:
400 Bad Request: Invalid request parameters401 Unauthorized: Missing or invalid authentication token403 Forbidden: Insufficient permissions404 Not Found: Chat ID not found429 Too Many Requests: Rate limit exceeded500 Internal Server Error: Server-side error
Error responses include a message:
{
"status": "error",
"message": "Chat not found"
}Understand rate limits
API requests are subject to rate limits based on your Grafana Cloud plan. Monitor the response headers for rate limit information:
X-RateLimit-Limit: Maximum requests per windowX-RateLimit-Remaining: Remaining requests in current windowX-RateLimit-Reset: Time when the rate limit resets
What’s next
Continue exploring and testing the APIs:
- Open Grafana Assistant and click For developers to try interactive API examples
- Learn about service account tokens
- Review Grafana HTTP API documentation



