Grafana Cloud

Labels REST API

Note

The documentation for this API is also available as an OpenAPI description.

List label keys

GET /cloud/v6/labels

List all label keys (accessible by all authenticated users).

Request parameters

NameDescriptionInRequiredType
X-Stack-Id

Numeric ID of the Grafana stack representing the request scope.

  • If the API is called with a Personal API token, the user must be a member of the specified stack.
  • If the API is called with a Grafana Stack API token, the value must be the ID of the corresponding stack.
headertrueinteger

200 response

OK.

Content types: application/json
OK example
[
  {
    "value": [
      {
        "description": "Environment being tested",
        "id": 1,
        "key": "environment"
      },
      {
        "description": "Team responsible for the project",
        "id": 2,
        "key": "team"
      }
    ]
  }
]

401 response

Invalid token or authentication scheme.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null

403 response

The user does not have permission to perform this action.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null

500 response

Unexpected error.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null

Create label keys

POST /cloud/v6/labels

Creates one or more label keys for the organization.

This operation is additive: it adds the new labels to the existing ones without replacing them.

Request parameters

NameDescriptionInRequiredType
X-Stack-Id

Numeric ID of the Grafana stack representing the request scope.

  • If the API is called with a Personal API token, the user must be a member of the specified stack.
  • If the API is called with a Grafana Stack API token, the value must be the ID of the corresponding stack.
headertrueinteger

Request body

Content types: application/json

Request to create one or more label keys

LabelKeyCreateRequest properties:

NameDescriptionRequiredType
valueArray of label keys to create (1-100).trueArray[LabelKeyCreateItem]

Single label key to create

LabelKeyCreateItem properties:

NameDescriptionRequiredType
descriptionOptional description of the label key.falsestring | null
keyLabel key name. Case-sensitive. Unique per organization.truestring
Create example
{
  "value": [
    {
      "description": "Environment being tested",
      "key": "environment"
    },
    {
      "description": "Team responsible for the project",
      "key": "team"
    },
    {
      "key": "cost_center"
    }
  ]
}

201 response

OK.

Content types: application/json

Response for listing label keys

LabelKeyListResponse properties:

NameDescriptionRequiredType
valueList of label keys.trueArray[LabelKeyResponse]

Label key response model

LabelKeyResponse properties:

NameDescriptionRequiredType
descriptionLabel key description.falsestring | null
idLabel key ID.trueinteger
keyLabel key name.truestring
Created example
{
  "value": [
    {
      "description": "Environment being tested",
      "id": 1,
      "key": "environment"
    },
    {
      "description": "Team responsible for the project",
      "id": 2,
      "key": "team"
    },
    {
      "description": null,
      "id": 3,
      "key": "cost_center"
    }
  ]
}

400 response

Duplicate keys in request.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null

401 response

Invalid token or authentication scheme.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null

403 response

The user does not have permission to perform this action.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null

409 response

Maximum number of label keys (100) exceeded.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null

500 response

Unexpected error.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null

Delete a label key

DELETE /cloud/v6/labels/{id}

Delete a label key (Admin only).

When a label key is deleted, all project labels using this key are cascade deleted.

Request parameters

NameDescriptionInRequiredType
X-Stack-Id

Numeric ID of the Grafana stack representing the request scope.

  • If the API is called with a Personal API token, the user must be a member of the specified stack.
  • If the API is called with a Grafana Stack API token, the value must be the ID of the corresponding stack.
headertrueinteger
idID of the label key.pathtrueinteger

204 response

OK.

401 response

Invalid token or authentication scheme.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null

403 response

The user does not have permission to perform this action.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null

404 response

Label key not found.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null

500 response

Unexpected error.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null

Update a label key

PATCH /cloud/v6/labels/{id}

Update a label key (rename or update description) (Admin only).

Request parameters

NameDescriptionInRequiredType
X-Stack-Id

Numeric ID of the Grafana stack representing the request scope.

  • If the API is called with a Personal API token, the user must be a member of the specified stack.
  • If the API is called with a Grafana Stack API token, the value must be the ID of the corresponding stack.
headertrueinteger
idID of the label key.pathtrueinteger

Request body

Content types: application/json

Request to update a label key

LabelKeyPatchRequest properties:

NameDescriptionRequiredType
descriptionNew label key description.falsestring | null
keyNew label key name.falsestring | null
RenameKey example
{
  "key": "env"
}
UpdateBoth example
{
  "description": "Environment (dev, prod)",
  "key": "env"
}
UpdateDescription example
{
  "description": "Environment (dev, prod)"
}

200 response

OK.

Content types: application/json

Label key response model

LabelKeyResponse properties:

