Provision a building with OpenApp Scripting
Multi-site rollouts (campus wings, new apartment towers, demo environments) repeat the same steps: integrations, devices, entities, portals. OpenApp Scripting runs Rhai programs server-side via POST /scripting/execute — ideal for one-shot provisioning jobs and CI pipelines.
This guide is for platform engineers automating building setup. Syntax reference: OpenApp Scripting. Getting started: Scripting step.
Prerequisites
Section titled “Prerequisites”- API key with scripting execute permission in at least one org
- A tested script in the interactive shell or a
.openappfile
Scripting does not take X-Org on the wire; org context is resolved from caller permissions inside the runtime.
Execute inline (HTTP API)
Section titled “Execute inline (HTTP API)”export OPENAPP_API_BASE='https://api.openapp.house/api/v1'export OPENAPP_API_KEY='v1_openapp_YOUR_SECRET'
curl -sS -X POST \ -H "Authorization: Bearer ${OPENAPP_API_KEY}" \ -H "Content-Type: application/json" \ -d '{ "script": "print(\"provision batch start\");" }' \ "${OPENAPP_API_BASE}/scripting/execute"Replace the script body with your provisioning program (create integration, devices, entities — see reference for built-ins).
Python (SDK)
Section titled “Python (SDK)”import osfrom openapp_sdk import AsyncClient
client = AsyncClient(os.environ["OPENAPP_API_KEY"])result = await client.scripting.execute( script='entity_action("01HENTITY...", "switchable.open", #{});')print(result)Or load a file:
result = await client.scripting.execute_file("provision-wing-a.openapp")Example pattern (pseudocode)
Section titled “Example pattern (pseudocode)”// Illustrative — adapt to your org and provider types (see scripting reference).let integration_id = create_integration("virtual_access", #{ "name": "Tower A" });// create devices, entities, portals...Keep scripts idempotent where possible (check before create) and run against a staging org first.
When to use scripting vs SDK loops
Section titled “When to use scripting vs SDK loops”| Use scripting | Use SDK / HTTP directly |
|---|---|
| Many chained steps in one atomic job | Single invite or door action |
| CI template copied per building | PMS webhook on each check-in |
Operator-maintained .openapp files | Production microservice |
Related
Section titled “Related”- Integrate existing software for ongoing PMS/SIS sync
- Agent-relevant API —
execute_scripting