---
title: "UpsertDataPolicy"
method: POST
path: "/v1alpha/data-policies"
tags: ["DataPoliciesService"]
---

# UpsertDataPolicy

`POST /v1alpha/data-policies`

Creates or updates a DataPolicy in PACE and optionally applies it to the processing platform.

## Request body

- UpsertDataPolicyRequest
  - `apply` boolean — whether to apply the policy directly on the processing platform if omitted, defaults to false
  - `dataPolicy` DataPolicy
    - `id` string
    - `metadata` DataPolicyMetadata
      - `createTime` string, date-time
      - `description` string
      - `lastApplyTime` string, date-time — The last time the policy was applied to the target(s).
      - `tags` string[]
      - `title` string
      - `updateTime` string, date-time
      - `version` integer — For new policies, the version does not need to be set. When updating a policy, the version must match the current version. The version is then automatically incremented.
    - `platform` DataPolicyProcessingPlatform
      - `id` string — An arbitrary but unique identifier for the platform. This matches the id from the PACE app configuration.
      - `platformType` 'PLATFORM_TYPE_UNSPECIFIED' | 'DATABRICKS' | 'SNOWFLAKE' | 'BIGQUERY' | 'POSTGRES' | 'SYNAPSE', enum
    - `ruleSets` DataPolicyRuleSet[]
      - `fieldTransforms` RuleSetFieldTransform[] — Zero or more field transforms. Any field for which no field transform is specified will be included as-is.
        - `field` DataPolicyField
          - `nameParts` string[] — Instead of using "nodes", nesting can be expressed by specifying multiple name parts. A flat table (e.g. csv file) will only contain a single name part for all fields.
          - `required` boolean — Whether the field is required. If not, the field may be null.
          - `tags` string[]
          - `type` string — The data type of the field.
        - `transforms` FieldTransformTransform[] — The last condition in the list must have 0 principals, as this acts as the default / else condition. Transforms should have mutually exclusive sets of principals.
          - `aggregation` TransformAggregation
            - `avg` AggregationAvg
              - …
            - `max` AggregationMax
            - `min` AggregationMin
            - `partitionBy` DataPolicyField[] — The fields to partition by.
              - …
            - `sum` AggregationSum
          - `detokenize` TransformDetokenize
            - `tokenField` DataPolicyField
              - …
            - `tokenSourceRef` string — Full reference to the token source, e.g. a fully qualified table name.
            - `valueField` DataPolicyField
              - …
          - `fixed` TransformFixed
            - `value` string
          - `hash` TransformHash
            - `seed` string
          - `identity` TransformIdentity
          - `nullify` TransformNullify
          - `numericRounding` TransformNumericRounding
            - `ceil` NumericRoundingCeil
              - …
            - `floor` NumericRoundingFloor
              - …
            - `round` NumericRoundingRound
              - …
          - `principals` DataPolicyPrincipal[] — The principals (e.g. groups) for which this transform will be applied.
            - `group` string
          - `regexp` TransformRegexp
            - `regexp` string
            - `replacement` string — Use dollar signs to reference capturing groups in the replacement, e.g. "my-replacement-$1-$2". If the replacement is left empty, the regexp match result (full match or first capturing group) is used.
          - `sqlStatement` TransformSqlStatement
            - `statement` string
      - `filters` RuleSetFilter[] — Zero or more filters. Records that match the conditions are included in the result. When no filters are defined, all records are always included.
        - `genericFilter` FilterGenericFilter
          - `conditions` GenericFilterCondition[] — The last condition in the list must have 0 principals, as this acts as the default / else condition.
            - `condition` string — A (platform-specific) SQL expression. If it evaluates to true, the principals are allowed to access the data.
            - `principals` DataPolicyPrincipal[] — The principals (e.g. groups) that apply to this condition.
              - …
        - `retentionFilter` FilterRetentionFilter
          - `conditions` RetentionFilterCondition[] — The last condition in the list must have 0 principals, as this acts as the default / else condition.
            - `period` RetentionFilterPeriod
              - …
            - `principals` DataPolicyPrincipal[] — The principals (e.g. groups) that apply to this condition.
              - …
          - `field` DataPolicyField
            - `nameParts` string[] — Instead of using "nodes", nesting can be expressed by specifying multiple name parts. A flat table (e.g. csv file) will only contain a single name part for all fields.
            - `required` boolean — Whether the field is required. If not, the field may be null.
            - `tags` string[]
            - `type` string — The data type of the field.
      - `target` DataPolicyTarget
        - `fullname` string — The full and unique name to be used in the target platform. E.g. the view name.
        - `type` 'TARGET_TYPE_UNSPECIFIED' | 'SQL_VIEW', enum
    - `source` DataPolicySource
      - `fields` DataPolicyField[] — A representation of the source data schema. Nested fields are supported.
        - `nameParts` string[] — Instead of using "nodes", nesting can be expressed by specifying multiple name parts. A flat table (e.g. csv file) will only contain a single name part for all fields.
        - `required` boolean — Whether the field is required. If not, the field may be null.
        - `tags` string[]
        - `type` string — The data type of the field.
      - `ref` string — The ref is an identifier for the source, unique at the source platform level.
      - `tags` string[]

## Response `200`

OK

