API Reference
Overview¶
Availability
The PBAC API is part of the Metadata Service (MDS) REST API, like the policy and identifier APIs.
All endpoints are under /api/v1/metadata, need PBAC enabled for the account (403 otherwise), and take the usual tenant header. GET /purposes, GET /omni-policies and the report take the standard page (0-based) and size parameters. The lists of a purpose's policies and of a data product's applications return every item at once.
Purposes¶
| Method and path | What it does |
|---|---|
POST /purposes | Create a purpose. Body: name, description, and optionally its first policies (see below). 201 with the purpose |
GET /purposes?search=&sortBy=&sortOrder=&page=&size= | List purposes. search matches part of the name, ignoring case; sortBy is name, createdAt or updatedAt |
GET /purposes/{id} | Get one purpose |
PATCH /purposes/{id} | Change name and/or description; absent fields stay as they are |
DELETE /purposes/{id} | Delete the purpose. Its policies are kept: each stays in its other purposes, or in no purpose. 409 with the data products while it is applied |
DELETE /purposes/{id}?removeApplications=true | Remove every application, then delete ("remove from all") |
| HTTP | |
|---|---|
The response carries the purpose id, which every other call uses. Every purpose response also carries policyCount, maskingPolicyCount and rowFilterPolicyCount.
Purpose policies, from the purpose¶
| Method and path | What it does |
|---|---|
POST /purposes/{purposeId}/policies | Create a policy in this purpose. 201 with the policy |
POST /purposes/{purposeId}/policies/attach | Add existing purpose policies to this purpose. Body: { "policyIds": [...] }, up to 50. A policy the purpose already has is skipped. Returns the purpose's policies |
GET /purposes/{purposeId}/policies | List the purpose's policies, by name |
GET /purposes/{purposeId}/policies/{policyId} | Get one |
PATCH /purposes/{purposeId}/policies/{policyId} | Change name, description, type, actions, identifiers or dataFiltersQuery; absent fields stay as they are, and the result is validated as a whole |
DELETE /purposes/{purposeId}/policies/{policyId} | Remove the policy from this purpose. It isn't deleted: it stays in its other purposes, or in no purpose. Allowed while the purpose is applied: those data products stop applying it, and any deselection of it is cleared |
GET /purposes/{purposeId}/policies/{policyId}/history | The recorded changes to the policy, 25 to a page, oldest first |
GET /purposes/{purposeId}/policies/{policyId}/versions/{eventId} | The policy as one change recorded it |
A row filter, written as a standard row filter is: it names one or more Record Identifiers, and the rows they match are kept or removed.
| JSON | |
|---|---|
identifiers.record_identifier: the ids of existing Record Identifiers, from Create identifier.dataFiltersQuery: the same ids. To combine several, join them withANDorOR, for example"<id1> AND <id2>". Put the ids here, not the filter itself: the filter is written on the Record Identifier.actionisALLOW(keep the matching rows, Allow Result) orDENY(remove them, Exclude Result).
A mask:
| JSON | |
|---|---|
masking.typeis one ofMASK_HASH,MASK_NULL,MASK_SHOW_LAST_4,MASK_SHOW_FIRST_4orMASK_NONE.MASK_CUSTOM(withmasking.valueExpression) is accepted but is not enforced on Snowflake: the column keeps its previous mask. Do not use it in a purpose.
Rejected on a purpose policy: type ACCESS, applyPolicy (assets or principals), user and column identifiers, whoQuery, dataQuery, and any status other than ACTIVE. A row filter's Record Identifiers must exist. A mask's tag must exist, and is stored in upper case; a mask whose tag has since been deleted is returned with "targetMissing": true.
A policy's name is unique within the purpose, ignoring case. Two purposes can each have a different policy with the same name, but a policy cannot be added to a purpose that already has a policy of that name.
Purpose policies on the policy page¶
Purpose policies are omni policies with "kind": "PURPOSE", so the policy endpoints serve them too.
| Method and path | What it does |
|---|---|
GET /omni-policies?kind=PURPOSE | List purpose policies only. kind=STANDARD lists standard ones; omit kind for both. A resourceId filter lists standard policies only |
POST /omni-policies with "kind": "PURPOSE" | Create a purpose policy in the purposes named by purposeIds: one, several, or none. A policy in no purpose does nothing until it is added to one |
POST /omni-policies with no kind | Create a standard policy, exactly as before PBAC. "kind": "STANDARD" does the same |
GET, PUT, PATCH /omni-policies/{id} | Read or change a purpose policy; it keeps the purpose-policy rules above. A change applies in every purpose that has the policy, and an edit never changes which purposes those are |
DELETE /omni-policies/{id} | Delete the purpose policy, which removes it from every purpose. This is the only way to delete a purpose policy |
GET /omni-policies/{id}/purposes | The purposes that have the policy |
POST /omni-policies/{id}/purposes | Add the policy to more purposes. Body: { "purposes": [...] }. A purpose that already has it is skipped |
PATCH /omni-policies/{id}/purposes/delete | Remove the policy from purposes. Body: { "purposes": [...] }. The policy is not deleted |
GET /omni-policies?kind=PURPOSE&unattached=true | Purpose policies that are in no purpose |
Purpose policies returned by /omni-policies carry kind and purposes, which lists every purpose that has them (id and name). Standard policies do not.
A purpose policy can be in several purposes, or in none. Changing it changes every purpose that has it, and every data product those purposes are applied to, except where an application deselects it. Removing it from a purpose, even one applied to data products, stops it applying there at once; the policy is kept, and any deselection of it in that purpose's applications is cleared. A policy in no purpose does nothing until it is added to one.
| HTTP | |
|---|---|
Create a purpose with its first policies¶
POST /purposes can create the purpose's policies with it, as the Create Purpose wizard does. Add a policies list, each written as a purpose policy is, without purposeIds, and a policyIds list of existing purpose policies to add. Together they take up to 50:
It is all or nothing. Every policy is checked first, and two policies may not share a name; any problem is a 400 that lists each one as policies[i]: …, and nothing is created. PATCH /purposes/{id} does not take policies; add policies to an existing purpose with POST /purposes/{id}/policies or POST /purposes/{id}/policies/attach.
A standard policy cannot be added to a purpose; create a purpose policy with the same rule instead.
Get the policy ids¶
Every policy response carries its id.
- The policies of one purpose:
GET /purposes/{purposeId}/policies. - All purpose policies, by name:
GET /omni-policies?kind=PURPOSE&search=<part of the name>.
You need policy ids to deselect them when applying.
Apply a purpose to a data product¶
| Method and path | What it does |
|---|---|
POST /data-products/{dataProductId}/purposes | Apply a purpose. 201 with the application |
GET /data-products/{dataProductId}/purposes | The data product's applications, by purpose name |
GET /data-products/{dataProductId}/purposes/{applicationId} | One application |
PATCH /data-products/{dataProductId}/purposes/{applicationId} | Replace its groups and roles and/or its deselections |
DELETE /data-products/{dataProductId}/purposes/{applicationId} | Remove the application |
GET /purpose-applications?purposeId=&dataProductId=&hasDeselections=&page=&size= | The report |
To find the data product id, list data products with GET /data-products?search=<part of the name>.
| HTTP | |
|---|---|
principals: at least one, each withtypeGROUPorROLEand anameTrust3 AI knows. To look one up, useGET /principals?type=ROLE&search=<part of the name>.deselectedPolicyIds: optional. Each must be a policy of the purpose, and at least one policy must stay selected.
The response holds the application id, dataProductId, purposeId, purposeName, principals (with id, name and type) and deselectedPolicyIds.
On PATCH, send principals and/or deselectedPolicyIds; each replaces the stored list when present. Sending purposeId is refused: an application's purpose never changes.
Errors when applying:
| Status | When |
|---|---|
| 400 | No group or role; a principal that is not a group or role, or that Trust3 AI does not know; a deselected id that is not a policy of the purpose; every policy deselected; a purpose with no policies |
| 403 | You may not make this change: applying needs ROLE_ACCOUNT_ADMIN, ROLE_POLICY_ADMIN, or admin of the data product's security zone. Also returned when PBAC is off |
| 404 | The data product, purpose or application does not exist, or you cannot see it |
| 409 | A group or role already has a purpose on this data product; or another change to this data product's purposes is in progress, or too many purpose changes are in progress, in which case retry |
| 500 | This change took too long and was rolled back; retry |
- Prev topic: PBAC on Snowflake
- Next topic: Policies and Identifiers