---
title: "Add correlation."
method: POST
path: "/datasources/uid/{sourceUID}/correlations"
tags: ["datasources", "correlations"]
---

# Add correlation.

`POST /datasources/uid/{sourceUID}/correlations`

## Path parameters

- `sourceUID` string, required

## Request body

- CreateCorrelationCommand — CreateCorrelationCommand is the command for creating a correlation
  - `config` CorrelationConfig
    - `field` string, required — Field used to attach the correlation link
    - `target` object, required — Target data query
    - `transformations` Transformation[]
      - `expression` string
      - `field` string
      - `mapValue` string
      - `type` 'regex' | 'logfmt'
    - `type` string — the type of correlation, either query for containing query information, or external for containing an external URL +enum
  - `description` string — Optional description of the correlation
  - `label` string — Optional label identifying the correlation
  - `provisioned` boolean — True if correlation was created with provisioning. This makes it read-only.
  - `targetUID` string — Target data source UID to which the correlation is created. required if type = query
  - `type` string — the type of correlation, either query for containing query information, or external for containing an external URL +enum

## Response `200`

(empty)

- CreateCorrelationResponseBody — CreateCorrelationResponse is the response struct for CreateCorrelationCommand
  - `message` string
  - `result` Correlation — Correlation is the model for correlations definitions
    - `config` CorrelationConfig
      - `field` string, required — Field used to attach the correlation link
      - `target` object, required — Target data query
      - `transformations` Transformation[]
        - `expression` string
        - `field` string
        - `mapValue` string
        - `type` 'regex' | 'logfmt'
      - `type` string — the type of correlation, either query for containing query information, or external for containing an external URL +enum
    - `description` string — Description of the correlation
    - `label` string — Label identifying the correlation
    - `orgId` integer — OrgID of the data source the correlation originates from
    - `provisioned` boolean — Provisioned True if the correlation was created during provisioning
    - `sourceUID` string — UID of the data source the correlation originates from
    - `targetUID` string — UID of the data source the correlation points to
    - `type` string — the type of correlation, either query for containing query information, or external for containing an external URL +enum
    - `uid` string — Unique identifier of the correlation

## Other responses

- `400` — BadRequestError is returned when the request is invalid and it cannot be processed.
- `401` — UnauthorizedError is returned when the request is not authenticated.
- `403` — ForbiddenError is returned if the user/token has insufficient permissions to access the requested resource.
- `404` — NotFoundError is returned when the requested resource was not found.
- `500` — InternalServerError is a general error indicating something went wrong internally.

---

[API](https://skmtc.net/grafana/apis/http-api.md) · [All operations](https://skmtc.net/grafana/apis/http-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/grafana/http-api/revisions/df55ba1718ba/schema)
