Manage Data and Subscription Policies

Policy API reference guide

The policy endpoint allows you to manage and review policies in Immuta. This page outlines the endpoint and its request and response parameters.

Additional fields may be included in some responses you receive; however, these attributes are for internal purposes and are therefore undocumented.

Policy workflow

Create and manage policies

Method
Path
Purpose

POST

/policy/global

POST or PUT

/policy/handler/{dataSourceId}

POST

/policy/global/applyPolicy

PUT

/policy/global/{policyId}

Create a global policy with a specified entity type

POST /policy/global

Create a Global Policy with a given entityType.

Query parameters

Attribute
Description
Required

body

array Contains Global Policy metadata.

Yes

Payload parameters

See the Policy Handler Objects tutorial for payload examples and details.

Response parameters

When successful, the response returns the body of the request payload.

Request example

This example request creates a Global Policy (saved in the example-payload.json file) in the Immuta tenant.

curl \
    --request POST \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer dea464c07bd07300095caa8" \
    --data @example-payload.json \
    https://demo.immuta.com/policy/global

Request payload example

{
  "type": "data",
  "template": false,
  "ownerRestrictions": null,
  "actions": [{
    "type": "masking",
    "rules": [{
      "type": "masking",
      "exceptions": null,
      "config": {
        "fields": [{
          "name": "Discovered.Passport",
          "displayName": "Discovered > Passport",
          "hasLeafNodes": false,
          "source": "curated"
        }],
        "maskingConfig": {
          "type": "Consistent Value",
          "metadata": {}
        }
      }
    }],
    "description": ""
  }],
  "circumstances": [{
    "operator": "or",
    "type": "columnTags",
    "columnTag": {
      "name": "Discovered.Passport",
      "displayName": "Discovered > Passport",
      "hasLeafNodes": false,
      "source": "curated"
    }
  }],
  "name": "Mask Passports",
  "certification": {
    "text": "This certifies that all columns containing passports in this data source have been tagged appropriately.",
    "label": "Certified",
    "tags": [],
    "recertify": true
  },
  "staged": false
}

Response example

{
  "id": 8,
  "policyKey": "Mask Passports",
  "name": "Mask Passports",
  "type": "data",
  "template": false,
  "staged": false,
  "systemGenerated": false,
  "deleted": false,
  "certification": {
    "tags": [],
    "text": "This certifies that all columns containing passports in this data source have been tagged appropriately.",
    "label": "Certified",
    "recertify": true
  },
  "actions": [{
    "type": "masking",
    "rules": [{
      "type": "masking",
      "config": {
        "fields": [{
          "name": "Discovered.Passport",
          "source": "curated",
          "hasLeafNodes": false
        }],
        "maskingConfig": {
          "type": "Consistent Value",
          "metadata": {}
        }
      },
      "exceptions": null
    }],
    "description": null
  }],
  "circumstances": [{
    "type": "columnTags",
    "operator": "or",
    "columnTag": {
      "name": "Discovered.Passport",
      "hasLeafNodes": false
    }
  }],
  "metadata": null,
  "clonedFrom": null,
  "createdBy": 2,
  "createdAt": "2021-09-21T18:35:48.615Z",
  "updatedAt": "2021-09-21T18:35:48.615Z",
  "createdByName": "Katie",
  "ownerRestrictions": null
}

Create or update a policy for a specific data source

POST or PUT /policy/handler/{dataSourceId}

Create (POST) or update (PUT) a policy for the specified data source.

Query parameters

Attribute
Description
Required

dataSourceId

integer The ID of the data source.

Yes

jsonPolicies

array[object] An array of JSON rules objects.

Yes

Response parameters

Attribute
Description

id

integer The policy handler ID.

url

string The URL of the Immuta tenant.

dataSourceId

integer The ID of the data source the policy is applied to.

createdBy

integer The ID of the user who created the policy.

ca

string The certificate authority.

jsonPolicies

array[object] Policy metadata, including the policy type (visibility, masking, time, minimization, exemption, external, prerequisite, customWhere, showRowsNever, or rowOrObjectRestriction), rules, and description.

