Note: This version will be sunset (retired) in June 2025.
See Import Policy V2 for the latest documentation.
This API is used to create new Policies, update existing Policies and promote Policies between Environments. Note that only valid Policies will be created successfully.
Notice
Accessing the Policy Management APIs is through a dedicated domain/URL, according to your PlainID Tenant Locationhttps://api.us1.plainid.io
https://api.ca1.plainid.io
https://api.eu1.plainid.io
Prerequisites
The following objects need to be available in the target Environment to successfully import the code:
The following objects need to be available in the target Environment for Policies created to be considered in the access decision:
These connections can be defined before or after importing the Policy. Without these objects, the Policies can be successfully imported, but will not be considered as part of the Access decisions calculation.
cURL Sample Guidelines
In order for the relevant parameters to appear in the cURL sample, you can input the values in the interactive API console on the right. They will then appear in the cURL sample on the bottom of the page in the correct format.
For more details about Administration API Authentication, check out the Authentication APIs documentation. Provide your bearer token in the Authorization header when making requests to protected resources. Example: Authorization: Bearer 123
The environment that the policy will be imported to
The Environment
ID can be found under the Details tab in the Environment Settings.
{
"policyCode": "# METADATA\n# custom:\n# plainid:\n# policyId: PaC1\n# name: Manage consumers accounts in branch\n# description: Tellers, Senior Tellers, Branch Managers can manage private consumer accounts in their own branch only during business hours\n# accessType: Allow\npackage policy\nimport future.keywords\n\n# METADATA\n# custom:\n# plainid:\n# kind: DynamicGroup\n# name: BranchManager\ndynamic_group(identity){\n\tidentity.template == \"User\"\n\tidentity[\"User_Type\"] == \"internal\"\n\tidentity[\"title\"] == \"branch manager\"\n}\n\n# METADATA\n# custom:\n# plainid:\n# kind: DynamicGroup\n# name: SeniorTeller\ndynamic_group(identity){\n\tidentity.template == \"User\"\n\tidentity[\"title\"] == \"Senior Teller\"\n\tidentity[\"User_Type\"] == \"Internal\"\n}\n\n# METADATA\n# custom:\n# plainid:\n# kind: DynamicGroup\n# name: Teller\ndynamic_group(identity){\n\tidentity.template == \"User\"\n\tidentity[\"User_Type\"] == \"Internal\"\n}\n\n# METADATA\n# custom:\n# plainid:\n# kind: Ruleset\n# name: Private consumer bank accounts managed in the user branch\nruleset(asset, identity, requestParams){\n\tasset.template == \"Bank Accounts\"\n\tidentity.template == \"User\"\n\tasset[\"account_type\"] == \"private\"\n\tasset[\"account_branch\"] == identity[\"User_Branch\"]\n}\n\n# METADATA\n# custom:\n# plainid:\n# kind: Action\naction(asset){\n\tasset.template == \"Bank Accounts\"\n\tasset.action in [\"Manage\",\"View\"]\n}",
"language": "rego",
"authWsId": "57fd3c41-fada-41a9-b5ab-fad1133f1e63"
}
{
"policyCode": "# METADATA\n# custom:\n# plainid:\n# policyId: PaC1\n# name: Manage consumers accounts in branch\n# description: Tellers, Senior Tellers, Branch Managers can manage private consumer accounts in their own branch only during business hours\n# accessType: Allow\npackage policy\nimport future.keywords\n\n# METADATA\n# custom:\n# plainid:\n# kind: DynamicGroup\n# name: BranchManager\ndynamic_group(identity){\n\tidentity.template == \"User\"\n\tidentity[\"User_Type\"] == \"internal\"\n\tidentity[\"title\"] == \"branch manager\"\n}\n\n# METADATA\n# custom:\n# plainid:\n# kind: DynamicGroup\n# name: SeniorTeller\ndynamic_group(identity){\n\tidentity.template == \"User\"\n\tidentity[\"title\"] == \"Senior Teller\"\n\tidentity[\"User_Type\"] == \"Internal\"\n}\n\n# METADATA\n# custom:\n# plainid:\n# kind: DynamicGroup\n# name: Teller\ndynamic_group(identity){\n\tidentity.template == \"User\"\n\tidentity[\"User_Type\"] == \"Internal\"\n}\n\n# METADATA\n# custom:\n# plainid:\n# kind: Ruleset\n# name: Private consumer bank accounts managed in the user branch\nruleset(asset, identity, requestParams){\n\tasset.template == \"Bank Accounts\"\n\tidentity.template == \"User\"\n\tasset[\"account_type\"] == \"private\"\n\tasset[\"account_branch\"] == identity[\"User_Branch\"]\n}\n\n# METADATA\n# custom:\n# plainid:\n# kind: Action\naction(asset){\n\tasset.template == \"Bank Accounts\"\n\tasset.action in [\"Manage\",\"View\"]\n}",
"language": "rego",
"authWsId": "57fd3c41-fada-41a9-b5ab-fad1133f1e63"
}
{
"policyCode": "# METADATA\n# custom:\n# plainid:\n# policyId: PaC1\n# name: Manage consumers accounts in branch\n# description: Tellers, Senior Tellers, Branch Managers can manage private consumer accounts in their own branch only during business hours\n# accessType: Allow\npackage policy\nimport future.keywords\n\n# METADATA\n# custom:\n# plainid:\n# kind: DynamicGroup\n# name: BranchManager\ndynamic_group(identity){\n\tidentity.template == \"Usr\"\n\tidentity[\"User_Type\"] == \"internal\"\n\tidentity[\"title\"] == \"branch manager\"\n}\n\n# METADATA\n# custom:\n# plainid:\n# kind: DynamicGroup\n# name: SeniorTeller\ndynamic_group(identity){\n\tidentity.template == \"User\"\n\tidentity[\"title\"] == \"Senior Teller\"\n\tidentity[\"User_Type\"] == \"Internal\"\n}\n\n# METADATA\n# custom:\n# plainid:\n# kind: DynamicGroup\n# name: Teller\ndynamic_group(identity){\n\tidentity.template == \"User\"\n\tidentity[\"User_Type\"] == \"Internal\"\n}\n\n# METADATA\n# custom:\n# plainid:\n# kind: Ruleset\n# name: Private consumer bank accounts managed in the user branch\nruleset(asset, identity, requestParams){\n\tasset.template == \"Bank Acounts\"\n\tidentity.template == \"User\"\n\tasset[\"account_type\"] == \"private\"\n\tasset[\"account_branch\"] == identity[\"User_Branch\"]\n}\n\n# METADATA\n# custom:\n# plainid:\n# kind: Action\naction(asset){\n\tasset.template == \"Bank Acounts\"\n\tasset.action in [\"Manage\",\"View\"]\n}",
"language": "rego",
"authWsId": "57fd3c41-fada-41a9-b5ab-fad1133f1e63"
}
Structured Rego Policy
Detailed instructions for structured Rego to be found [here] - (https://docs.plainid.io/apidocs/structured-rego)
Authorization Workspace ID. This can be found in your Authorization Workspace Settings under Workspace ID.
The code language - rego
Policy Created
{
"data": {
"language": "rego",
"policyCode": "# METADATA\n# custom:\n# plainid:\n# policyId: PaC1\n# name: Manage consumers accounts in branch\n# description: Tellers, Senior Tellers, Branch Managers can manage private consumer accounts in their own branch only during business hours\n# accessType: Allow\npackage policy\nimport future.keywords\n\n# METADATA\n# custom:\n# plainid:\n# kind: DynamicGroup\n# name: BranchManager\ndynamic_group(identity){\n\tidentity.template == \"User\"\n\tidentity[\"User_Type\"] == \"internal\"\n\tidentity[\"title\"] == \"branch manager\"\n}\n\n# METADATA\n# custom:\n# plainid:\n# kind: DynamicGroup\n# name: SeniorTeller\ndynamic_group(identity){\n\tidentity.template == \"User\"\n\tidentity[\"title\"] == \"Senior Teller\"\n\tidentity[\"User_Type\"] == \"Internal\"\n}\n\n# METADATA\n# custom:\n# plainid:\n# kind: DynamicGroup\n# name: Teller\ndynamic_group(identity){\n\tidentity.template == \"User\"\n\tidentity[\"User_Type\"] == \"Internal\"\n}\n\n# METADATA\n# custom:\n# plainid:\n# kind: Ruleset\n# name: Private consumer bank accounts managed in the user branch\nruleset(asset, identity, requestParams){\n\tasset.template == \"Bank Accounts\"\n\tidentity.template == \"User\"\n\tasset[\"account_type\"] == \"private\"\n\tasset[\"account_branch\"] == identity[\"User_Branch\"]\n}\n\n# METADATA\n# custom:\n# plainid:\n# kind: Action\naction(asset){\n\tasset.template == \"Bank Accounts\"\n\tasset.action in [\"Manage\",\"View\"]\n}",
"isPolicyCompleted": true
}
}
Policy Import Failed - Validation Errors
{
"errors": [
{
"code": "PACV-001",
"id": "EVR045",
"name": "TemplateNotFound",
"message": "Template ID [Usr] was not found in Environment ID [ed252aa5-9d0c-4193-8388-60bf20b13109]. Hint: Did you mean [User]?",
"line": 39
}
]
}
{
"errors": [
{
"code": "PACV-001",
"id": "EOEN7T",
"name": "TemplateNotFound",
"message": "Template ID [Usr] was not found in Environment ID [ed252aa5-9d0c-4193-8388-60bf20b13109]. Hint: Did you mean [User]?",
"line": 39
},
{
"code": "PACV-001",
"id": "EJFMNJ",
"name": "TemplateNotFound",
"message": "Template ID [Bank Acounts] was not found in Environment ID [ed252aa5-9d0c-4193-8388-60bf20b13109]. Hint: Did you mean [Bank Accounts, Client Profiles, Credit Cards, Loans, Modules App customer, Modules App Internal]?",
"line": 60
},
{
"code": "PACV-004",
"id": "E5KZRO",
"name": "MissingRequiredActions",
"message": "Action Rule was not defined for Asset Template [Bank Accounts]. Hint: Remove the Ruleset or add required Action Rule with one or more Actions [Manage, Suspend, View].",
"line": -1
}
]
}
{
"errors": [
{
"code": "PAC-001",
"args": {
"0": "57fd3c41-fada-41a9-b5ab-fad1133f1e63"
},
"id": "EBLBJH",
"status": 400,
"name": "AuthorizationWsNotFound",
"message": "AuthorizationWs: [57fd3c41-fada-41a9-b5ab-fad1133f1e63] not found"
}
]
}
Unauthorized
Validation Failed - Invalid UUID
{
"errors": [
{
"code": "V-032",
"args": {
"0": "ed252aa5-9d0c-4193-838-60bf20b13109",
"1": "uuid"
},
"id": "EEJQMA",
"status": 422,
"name": "UnprocessableEntityError",
"message": "$: ed252aa5-9d0c-4193-838-60bf20b13109 is an invalid uuid"
}
]
}