NameDescriptionRequiredType
descriptionLabel key description.falsestring | null
idLabel key ID.trueinteger
keyLabel key name.truestring
OK example
{
  "description": "Environment (dev, prod)",
  "id": 1,
  "key": "env"
}

400 response

Request validation error.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null

401 response

Invalid token or authentication scheme.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null

403 response

The user does not have permission to perform this action.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null

404 response

Label key not found.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null

409 response

Label key with new name already exists.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null

500 response

Unexpected error.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null

List project labels

GET /cloud/v6/projects/{project_id}/labels

List all labels on a project.

Request parameters

NameDescriptionInRequiredType
X-Stack-Id

Numeric ID of the Grafana stack representing the request scope.

  • If the API is called with a Personal API token, the user must be a member of the specified stack.
  • If the API is called with a Grafana Stack API token, the value must be the ID of the corresponding stack.
headertrueinteger
project_idID of the project.pathtrueinteger

200 response

OK.

Content types: application/json
OK example
[
  {
    "value": [
      {
        "key": "environment",
        "value": "production"
      },
      {
        "key": "team",
        "value": "backend"
      }
    ]
  }
]

401 response

Invalid token or authentication scheme.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null

403 response

The user does not have permission to perform this action.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null

404 response

Resource not found.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null

500 response

Unexpected error.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null

Replace project labels

PUT /cloud/v6/projects/{project_id}/labels

Replace labels on a project (Admin or Editor).

This is a full replacement operation.

Request parameters

NameDescriptionInRequiredType
X-Stack-Id

Numeric ID of the Grafana stack representing the request scope.

  • If the API is called with a Personal API token, the user must be a member of the specified stack.
  • If the API is called with a Grafana Stack API token, the value must be the ID of the corresponding stack.
headertrueinteger
project_idID of the project.pathtrueinteger

Request body

Content types: application/json

Request to replace project labels.

This is a full replacement of all labels on the project.

ProjectLabelPutRequest properties:

NameDescriptionRequiredType
valueArray of labels to assign (0-30).trueArray[ProjectLabelPutItem]

Single project label for PUT request

ProjectLabelPutItem properties:

NameDescriptionRequiredType
keyLabel key name. Mutually exclusive with ‘key_id’.falsestring | null
key_idLabel key ID. Mutually exclusive with ‘key’.falseinteger | null
valueLabel value.truestring
ReplaceLabelsUsingKey example
{
  "value": [
    {
      "key": "provider",
      "value": "aws"
    }
  ]
}
ReplaceLabelsUsingKeyId example
{
  "value": [
    {
      "key_id": 1,
      "value": "aws"
    }
  ]
}

200 response

OK.

Content types: application/json

Response for PUT project labels

ProjectLabelPutResponse properties:

NameDescriptionRequiredType
valueList of project labels.trueArray[ProjectLabelPutResponseItem]

Single project label in PUT response

ProjectLabelPutResponseItem properties:

NameDescriptionRequiredType
keyLabel key name.truestring
key_idLabel key ID.trueinteger
valueLabel value.truestring
OK example
{
  "value": [
    {
      "key": "provider",
      "key_id": 1,
      "value": "aws"
    }
  ]
}

400 response

Invalid label key ID or name, or duplicate keys in request.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null

401 response

Invalid token or authentication scheme.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null

403 response

The user does not have permission to perform this action.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null

404 response

Project not found.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null

409 response

Max labels per project (30) or max unique pairs per organization (500) exceeded.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null

500 response

Unexpected error.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null

Remove a label from project

DELETE /cloud/v6/projects/{project_id}/labels/{key}

Remove a label from a project (Admin or Editor).

Request parameters

NameDescriptionInRequiredType
X-Stack-Id

Numeric ID of the Grafana stack representing the request scope.

  • If the API is called with a Personal API token, the user must be a member of the specified stack.
  • If the API is called with a Grafana Stack API token, the value must be the ID of the corresponding stack.
headertrueinteger
keyLabel key name.pathtruestring
project_idID of the project.pathtrueinteger

204 response

OK.

401 response

Invalid token or authentication scheme.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null

403 response

The user does not have permission to perform this action.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null

404 response

Label key not found on project.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null

500 response

Unexpected error.

Content types: application/json

ErrorResponseApiModel properties:

NameDescriptionRequiredType
errortrueErrorApiModel

Details of the error.

ErrorApiModel properties:

NameDescriptionRequiredType
codeService-defined error code.truestring
detailsArray of objects with more specific error information when applicable.falsearray | null
messageHuman-readable string describing the error.truestring
targetA string indicating the target of the error. For example, the name of the property in error.falsestring | null