Skip to main content
Actions are serverless functions that execute custom logic during specific points in the Auth0 authentication and authorization flow. Use this API to manage actions, their versions, deployments, and test executions.

List Actions

Retrieves a paginated list of all actions in your tenant.
func (c *Client) List(
    ctx context.Context,
    request *management.ListActionsRequestParameters,
    opts ...option.RequestOption,
) (*core.Page[*int, *management.Action, *management.ListActionsPaginatedResponseContent], error)
ctx
context.Context
required
Context for the request
request
*management.ListActionsRequestParameters
Query parameters for filtering and pagination:
  • TriggerId - Filter by trigger ID
  • ActionName - Filter by action name
  • Deployed - Filter by deployment status
  • Installed - Filter by installation status
  • Page - Page number (default: 0)
  • PerPage - Number of results per page (default: 50)
opts
...option.RequestOption
Optional request options

Example

import (
    "context"
    "github.com/auth0/go-auth0/v2/management"
)

params := &management.ListActionsRequestParameters{
    PerPage: management.Int(25),
}

page, err := client.Management.Actions.List(context.TODO(), params)
if err != nil {
    log.Fatalf("Failed to list actions: %v", err)
}

for _, action := range page.Results {
    fmt.Printf("Action: %s (ID: %s)\n", action.GetName(), action.GetID())
}

Get Action

Retrieves details for a specific action by its ID.
func (c *Client) Get(
    ctx context.Context,
    id string,
    opts ...option.RequestOption,
) (*management.GetActionResponseContent, error)
ctx
context.Context
required
Context for the request
id
string
required
The ID of the action to retrieve
opts
...option.RequestOption
Optional request options
action
*management.GetActionResponseContent
Returns the action with properties:
  • ID - Unique action identifier
  • Name - Action name
  • SupportedTriggers - List of triggers this action supports
  • Code - The action’s source code
  • Dependencies - NPM dependencies
  • Runtime - Node.js runtime version
  • Secrets - List of secrets
  • DeployedVersion - Currently deployed version
  • Status - Build status
  • AllChangesDeployed - Whether all changes are deployed

Example

action, err := client.Management.Actions.Get(
    context.TODO(),
    "act_1234567890",
)
if err != nil {
    log.Fatalf("Failed to get action: %v", err)
}

fmt.Printf("Action: %s\n", action.GetName())
fmt.Printf("Runtime: %s\n", action.GetRuntime())

Create Action

Creates a new action. Once created, the action must be deployed and bound to a trigger before it executes.
func (c *Client) Create(
    ctx context.Context,
    request *management.CreateActionRequestContent,
    opts ...option.RequestOption,
) (*management.CreateActionResponseContent, error)
ctx
context.Context
required
Context for the request
request
*management.CreateActionRequestContent
required
The action configuration:
  • Name - Action name (required)
  • SupportedTriggers - List of triggers (required)
  • Code - Action source code
  • Dependencies - NPM dependencies
  • Runtime - Node.js runtime (e.g., “node22”)
  • Secrets - List of secrets
  • Deploy - Whether to deploy immediately
opts
...option.RequestOption
Optional request options

Example

trigger := &management.ActionTrigger{
    ID:      management.String("post-login"),
    Version: management.String("v3"),
}

action := &management.CreateActionRequestContent{
    Name: "my-custom-action",
    SupportedTriggers: []*management.ActionTrigger{trigger},
    Code: management.String(`
exports.onExecutePostLogin = async (event, api) => {
    console.log("User logged in:", event.user.email);
};
    `),
    Runtime: management.String("node22"),
}

created, err := client.Management.Actions.Create(context.TODO(), action)
if err != nil {
    log.Fatalf("Failed to create action: %v", err)
}

fmt.Printf("Created action: %s\n", created.GetID())

Update Action

Updates an existing action. If the action is bound to a trigger, updating it will not affect user flows until deployed.
func (c *Client) Update(
    ctx context.Context,
    id string,
    request *management.UpdateActionRequestContent,
    opts ...option.RequestOption,
) (*management.UpdateActionResponseContent, error)
ctx
context.Context
required
Context for the request
id
string
required
The ID of the action to update
request
*management.UpdateActionRequestContent
required
The fields to update:
  • Name - Action name
  • Code - Action source code
  • Dependencies - NPM dependencies
  • Runtime - Node.js runtime
  • Secrets - List of secrets
opts
...option.RequestOption
Optional request options

Example

update := &management.UpdateActionRequestContent{
    Code: management.String(`
exports.onExecutePostLogin = async (event, api) => {
    console.log("Updated action code");
};
    `),
}

updated, err := client.Management.Actions.Update(
    context.TODO(),
    "act_1234567890",
    update,
)
if err != nil {
    log.Fatalf("Failed to update action: %v", err)
}

Delete Action

Deletes an action and all its associated versions. The action must be unbound from all triggers before deletion.
func (c *Client) Delete(
    ctx context.Context,
    id string,
    request *management.DeleteActionRequestParameters,
    opts ...option.RequestOption,
) error
ctx
context.Context
required
Context for the request
id
string
required
The ID of the action to delete
request
*management.DeleteActionRequestParameters
Query parameters:
  • Force - Force deletion even if the action is bound
opts
...option.RequestOption
Optional request options

Example

err := client.Management.Actions.Delete(
    context.TODO(),
    "act_1234567890",
    &management.DeleteActionRequestParameters{},
)
if err != nil {
    log.Fatalf("Failed to delete action: %v", err)
}

Deploy Action

Deploys an action, creating a new immutable version. If bound to a trigger, the new version executes immediately.
func (c *Client) Deploy(
    ctx context.Context,
    id string,
    opts ...option.RequestOption,
) (*management.DeployActionResponseContent, error)
ctx
context.Context
required
Context for the request
id
string
required
The ID of the action to deploy
opts
...option.RequestOption
Optional request options

Example

deployed, err := client.Management.Actions.Deploy(
    context.TODO(),
    "act_1234567890",
)
if err != nil {
    log.Fatalf("Failed to deploy action: %v", err)
}

fmt.Printf("Deployed version: %s\n", deployed.DeployedVersion.GetNumber())

Test Action

Tests an action prior to deployment to ensure it behaves as expected.
func (c *Client) Test(
    ctx context.Context,
    id string,
    request *management.TestActionRequestContent,
    opts ...option.RequestOption,
) (*management.TestActionResponseContent, error)
ctx
context.Context
required
Context for the request
id
string
required
The ID of the action to test
request
*management.TestActionRequestContent
required
Test payload:
  • Payload - The test event payload
opts
...option.RequestOption
Optional request options

Example

testPayload := &management.TestActionRequestContent{
    Payload: map[string]interface{}{
        "user": map[string]interface{}{
            "email": "[email protected]",
        },
    },
}

result, err := client.Management.Actions.Test(
    context.TODO(),
    "act_1234567890",
    testPayload,
)
if err != nil {
    log.Fatalf("Failed to test action: %v", err)
}

fmt.Printf("Test result: %+v\n", result)

Build docs developers (and LLMs) love