---
title: "Create PR for custom metrics"
method: POST
path: "/api/v1/projects/{projectUuid}/git-integration/pull-requests/custom-metrics"
tags: ["Git Integration"]
---

# Create PR for custom metrics

`POST /api/v1/projects/{projectUuid}/git-integration/pull-requests/custom-metrics`

Create a pull request for custom metrics

## Path parameters

- `projectUuid` string, required

## Request body

- object
  - `quoteChar` '"' | '''
  - `customMetrics` AdditionalMetric[], required
    - `label` string — Display label for the metric
    - `type` 'percentile' | 'average' | 'count' | 'count_distinct' | 'sum' | 'sum_distinct' | 'average_distinct' | 'min' | 'max' | 'percent_of_previous' | 'percent_of_total' | 'running_total' | 'number' | 'median' | 'string' | 'date' | 'timestamp' | 'boolean', required
    - `description` string — Description of what the metric measures
    - `sql` string, required — SQL expression (e.g., ${TABLE}.column_name)
    - `hidden` boolean — Whether the metric is hidden from users
    - `round` number, double — Number of decimal places
    - `compact` union
      - 'auto' | 'thousands' | 'millions' | 'billions' | 'trillions' | 'kilobytes' | 'megabytes' | 'gigabytes' | 'terabytes' | 'petabytes' | 'kibibytes' | 'mebibytes' | 'gibibytes' | 'tebibytes' | 'pebibytes'
      - 'K' | 'thousand' | 'M' | 'million' | 'B' | 'billion' | 'T' | 'trillion' | 'KB' | 'kilobyte' | 'MB' | 'megabyte' | 'GB' | 'gigabyte' | 'TB' | 'terabyte' | 'PB' | 'petabyte' | 'KiB' | 'kibibyte' | 'MiB' | 'mebibyte' | 'GiB' | 'gibibyte' | 'TiB' | 'tebibyte' | 'PiB' | 'pebibyte'
    - `format` union — Format string (legacy format specification)
      - 'km' | 'mi' | 'si' | 'usd' | 'gbp' | 'eur' | 'jpy' | 'dkk' | 'id' | 'percent'
      - string
    - `separator` 'default' | 'commaPeriod' | 'spacePeriod' | 'periodComma' | 'noSeparatorPeriod' | 'apostrophePeriod'
    - `table` string, required — Table name the metric belongs to
    - `name` string, required — Internal name of the metric
    - `index` number, double — Display order index
    - `filters` MetricFilterRule[] — Filters to apply to this metric
      - `includeNull` boolean — For the `equals` operator on string fields, also match rows where the field is null (compiles to `field IN (...) OR field IS NULL`). Lets users combine null with selected values in a single "is" rule.
      - `values` AnyType[] — Values to filter by
        - unknown
      - `operator` 'isNull' | 'notNull' | 'equals' | 'notEquals' | 'startsWith' | 'endsWith' | 'include' | 'doesNotInclude' | 'lessThan' | 'lessThanOrEqual' | 'greaterThan' | 'greaterThanOrEqual' | 'inThePast' | 'notInThePast' | 'inTheNext' | 'inTheCurrent' | 'notInTheCurrent' | 'inBetween' | 'notInBetween' | 'inPeriodToDate', required
      - `id` string, required — Unique identifier for the filter
      - `target` object, required — Target field for the filter
        - `fieldRef` string, required — Field reference to filter on (e.g., 'table_name.field_name')
      - `settings` unknown
      - `disabled` boolean — Whether this filter is disabled
      - `required` boolean — Whether this filter is required
      - `caseSensitive` boolean — Overrides the field/explore case-sensitivity for this rule only. Used by internal features like autocomplete search that must always match case-insensitively regardless of the field's configured setting.
    - `baseDimensionName` string — Name of the base dimension/column this metric aggregates
    - `baseMetricName` string — Name of the explore metric this metric was cloned from
    - `uuid` string, nullable — Unique identifier for the metric
    - `percentile` number, double — Percentile value for percentile metrics
    - `distinctKeys` string[]
    - `formatOptions` CustomFormat
      - `type` 'default' | 'percent' | 'currency' | 'number' | 'id' | 'date' | 'timestamp' | 'bytes_si' | 'bytes_iec' | 'custom', required
      - `round` number, double — Number of decimal places
      - `separator` 'default' | 'commaPeriod' | 'spacePeriod' | 'periodComma' | 'noSeparatorPeriod' | 'apostrophePeriod'
      - `currency` string — Currency code (e.g., USD, GBP, EUR)
      - `compact` union
        - 'auto' | 'thousands' | 'millions' | 'billions' | 'trillions' | 'kilobytes' | 'megabytes' | 'gigabytes' | 'terabytes' | 'petabytes' | 'kibibytes' | 'mebibytes' | 'gibibytes' | 'tebibytes' | 'pebibytes'
        - 'K' | 'thousand' | 'M' | 'million' | 'B' | 'billion' | 'T' | 'trillion' | 'KB' | 'kilobyte' | 'MB' | 'megabyte' | 'GB' | 'gigabyte' | 'TB' | 'terabyte' | 'PB' | 'petabyte' | 'KiB' | 'kibibyte' | 'MiB' | 'mebibyte' | 'GiB' | 'gibibyte' | 'TiB' | 'tebibyte' | 'PiB' | 'pebibyte'
      - `prefix` string — Prefix to prepend to formatted values
      - `suffix` string — Suffix to append to formatted values
      - `timeInterval` 'RAW' | 'YEAR' | 'QUARTER' | 'MONTH' | 'WEEK' | 'DAY' | 'HOUR' | 'MINUTE' | 'SECOND' | 'MILLISECOND' | 'DAY_OF_WEEK_INDEX' | 'DAY_OF_MONTH_NUM' | 'DAY_OF_YEAR_NUM' | 'WEEK_NUM' | 'MONTH_NUM' | 'QUARTER_NUM' | 'YEAR_NUM' | 'DAY_OF_WEEK_NAME' | 'MONTH_NAME' | 'QUARTER_NAME' | 'HOUR_OF_DAY_NUM' | 'MINUTE_OF_HOUR_NUM'
      - `custom` string — Custom format string
    - `generationType` 'periodOverPeriod' — Optional marker for metrics generated by the system. Currently used for Period-over-Period (PoP) previous-period metrics.
    - `baseMetricId` string
    - `timeDimensionId` string
    - `granularity` 'RAW' | 'YEAR' | 'QUARTER' | 'MONTH' | 'WEEK' | 'DAY' | 'HOUR' | 'MINUTE' | 'SECOND' | 'MILLISECOND' | 'DAY_OF_WEEK_INDEX' | 'DAY_OF_MONTH_NUM' | 'DAY_OF_YEAR_NUM' | 'WEEK_NUM' | 'MONTH_NUM' | 'QUARTER_NUM' | 'YEAR_NUM' | 'DAY_OF_WEEK_NAME' | 'MONTH_NAME' | 'QUARTER_NAME' | 'HOUR_OF_DAY_NUM' | 'MINUTE_OF_HOUR_NUM'
    - `periodOffset` number, double — For PoP-generated metrics, the number of periods to offset by (>= 1).

## Response `200`

Success

- object
  - `results` PullRequestCreated, required
    - `prUrl` string, required
    - `prTitle` string, required
  - `status` 'ok', required

## Other responses

- `default` — Error

---

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