> ## Documentation Index
> Fetch the complete documentation index at: https://docs.plainid.io/llms.txt
> Use this file to discover all available pages before exploring further.
# Import Building Blocks
> Import Building Blocks.
Users can only import up to 50 building blocks per request.
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.
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.
| 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"` |
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.
## OpenAPI ````json POST /api/2.0/building-blocks/{envId} { "openapi": "3.0.3", "info": { "title": "Management APIs", "version": "1.0.0", "contact": { "name": "PlainID", "url": "https://plainid.com", "email": "contact@plainid.com" }, "license": { "name": "Commercial", "url": "https://plainid.com/license" }, "termsOfService": "https://www.plainid.com/terms/", "description": "| Region | Base URL |
|---|---|
| United States (US) | https://api.us1.plainid.io |
| Canada (CA) | https://api.ca1.plainid.io |
| Europe (EU) | https://api.eu1.plainid.io |
| Local PAA | https://api.plainid.local |
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.
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.
| 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\"` |
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.
", "operationId": "upsertBuildingBlocks", "parameters": [ { "in": "path", "name": "envId", "required": "true", "schema": { "type": "string", "format": "uuid" }, "description": "The Environment ID can be found under the Details Tab in the Environment Settings." }, { "in": "query", "name": "filter[authWsId]", "description": "This can be found in your Authorization Workspace Settings under Workspace ID. *Required if `identityWsId` is not provided.", "schema": { "type": "string", "format": "uuid" } }, { "in": "query", "name": "filter[identityWsId]", "description": "Identity Workspace ID. *Required if `authWsId` is not provided.", "schema": { "type": "string", "format": "uuid" } }, { "in": "query", "name": "extendedSchema", "description": "Toggle to enable or disable additional metadata in the response, like the Building Block `id` and `description`.", "schema": { "type": "boolean", "default": "true" } } ], "security": [ { "bearerAuth": [] } ], "requestBody": { "required": "true", "content": { "text/plain;language=rego": { "schema": { "type": "string", "description": "Building Blocks as Rego code" }, "examples": { "Building Blocks as Rego code": { "value": "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" }, "Generic Conditions": { "value": "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" } } } } }, "responses": { "201": { "description": "successful operation", "content": { "text/plain;language=rego": { "schema": { "type": "string", "description": "Building Blocks as Rego code" }, "examples": { "Successful Import": { "value": "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" }, "Successful Import with Generic Conditions": { "value": "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" } } } }, "headers": { "x-request-id": { "schema": { "type": "string" } } } }, "400": { "description": "bad request", "headers": { "x-request-id": { "schema": { "type": "string" } } }, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Errors" }, "examples": { "Identity WS not found": { "value": { "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" } ] } }, "No SAAS Application for Generic Conditions": { "value": { "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" } ] } } } } } }, "401": { "description": "Unauthorized", "headers": { "x-request-id": { "schema": { "type": "string" } } } }, "422": { "description": "Validation Failed - Invalid UUID", "headers": { "x-request-id": { "schema": { "type": "string" } } }, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Errors" }, "examples": { "Invalid ID Format": { "value": { "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" } ] } } } } } } } } } }, "components": { "schemas": { "Errors": { "type": "object", "properties": { "errors": { "type": "array", "items": { "$ref": "#/components/schemas/Error" } } } }, "Error": { "type": "object", "properties": { "code": { "type": "string" }, "id": { "type": "string" }, "status": { "type": "integer" }, "name": { "type": "string" }, "message": { "type": "string" }, "args": { "type": "object", "properties": { "path": { "type": "string" } } } } } } } } ````