rules

string The conditions of the policy.

createdAt

timestamp The date the policy was created.

updatedAt

timestamp The date the policy was modified.

Request example

This example request applies the policy specified in the payload to the data source with the ID 2.

curl \
    --request POST \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer dea464c07bd07300095caa8" \
    --data @example-payload.json \
    https://demo.immuta.com/policy/handler/2

Request payload example

{
  "jsonPolicies": [{
    "type": "masking",
    "rules": [{
      "type": "masking",
      "config": {
        "fields": ["amount"],
        "maskingConfig": {
          "type": "Consistent Value",
          "metadata": {
            "constant": null
          }
        }
      },
      "exceptions": null
    }],
    "createdAt": "2021-09-20T20:03:18.001Z",
    "createdBy": 2,
    "description": null
  }, {
    "type": "masking",
    "rules": [{
      "type": "masking",
      "config": {
        "fields": ["geo_latitude"],
        "maskingConfig": {
          "type": "Consistent Value",
          "metadata": {}
        }
      },
      "exceptions": null
    }],
    "createdAt": "2021-09-20T20:02:02.213Z",
    "createdBy": 2,
    "description": null
  }, {
    "type": "prerequisite",
    "rules": [{
      "type": "prerequisite",
      "exceptions": null,
      "config": {
        "qualifications": {
          "operator": "and",
          "conditions": [{
            "type": "purposes",
            "value": "Re-identification Prohibited"
          }]
        }
      }
    }],
    "description": ""
  }],
  "dataSourcePolicyHandler": {
    "handlerId": 26,
    "visibilitySchema": {
      "fields": []
    }
  }
}

Response example

{
  "id": 42,
  "dataSourceId": 2,
  "createdBy": 2,
  "ca": ["-----BEGIN CERTIFICATE-----\ncertificatedata\n-----END CERTIFICATE-----"],
  "jsonPolicies": [
    {
      "type": "masking",
      "rules": [
        {
          "type": "masking",
          "config": {
            "fields": [
              "amount"
            ],
            "maskingConfig": {
              "type": "Consistent Value",
              "metadata": {
                "constant": null
              }
            }
          },
          "exceptions": null
        }
      ],
      "createdAt": "2021-09-20T20:03:18.001Z",
      "createdBy": 2,
      "description": null
    },
    {
      "type": "masking",
      "rules": [
        {
          "type": "masking",
          "config": {
            "fields": [
              "geo_latitude"
            ],
            "maskingConfig": {
              "type": "Consistent Value",
              "metadata": {}
            }
          },
          "exceptions": null
        }
      ],
      "createdAt": "2021-09-20T20:02:02.213Z",
      "createdBy": 2,
      "description": null
    },
    {
      "type": "prerequisite",
      "rules": [
        {
          "type": "prerequisite",
          "config": {
            "qualifications": {
              "operator": "and",
              "conditions": [
                {
                  "type": "purposes",
                  "value": "Re-identification Prohibited"
                }
              ]
            }
          },
          "exceptions": null
        }
      ],
      "createdAt": "2021-09-20T20:05:35.925Z",
      "createdBy": 2,
      "description": null
    }
  ],
  "createdAt": "2021-09-21T18:49:34.021Z",
  "updatedAt": "2021-09-21T18:49:34.021Z"
}

Apply a global policy to a data source

Note: Global policies that contain the condition "with columns tagged" or "on all data sources" will automatically apply to relevant data sources when the policy is created. The endpoint detailed below can be used to apply Global Policies that contain the condition "when selected by data owners," as these policies are not automatically applied to data sources.

POST /policy/global/applyPolicy

Apply the Global Policy to the specified data source.

Query parameters

Attribute
Description
Required

payload

array Contains Global Policy and data source metadata.

Yes

Payload parameters

Attribute
Description
Required

policyID

integer The ID of the Global Policy.

Yes

dataSourceID

integer The ID of the data source to apply the policy to.

Yes

merged

boolean Default false.

Yes

Response parameters

None. When successful, no message will display.

Request example

This example request applies the specified Global Policy to the specified data source (saved in the example-payload.json file) in the Immuta tenant.

