Skip to main content
The OpalScript editor is where you write, test, and manage your scripts. This page walks through the editor, from creating a script to watching it run in production.

Prerequisites

  • You must be an Opal Admin or Read-only Admin to open the OpalScript editor.
  • Read Overview first if you haven’t created a script yet.

The editor at a glance

Navigate to OpalScript > Editor. The OpalScript editor with an empty script open. The left pane lists saved scripts with their type and last-edited time. The center pane holds the code. Above it, the script name "Untitled Script" sits over a metadata row reading "On Request", "Latest (v1)", and "No runs yet". Assistant and Save buttons are at top right, and a collapsed Debug panel with Test run and Clear buttons runs along the bottom. The script name itself is editable—select it to rename the script.

The metadata row

The row under the script name is three shortcuts, not just labels:
Renaming a script doesn’t break anything it’s attached to. Triggers follow the script, not its name.

Create a script

  1. Select + above the script list.
  2. Choose a script type from the dropdown at the top left of the New script dialog—Request review, delegation condition, or context provider.
  3. Pick a starting point. Blank script under Start from scratch gives you an empty file; the templates below it are grouped by what they do, and selecting one previews its full source on the right.
  4. Select an Owner, then select Use template. The New script dialog. A Request review type dropdown sits top left, above template groups labeled Start from scratch, Auto-approve, Block, and Escalate. The Low-risk auto-approve template is selected. The right side shows an Owner field set to "Analytics Owner" and a read-only preview of the template's code. Cancel and Use template buttons are at the bottom. The owner you select owns the service user that Opal provisions behind the script.
Templates are the fastest way to see what OpalScript can do. Select each one to read its source—even if you start from a blank script, the templates show the idioms for common patterns.

Test a script before you use it

Test runs execute your script against a synthetic request. Nothing real is approved, denied, or commented on.
  1. Select Test run in the Debug panel at the bottom of the editor.
  2. Build the request to simulate: The Test run dialog, headed "Synthetic access request". Requester is set to a test user, Simulate time to 10:19 PM, Resource or group to "Production Database", and Access level to "readonly". Duration is set to Custom with 0 days, 1 hour, 0 minutes, and the Reason field is empty. Cancel and Run test buttons are at the bottom.
  3. Select Run test and read the output in the Debug panel. The Debug panel after a test run, labeled with the requester and "Production Database". An INFO line reads "Script started - Low-risk auto-approve - v1". Two DEBUG lines show line and column numbers next to the calls made, including a resource_sensitivity lookup returning "CRITICAL" and the resulting actions.comment call. A WARN line reads "completed in 47ms - no decision (no approve/deny)".
Each line is tagged by level and, for calls your script made, prefixed with the line and column it came from. The closing line gives the runtime and the decision the script reached.
A run that ends with no decision (no approve/deny) did not decide anything. actions.comment() leaves a note without deciding, so the request carries on to its normal human reviewers. That’s the intended behavior for “send this to a human” branches—but if you expected an approval, this warning is the tell.

Save a script that’s already in use

Saving takes effect immediately—there’s no staging step. So when you save a script that live resources, groups, or delegations already depend on, Opal asks you to confirm first. The dialog is titled This script is in use and names what the save will affect: The "This script is in use" dialog over the editor. It reads "This script reviews access requests for 1 resource. Saving takes effect immediately and changes how those requests are reviewed." Below the text is a View resources link, and Cancel and Save changes buttons. You have three choices:
  • Save changes applies the new version right away. Every run after that point uses the new logic.
  • Cancel returns you to the editor with your changes intact but unsaved.
  • View resources (or View delegations) opens the drawer so you can check exactly what’s affected before deciding.
The dialog only appears when something live depends on the script. If nothing is attached to it yet, saving is silent. For delegation condition scripts, delegations that have already ended don’t count—only delegations still in effect trigger the warning.
Every run uses the latest saved version of the script. A run is never pinned to the version that was current when its request was submitted, so a save can change how in-flight requests are handled.

Versions and diffs

Every save creates a new version. Select the version segment in the metadata row to open the history. The version history popover, expanded over a split diff. A Unified / Split toggle sits at the top. Below it, a Base column of radio buttons lets you pick which version to compare against, with v1 dated Sep 16 and v2 dated Sep 20 tagged LATEST. Behind the popover, the editor shows v1 on the left and v2 on the right, with removed comment lines highlighted. The metadata row reads "v1 to v2". From the history you can:
  • Select a version to view it. The editor becomes read-only and Save becomes Restore.
  • Compare two versions. The Base column picks what to compare against; Unified shows changes inline and Split puts the versions side by side. The metadata row changes to v1 → v2 while you’re comparing.
  • Select Restore to make an earlier version current. Restoring creates a new version rather than deleting the ones after it.

Unsaved changes

The editor keeps your in-progress edits locally, even if you close the tab. When you come back, a banner tells you that unsaved changes were restored, and you can either save them or select Discard to return to the last saved version. Leaving the editor with unsaved changes prompts you to confirm first.

See where a script is used

Select the trigger segment (On Request) in the metadata row to open the drawer listing everything that causes the script to run. For request review scripts it’s titled Resources & groups; for delegation condition scripts, Delegations. The Resources & groups drawer open on the right side of the editor. It reads "This script runs when an access request is made for any of these resources or groups" above a count of 1 resource or group. A single card is labeled RESOURCE, names "test (Prod AWS Account)", carries DEFAULT, STAGE 1, and AND badges, and lists "OpalScript: Low-risk auto-approve" as the reviewer. Each card names the resource or group, the request configuration the script is attached to, the approval stage it sits on, the stage’s approval logic, and the other reviewers on that stage. An empty drawer means nothing triggers the script yet—it won’t run until you add it as a reviewer on a resource or group.
Check this drawer first when a script isn’t running. Most of the time the script is fine and simply isn’t attached to anything.

Monitor runs

Select the last-run segment in the metadata row to see this script’s execution history, or navigate to OpalScript > Runs for runs across all scripts. The OpalScript Runs page listing script executions, with filters for Script, resource or group, Requester, Result, and Run After across the top. Columns are Result, Script, Requester, Assets, Runtime, and Run at, sorted by Run at descending. Every visible row carries a green SUCCESS badge, and the Assets column names each group alongside its source system, such as Okta or Active Directory. Requester names are obscured. Each row is one execution: Filter by script, resource or group, requester, result, or date—useful for answering “did this script act on that request?”

Kill a pending run

A run that is still pending shows a red kill button at the end of its row. Selecting it asks you to confirm:
This stops the OpalScript run and denies its linked request. This can’t be undone.
Killing a run doesn’t just stop the script—it denies the access request the run was reviewing. The requester will need to submit again.
Last modified on September 21, 2026