- UpsertDataPolicyResponse
  - `dataPolicy` DataPolicy
    - `id` string
    - `metadata` DataPolicyMetadata
      - `createTime` string, date-time
      - `description` string
      - `lastApplyTime` string, date-time — The last time the policy was applied to the target(s).
      - `tags` string[]
      - `title` string
      - `updateTime` string, date-time
      - `version` integer — For new policies, the version does not need to be set. When updating a policy, the version must match the current version. The version is then automatically incremented.
    - `platform` DataPolicyProcessingPlatform
      - `id` string — An arbitrary but unique identifier for the platform. This matches the id from the PACE app configuration.
      - `platformType` 'PLATFORM_TYPE_UNSPECIFIED' | 'DATABRICKS' | 'SNOWFLAKE' | 'BIGQUERY' | 'POSTGRES' | 'SYNAPSE', enum
    - `ruleSets` DataPolicyRuleSet[]
      - `fieldTransforms` RuleSetFieldTransform[] — Zero or more field transforms. Any field for which no field transform is specified will be included as-is.
        - `field` DataPolicyField
          - `nameParts` string[] — Instead of using "nodes", nesting can be expressed by specifying multiple name parts. A flat table (e.g. csv file) will only contain a single name part for all fields.
          - `required` boolean — Whether the field is required. If not, the field may be null.
          - `tags` string[]
          - `type` string — The data type of the field.
        - `transforms` FieldTransformTransform[] — The last condition in the list must have 0 principals, as this acts as the default / else condition. Transforms should have mutually exclusive sets of principals.
          - `aggregation` TransformAggregation
            - `avg` AggregationAvg
              - …
            - `max` AggregationMax
            - `min` AggregationMin
            - `partitionBy` DataPolicyField[] — The fields to partition by.
              - …
            - `sum` AggregationSum
          - `detokenize` TransformDetokenize
            - `tokenField` DataPolicyField
              - …
            - `tokenSourceRef` string — Full reference to the token source, e.g. a fully qualified table name.
            - `valueField` DataPolicyField
              - …
          - `fixed` TransformFixed
            - `value` string
          - `hash` TransformHash
            - `seed` string
          - `identity` TransformIdentity
          - `nullify` TransformNullify
          - `numericRounding` TransformNumericRounding
            - `ceil` NumericRoundingCeil
              - …
            - `floor` NumericRoundingFloor
              - …
            - `round` NumericRoundingRound
              - …
          - `principals` DataPolicyPrincipal[] — The principals (e.g. groups) for which this transform will be applied.
            - `group` string
          - `regexp` TransformRegexp
            - `regexp` string
            - `replacement` string — Use dollar signs to reference capturing groups in the replacement, e.g. "my-replacement-$1-$2". If the replacement is left empty, the regexp match result (full match or first capturing group) is used.
          - `sqlStatement` TransformSqlStatement
            - `statement` string
      - `filters` RuleSetFilter[] — Zero or more filters. Records that match the conditions are included in the result. When no filters are defined, all records are always included.
        - `genericFilter` FilterGenericFilter
          - `conditions` GenericFilterCondition[] — The last condition in the list must have 0 principals, as this acts as the default / else condition.
            - `condition` string — A (platform-specific) SQL expression. If it evaluates to true, the principals are allowed to access the data.
            - `principals` DataPolicyPrincipal[] — The principals (e.g. groups) that apply to this condition.
              - …
        - `retentionFilter` FilterRetentionFilter
          - `conditions` RetentionFilterCondition[] — The last condition in the list must have 0 principals, as this acts as the default / else condition.
            - `period` RetentionFilterPeriod
              - …
            - `principals` DataPolicyPrincipal[] — The principals (e.g. groups) that apply to this condition.
              - …
          - `field` DataPolicyField
            - `nameParts` string[] — Instead of using "nodes", nesting can be expressed by specifying multiple name parts. A flat table (e.g. csv file) will only contain a single name part for all fields.
            - `required` boolean — Whether the field is required. If not, the field may be null.
            - `tags` string[]
            - `type` string — The data type of the field.
      - `target` DataPolicyTarget
        - `fullname` string — The full and unique name to be used in the target platform. E.g. the view name.
        - `type` 'TARGET_TYPE_UNSPECIFIED' | 'SQL_VIEW', enum
    - `source` DataPolicySource
      - `fields` DataPolicyField[] — A representation of the source data schema. Nested fields are supported.
        - `nameParts` string[] — Instead of using "nodes", nesting can be expressed by specifying multiple name parts. A flat table (e.g. csv file) will only contain a single name part for all fields.
        - `required` boolean — Whether the field is required. If not, the field may be null.
        - `tags` string[]
        - `type` string — The data type of the field.
      - `ref` string — The ref is an identifier for the source, unique at the source platform level.
      - `tags` string[]

## Other responses

- `default` — Default error response

## Changes

- **2023-12-15** `0006dd8ef0f4` — 2 info
  - added the new optional request property `dataPolicy/ruleSets/items/fieldTransforms/items/transforms/items/aggregation`
  - added the optional property `dataPolicy/ruleSets/items/fieldTransforms/items/transforms/items/aggregation` to the response with the `200` status
- **2023-11-29** `8ae5870420f4` — 1 info
  - endpoint added
- **2023-11-17** `04d64891152e` — 1 breaking
  - api path removed without deprecation

[Change history](https://skmtc.dev/getstrm/apis/pace-api/changes/v1alpha/data-policies/post.md)

---

[API](https://skmtc.dev/getstrm/apis/pace-api.md) · [All operations](https://skmtc.dev/getstrm/apis/pace-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/getstrm/pace-api/revisions/df7ee7e702db/schema)
