Save Grafana tool connection¶
Save the Grafana tool connection for the current workspace. The service account token is only used to establish or update credentials, and the token will not be echoed in a successful response.
POST $CLOUDSIGMA_API_BASE/workspaces/{workspace_id}/tools/grafana/connect
Before you call¶
Configure the CloudSigma regional endpoint and authentication before calling. The endpoint, credentials, workspace, and resource IDs must belong to the same region. Prepare a personal access token and target workspace ID that can access the target workspace.
Request body¶
curl -X POST "$CLOUDSIGMA_API_BASE/workspaces/$WORKSPACE_ID/tools/grafana/connect" \
-H "X-API-Key: $CLOUDSIGMA_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"grafana_url": "https://grafana.example.com",
"service_account_token": "<SERVICE_ACCOUNT_TOKEN>"
}'
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
Current workspace ID. |
|
string |
Yes |
Grafana base URL, the protocol can only be |
|
string |
Yes |
The Grafana service account token itself should not contain the |
Successful response¶
{
"code": 0,
"data": {
"tool_id": "moi.grafana.tools",
"grafana_url": "https://grafana.example.com",
"credential_ref": "cred_01",
"status": "connected",
"connected_at": "2026-01-02T15:04:05Z",
"requires_reconnect": false
}
}
Returns 200 on success. Reconnecting will update the Grafana connection in the workspace.
Field |
Type |
Description |
|---|---|---|
|
integer |
|
|
string |
Grafana built-in tool identifier. |
|
string |
Saved Grafana base URL. |
|
string |
A reference to a saved credential, not a service account token. |
|
string |
Connection status and whether reconnection is required. |
|
boolean |
Connection status and whether reconnection is required. |
|
string |
The time the connection was established, using RFC 3339 format. |
Error response¶
{
"code": 2,
"message": "<错误信息>"
}
Common HTTP errors
HTTP status code |
error code |
Description |
|---|---|---|
|
|
Common reasons: The URL, service account token, or request body is invalid. Recommended Action: Use Grafana base URL without credentials and |
|
|
Common Cause: Valid identity credentials are missing. Recommended Action: Check the API Key. |
|
|
Common reasons: The current identity does not have the permission to manage tool connections in the workspace. Recommended Action: Check the workspace authorization. |
|
|
Common reasons: The Grafana tool connection service or authorization dependency is temporarily unavailable. Recommended Action: Try again later. |