Auth0Client.Management.Action (auth0_client v1.0.0)

Copy Markdown View Source

A module representing actions on Auth0.

Actions are Auth0's extensibility model: Node functions that run at points in the login flow. They replace Rules, which Auth0 has made read-only and ends on 2026-11-18.

The work comes in three steps, and the third is the one people forget:

  1. create/1 an action, naming the triggers it supports
  2. deploy/1 it, which makes a version live
  3. update_bindings/2 to bind it to a trigger

An action that is never bound never runs, no matter how many times it is deployed.

The /actions/modules endpoints, which share reusable code between actions, are not wrapped here.

https://auth0.com/docs/api/management/v2/actions

Summary

Functions

Gets all actions.

Gets the actions currently bound to a trigger, in execution order

Creates an action.

Deletes an action.

Deploys an action, creating a new version from the current draft.

Rolls an action back to an earlier version by redeploying it.

Gets the details of an action execution, including logs from each bound action

Gets a single action

Runs an action against a test payload without deploying it.

Gets the available triggers and their current versions.

Updates an action's code, dependencies, secrets or supported triggers.

Sets the actions bound to a trigger.

Gets a specific version of an action

Gets an action's deployed versions

Functions

all(params \\ %{})

Gets all actions.

Filters: triggerId, actionName, deployed, installed, plus page and per_page.

iex> Auth0Client.Management.Action.all()
iex> Auth0Client.Management.Action.all(triggerId: "post-login", deployed: true)

bindings(trigger_id, params \\ %{})

Gets the actions currently bound to a trigger, in execution order

iex> Auth0Client.Management.Action.bindings("post-login")

create(body)

Creates an action.

name and supported_triggers are required. supported_triggers is a list of objects, not names — [%{id: "post-login", version: "v3"}]. Use triggers/0 to see the available ids and their current versions.

iex> Auth0Client.Management.Action.create(%{
...>   name: "enrich-profile",
...>   supported_triggers: [%{id: "post-login", version: "v3"}],
...>   code: "exports.onExecutePostLogin = async (event, api) => {};"
...> })

delete(id, params \\ %{})

Deletes an action.

Auth0 refuses to delete an action that is still bound to a trigger; pass force: true to delete it anyway.

iex> Auth0Client.Management.Action.delete("act_abc123")
iex> Auth0Client.Management.Action.delete("act_abc123", force: true)

deploy(id)

Deploys an action, creating a new version from the current draft.

Auth0 accepts this asynchronously and answers 202, so a successful return means the deployment was accepted rather than finished. Poll get/1 for the status.

iex> Auth0Client.Management.Action.deploy("act_abc123")

deploy_version(action_id, version_id, body \\ %{})

Rolls an action back to an earlier version by redeploying it.

Pass %{update_draft: true} to overwrite the draft with that version's code as well. Like deploy/1, Auth0 answers 202.

iex> Auth0Client.Management.Action.deploy_version("act_abc123", "ver_1")
iex> Auth0Client.Management.Action.deploy_version("act_abc123", "ver_1", %{update_draft: true})

execution(id)

Gets the details of an action execution, including logs from each bound action

iex> Auth0Client.Management.Action.execution("exec_abc123")

get(id)

Gets a single action

iex> Auth0Client.Management.Action.get("act_abc123")

test(id, payload)

Runs an action against a test payload without deploying it.

The payload is nested under payload for you.

iex> Auth0Client.Management.Action.test("act_abc123", %{user: %{email: "test@example.com"}})

triggers()

Gets the available triggers and their current versions.

Use this to find the id and version for create/1's supported_triggers.

iex> Auth0Client.Management.Action.triggers()

update(id, body)

Updates an action's code, dependencies, secrets or supported triggers.

Changes affect the draft; call deploy/1 to make them live.

iex> Auth0Client.Management.Action.update("act_abc123", %{code: "exports.onExecutePostLogin = async () => {};"})

update_bindings(trigger_id, bindings)

Sets the actions bound to a trigger.

This replaces every binding on the trigger

It is not additive. Passing one binding unbinds every other action on that trigger. Read bindings/2 first and pass the existing list back with your change applied.

Order is significant — Auth0 executes bound actions in the order given.

Each binding is %{ref: %{type: "action_id", value: id}, display_name: name}; ref may also use type: "action_name".

iex> Auth0Client.Management.Action.update_bindings("post-login", [
...>   %{ref: %{type: "action_id", value: "act_abc123"}, display_name: "Enrich profile"}
...> ])

version(action_id, version_id)

Gets a specific version of an action

iex> Auth0Client.Management.Action.version("act_abc123", "ver_1")

versions(action_id, params \\ %{})

Gets an action's deployed versions

iex> Auth0Client.Management.Action.versions("act_abc123")
iex> Auth0Client.Management.Action.versions("act_abc123", per_page: 10)