Skip to main content

Functions

A function is TypeScript your organization writes and Owlie runs at one set point: an approval step, a fulfillment, a review, a provisioning operation, a reaction, or a menu action. You choose that point when you create the function, by choosing its type. The type decides what the function receives, what it must return, and where you can attach it.

Functions are under Extensibility > Functions. Reading them needs permission to read functions, and creating, editing, publishing and deleting them needs permission to modify functions.

Choose a type​

TypeWhat it is forWhere you attach it
Endpoint (existing functions only)Custom logic that takes a request and returns a response.New Endpoint functions cannot be created. Existing ones can run from the editor.
FulfillmentGrants or removes access for a resource after a request is approved.A resource's fulfillment
ApprovalApproves or rejects a request, or routes it to a user, a group, a manager or an app owner.A resource's approval steps
Review reviewer resolverReturns the user or group who reviews an item in an access review.Reviewer routing
Event actionRuns from a reaction after a matching event.A reaction's Run function action
Provisioning hookRuns a side effect before or after a provisioning operation.A resource's provisioning profile
Identity actionRuns against one identity when a person chooses it from the identity's Quick Actions menu.A custom action
Request actionRuns against one request when a person chooses it from the request's Quick Actions menu.A custom action

A function's type can't be changed after you create it. Each type starts from its own starter code, and the editor checks your code against that type's input and return shapes. The shapes themselves are in the function programming reference.

Create a function​

  1. Open Extensibility > Functions and select Add Function.
  2. Choose the Function type.
  3. Optionally add Tags. Tags only help you find the function in the list.
  4. Create the function. Owlie names it after its type, such as approval-function, and opens the editor.

To rename the function, select its name in the editor's top bar and type a new one.

If Add Function is unavailable, your organization has reached its plan's function limit. See Usage and limits.

The editor​

The editor has the code in the middle, a Reference panel on the right, and a dock at the bottom.

PartWhat it holds
Top barThe function's name, the version picker, Publish, Save, Delete function and the dock toggle.
function.tsThe function's one source file, with formatting, copy and type checking against the function's type.
Reference > PackagesThe npm packages the function imports.
Reference > SecretsThe function's encrypted secrets.
Reference > SettingsTags, Owlie Access and Network Access.
Reference > DocsThe input, context and return shapes for this function's type.
Dock > RunA test event, the result and the logs of your last run.
Dock > HistoryEvery recorded run of the function.

Every function has exactly one draft. Save writes your changes to the draft and builds it. If the build fails, the errors stay on the draft and you can keep editing, but you can't run or publish the draft until it builds. If someone else saved the draft after you opened it, Owlie rejects your save instead of overwriting their work.

Packages​

On Packages, type a package name after npm install and press Enter. Owlie resolves the version and adds the package to the draft. Add one package at a time.

Secrets​

Secrets are encrypted values, such as an API token, that the function reads at run time from context.secrets. On Secrets, select Add Secret, enter a name and a value, and save the draft.

  • A name uses uppercase letters, digits and underscores, such as HRIS_API_TOKEN, and can be up to 64 characters. A value can be up to 8,192 characters.
  • A version can hold up to 20 secrets.
  • Owlie never shows a saved value again. To replace one, select Edit and enter the new value.
  • Changing a secret doesn't rebuild the function.

Secrets belong to a version. Publishing carries the draft's secrets into the published version and into the new draft.

Network access​

A function can't reach the internet until you allow it. Under Settings > Network Access, turn on Allow outbound requests, then add each host under Allowed Domains, such as api.example.com. An entry also covers its subdomains. Wildcards, localhost, and private network addresses aren't accepted.

Network access is saved with the draft. The published version keeps its own list until you publish again. You can't publish with Allow outbound requests on and no allowed domain.

Owlie Access​

By default a function can't call Owlie's API. Settings > Owlie Access gives the function the Owlie SDK as context.owlie, without an API key to store or rotate.

  1. Turn on Owlie Access. Owlie creates a service account for the function with no roles, so every SDK call is denied until you assign one.
  2. Select Assign role and choose a role. The function receives every permission in that role.

A role change applies to the function's next SDK call. Assigning a role needs permission to modify functions and to modify roles, and you must hold every permission the role carries yourself. Once a function has Owlie Access, the same ceiling applies to editing, testing and publishing it: you can't run code under more authority than you have.

A function can never use its roles to modify API keys, roles, functions, gateways or the identity provider, even if a role includes those permissions. One run can make up to 32 SDK calls, four at a time.

Turning Owlie Access off removes the SDK and the assigned roles at once. A draft that still uses context.owlie then shows build errors until you remove that code.

Test a function​

  1. Open the dock and select Run.
  2. Edit the JSON under Test Event. It starts as a sample input for the function's type. The reset control restores the sample.
  3. Select Run. With unsaved changes the button reads Save and run, and Owlie saves the draft first.

Output shows the returned value or the error, and Logs shows what the code wrote to the console. A test run executes the draft, with its secrets, its network access and the function's Owlie Access, so a test can change real data in Owlie or in an external system.

A custom action's function receives its actor, action and form values only when a person runs the action from a menu. A test run from the editor leaves them empty.

Publish a version​

Publish makes the draft the live version. Owlie archives the version that was live, and opens a new draft that starts as a copy of the one you published. Whatever the function is attached to runs the live version from then on, so attaching a function that has never been published has no effect until you publish it.

Publish is available when the draft is selected, saved, and builds.

The version picker lists every version with its status: DRAFT, LIVE or ARCHIVED. Select a version to read its code and settings. Published versions are read-only: typing in one shows "Published versions cannot be edited." with Switch to draft.

Select an archived version and choose Restore as live to make it live again. Your draft stays as it is. Select a published version and choose Rotate secrets to replace existing secret values without republishing. Leave a field blank to keep its current value. You can't add secret names to a published version.

Execution history​

The dock's History tab lists the function's runs with Status, Version, Executed and Duration. Filter by status: Running, Success, Failed or Timed out. Select a run to open its Request, Response or Error, and Logs.

What a run keeps depends on how it ran:

RunRecorded
A test run from the editorStatus, timing, version, the request, the response or error, and console logs.
A successful run in normal useStatus, timing and version only.
A failed run in normal useStatus, timing, version, a sanitized error and console logs.

Logs are cut off at a size limit. Owlie redacts the function's secret values from recorded requests, responses, errors and logs. It can't recognize a secret your code encoded or transformed, so don't log credentials.

From a recorded request you can select the control that uses the run's request as the test event, then run it again from Run.

A run's returned value must be JSON and at most 1 MiB. Each run starts fresh: nothing a function keeps in memory carries over to the next run.

Delete a function​

Delete function permanently removes the function, its versions and its secrets. Owlie also removes the service account that Owlie Access created, or leaves it disabled if it still holds access or open work. Custom actions bound to the function are deleted with it. Detach the function from resources, reviews and reactions before you delete it.