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
Section titled “Execute inline”SDK
result = await client.scripting.execute( script='entity_action("01HENTITY...", "switchable.open", #{});')print(result)
# Or load a .openapp file:result = await client.scripting.execute_file("provision-wing-a.openapp")const res = await fetch(`${apiBase}/scripting/execute`, { method: "POST", headers: { authorization: `Bearer ${apiKey}`, "content-type": "application/json", }, body: JSON.stringify({ script: 'entity_action("01HENTITY...", "switchable.open", #{});', }),});const result = await res.json();use openapp_sdk::Client;use serde_json::json;
let client = Client::builder() .api_key("https://api.openapp.house/api/v1_openapp_YOUR_SECRET") .build()?;
let out = client .scripting() .execute(&json!({ "script": r#"entity_action("01HENTITY...", "switchable.open", #{});"#, })) .await?;import ( "context" "os"
openapiclient "github.com/tomers/openapp-sdk/go")
source, err := os.ReadFile("provision-wing-a.openapp")if err != nil { return err}body := *openapiclient.NewExecuteScriptingRequest(string(source))resp, httpResp, err := client.ScriptingAPI.ExecuteScripting(ctx). ExecuteScriptingRequest(body). Execute()if err != nil { return err}defer httpResp.Body.Close()_ = respReplace the script body with your provisioning program (create integration, devices, entities — see reference for built-ins).
HTTP API (curl)
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"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