curl \
    --request POST \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer dea464c07bd07300095caa8" \
    --data @example-payload.json \
    https://demo.immuta.com/policy/global/applyPolicy

Request payload example

The following payload will apply the Global Policy with the ID 1 to the data source with ID 1.

{
  "policyId": 1,
  "dataSourceId": 1,
  "merged": false
}

Update a global policy

PUT /policy/global/{policyId}

Update the specified policy.

Query parameters

Attribute
Description
Required

policyID

integer The ID of the Global Policy you want to update.

Yes

payload

array Contains Global Policy and metadata.

Yes

Payload parameters

See the Policy Handler Objects tutorial for payload examples and details.

Response parameters

When successful, the response returns the body of the request payload.

Request example

This example request updates the specified Global Policy (8) with changes to the metadata saved in the example-payload.json file.

curl \
    --request PUT \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer dea464c07bd07300095caa8" \
    --data @example-payload.json \
    https://demo.immuta.com/policy/global/8

Request payload example

In this payload, the user updated the description attribute to update the policy.

{
  "id": 8,
  "policyKey": "Mask Passports",
  "name": "Mask Passport",
  "type": "data",
  "template": false,
  "staged": false,
  "systemGenerated": false,
  "deleted": false,
  "certification": {
    "tags": ["Discovered.Passport"],
    "text": "This certifies that all columns containing passports in this data source have been tagged appropriately.",
    "label": "Certified"
  },
  "actions": [{
    "type": "masking",
    "rules": [{
      "type": "masking",
      "config": {
        "fields": [{
          "name": "Discovered.Passport",
          "source": "curated",
          "hasLeafNodes": false,
          "displayName": "Discovered > Passport"
        }],
        "maskingConfig": {
          "type": "Consistent Value",
          "metadata": {}
        }
      },
      "exceptions": null
    }],
    "description": "This policy masks all passports for data sources with columns tagged Discovered.Passport."
  }],
  "circumstances": [{
    "type": "columnTags",
    "operator": "or",
    "columnTag": {
      "name": "Discovered.Passport",
      "hasLeafNodes": false,
      "displayName": "Discovered > Passport"
    }
  }],
  "metadata": null,
  "clonedFrom": null,
  "createdBy": 2,
  "createdAt": "2021-09-21T18:35:48.615Z",
  "updatedAt": "2021-09-21T18:41:36.054Z",
  "createdByName": "Katie",
  "ownerRestrictions": null
}

Response example

{
  "id": 6,
  "policyKey": "mask-passports",
  "name": "Mask Passports",
  "type": "data",
  "template": false,
  "createdBy": 2,
  "createdByName": "Kate",
  "createdAt": "2021-09-14",
  "updatedAt": "2021-09-15",
  "actions": [
    {
      "type": "masking",
      "rules": [
        {
          "type": "masking",
          "exceptions": null,
          "config": {
            "fields": [
              {
                "name": "Discovered.Passport",
                "hasLeafNodes": false,
                "source": "curated"
              }
            ],
            "maskingConfig": {
              "type": "Consistent Value",
              "metadata": {}
            }
          }
        }
      ],
      "description": "This policy masks all passports for data sources with columns tagged Discovered.Passport."
      }
    ],
      "circumstances": [
        {
          "operator": "or",
          "type": "columnTags",
          "columnTag": {
            "name": "Discovered.Passport",
            "hasLeafNodes": false
          }
        }
      ],
  "clonedFrom": 0,
  "staged": false,
  "systemGenerated": false,
  "deleted": false,
  "certification": {
    "label": "string",
    "text": "string",
    "tags": [
      "string"
    ],
    "recertify": false
  }
}

Review policies

Method
Path
Purpose

POST

/policy/search

GET

/policy/global/{policyId}

GET

/policy/global

GET

/policy/global/appliedTo/{policyId}

GET

/policy/dataSourcePolicies/{dataSourceId}

GET

/policy/diff/{dataSourceId}

GET

/policy/handler/{dataSourceId}

Search for policies

POST /policy/search

Searches for specified policies.