Import Building Blocks.
Users can only import up to 50 building blocks per request.
Condition Date Time Building Blocks
Condition Date Time Building Blocks use the time_in_range function, so the request must add import data.plainid.datetime.time_in_range after import rego.v1. If you leave it out, the request fails with a validation error. See the Condition Date Time example.
Notice
Accessing the Policy Management APIs is through a dedicated domain/URL, according to your PlainID Tenant Locationhttps://api.us1.plainid.iohttps://api.ca1.plainid.iohttps://api.eu1.plainid.ioUsing HTML Encoded Special Characters
Use HTML encoded patterns when working with values that contain special characters like spaces, dashes, etc. Refer to this HTML URL Encoding Reference for a full list.
Important note about headers
Refer to the headers below to modify your cURL sample. Check if the following headers are in the sample, if not, ensure you add it to your cURL sample before pasting into your API tool.
Headers
*Required| Header | Value | cURL Line |
|---|---|---|
| Accept | text/plain;language=rego | -H "Accept :text/plain;language=rego" |
| Content-Type | text/plain;language=rego | -H "Content-Type:text/plain;language=rego" |
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 in the Try It or Code Sample tabs. You can then copy the cURL sample from the Code Sample tab 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 ID can be found under the Details Tab in the Environment Settings.
The Policies Workspace ID can be found in the Workspace Settings. *Required if identityWsId is not provided.
The Identities Workspace ID can be found in the Workspace Settings. *Required if authWsId not provided.
Toggle to enable or disable additional metadata in the response, like the Building Block id and description.
"package building_blocks\nimport rego.v1\n\n# METADATA\n# custom:\n# plainid:\n# kind: DynamicGroup\n# name: dg1\n# description: dg1\ndynamic_group(identity) if {\n identity.template == \"idWs1\"\n identity[\"idAttr1\"] == \"test\"\n identity[\"idAttr1\"] != \"prod\"\n}\n""package building_blocks\nimport rego.v1\n\n# METADATA\n# custom:\n# plainid:\n# kind: Condition\n# subKind: Country Codes\n# name: Albania_Austria_Australia\ncondition(requestParams) if {\n requestParams[\"CountryCode\"] in [\"Albania\", \"Austria\", \"Australia\"]\n}\n\n# METADATA\n# custom:\n# plainid:\n# kind: Condition\n# subKind: Platforms\n# name: Windows Only\ncondition(requestParams) if {\n requestParams[\"Platform\"] == \"Windows\"\n}\n""package building_blocks\nimport rego.v1\nimport data.plainid.datetime.time_in_range\n\n# METADATA\n# custom:\n# plainid:\n# kind: Condition Date Time\n# name: Business Hours\ncondition_datetime if {\n time_in_range({\n \"months\": [\"JANUARY\"],\n \"days\": [\"MONDAY\"],\n \"times\": {\"from\": \"08:00\", \"to\": \"17:00\", \"timeZone\": \"UTC\"},\n \"dates\": {\"from\": \"2026-01-01\", \"to\": null}\n })\n}\n"Building Blocks as Rego code
successful operation
"package building_blocks\nimport rego.v1\n\n# METADATA\n# custom:\n# plainid:\n# kind: DynamicGroup\n# name: dg1\n# id: f28c17c2-caeb-4cf2-a549-02bf03fe4e17\n# description: dg1\ndynamic_group(identity) if {\n identity.template == \"idWs1\"\n identity[\"idAttr1\"] == \"test\"\n identity[\"idAttr1\"] != \"prod\"\n}\n""package building_blocks\nimport rego.v1\n\n# METADATA\n# custom:\n# plainid:\n# kind: Condition\n# subKind: Country Codes\n# name: Albania_Austria_Australia\n# id: 8adc4fe8-759a-4df4-9dc1-c180c9c4a2c4\ncondition(requestParams) if {\n requestParams[\"CountryCode\"] in [\"Albania\", \"Austria\", \"Australia\"]\n}\n\n# METADATA\n# custom:\n# plainid:\n# kind: Condition\n# subKind: Platforms\n# name: Windows Only\n# id: bbb22222-2222-2222-2222-222222222222\ncondition(requestParams) if {\n requestParams[\"Platform\"] == \"Windows\"\n}\n""package building_blocks\nimport rego.v1\nimport data.plainid.datetime.time_in_range\n\n# METADATA\n# custom:\n# plainid:\n# kind: Condition Date Time\n# name: Business Hours\n# id: 0d50b83c-5c73-4ca6-b4bd-16d6796e3720\ncondition_datetime if {\n time_in_range({\n \"months\": [\"JANUARY\"],\n \"days\": [\"MONDAY\"],\n \"times\": {\"from\": \"08:00\", \"to\": \"17:00\", \"timeZone\": \"UTC\"},\n \"dates\": {\"from\": \"2026-01-01\", \"to\": null}\n })\n}\n"Building Blocks as Rego code
bad request
{
"errors": [
{
"code": "PAC-005",
"args": {
"0": "67c1ffe0-a540-4662-b894-0813abcc04ec"
},
"id": "ERHCQC",
"status": 400,
"name": "IdentityWsNotFound",
"message": "IdentityWs: [67c1ffe0-a540-4662-b894-0813abcc04ec] not found"
}
]
}{
"errors": [
{
"code": "PACV-075",
"args": {
"0": "c5167aaf-c023-46a2-8262-3a5b103d69df"
},
"id": "EG7K2P",
"status": 400,
"name": "NoSaasApplicationForGenericConditions",
"message": "No SAAS applications found in workspace [c5167aaf-c023-46a2-8262-3a5b103d69df]; cannot process generic conditions in building blocks"
}
]
}{
"errors": [
{
"code": "TV-001",
"name": "CompilationError",
"line": 10,
"message": "Internal compiler error: undefined function time_in_range"
},
{
"code": "PACV-076",
"name": "InvalidConditionDateTimeExpr",
"line": 10,
"message": "Invalid Condition Date Time rule [Business Hours]: time_in_range is used without `import data.plainid.datetime.time_in_range`. Hint: use time_in_range({\"months\": [...], \"days\": [...], \"times\": {...}, \"dates\": {...}}) with `import data.plainid.datetime.time_in_range`."
}
]
}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": "$: test is an invalid uuid"
}
]
}