ActionsManager

ActionsManager

Actions provide a way to extend Auth0 flows with custom logic. See the Actions documentation for more information.

Constructor

new ActionsManager(options)

Source:
Parameters:
Name Type Description
options object

The client options.

Name Type Attributes Description
baseUrl string

The URL of the API.

headers object <optional>

Headers to be included in all requests.

retry object <optional>

Retry Policy Config

Members

resource :external:RestClient

Provides an abstraction layer for consuming the Auth0 Actions endpoint.

Source:
Type:

Methods

create(data, cbopt) → {Promise|undefined}

Create a new Action.

Source:
Parameters:
Name Type Attributes Description
data object

Action data object.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
management.actions.create(data, function (err) {
  if (err) {
    // Handle error.
  }

  // Action created.
});

createVersion(params, data, cbopt) → {Promise|undefined}

Create an Action Version. In general, updating an action and then deploying it is the preferred way of creating an action version, but this operation is supported as a way of creating versions without updating the action's code (which can be useful in some CI/CD scenarios).

Source:
Parameters:
Name Type Attributes Description
params object

Action parameters.

Name Type Description
id string

Action ID.

data object

ActionVersion parameters.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params = { id: ACTION_ID };
management.actions.createActionVersion(params, data, function (err, actionVersion) {
  if (err) {
    // Handle error.
  }
});

delete(params, cbopt) → {Promise|undefined}

Delete an existing action. Deleting an Action deletes all the action's versions

Source:
Parameters:
Name Type Attributes Description
params object

Action parameters.

Name Type Description
id string

Action ID.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
management.actions.delete({ id: ACTION_ID }, function (err) {
  if (err) {
    // Handle error.
  }

  // Action deleted.
});

deploy(params, cbopt) → {Promise|undefined}

deploy an Action. The action must be in a state of 'built' before it can be deployed.

Source:
Parameters:
Name Type Attributes Description
params object

Action parameters.

Name Type Description
id string

Action ID.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params = { id: ACTION_ID};
mangement.actions.deploy(params, function (err, actionVersion) {
  if (err) {
    // Handle error.
  }
});

deployVersion(params, cbopt) → {Promise|undefined}

deploy an Action Version to roll back to a previous version.

Source:
Parameters:
Name Type Attributes Description
params object

Action parameters.

Name Type Description
id string

Action ID.

version_id string

Action ID.

update_draft boolean

Update draft

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params = { id: ACTION_ID, version_id: VERSION_ID };
management.actions.deployVersion(params, function (err, actionVersion) {
  if (err) {
    // Handle error.
  }
});

get(params, cbopt) → {Promise|undefined}

Get an Auth0 action.

Source:
Parameters:
Name Type Attributes Description
params object

Action parameters.

Name Type Description
id string

Action ID.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
management.actions.get({ id: ACTION_ID }, function (err, action) {
  if (err) {
    // Handle error.
  }

  console.log(action);
});

getAll(paramsopt, cbopt) → {Promise|undefined}

Get all actions.

Source:
Parameters:
Name Type Attributes Description
params object <optional>

Actions parameters.

Name Type Attributes Description
per_page number <optional>

Number of results per page.

page number <optional>

Page number, zero indexed.

triggerId string <optional>

The trigger ID of the actions to retrieve.

actionName string <optional>

The name of the actions to retrieve.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example

This method takes an optional object as first argument that may be used to specify pagination settings. If pagination options are not present, the first page of a limited number of results will be returned.

// Pagination settings.
var params = {
  per_page: 10,
  page: 0,
  triggerId:'TRIGGER_ID',
  actionName: 'ACTION_NAME'
};

management.actions.getAll(params, function (err, actions) {
  console.log(actions.length);
});

getAllTriggers(paramsopt, cbopt) → {Promise|undefined}

Get all Triggers.

Source:
Parameters:
Name Type Attributes Description
params object <optional>

Actions parameters.

Name Type Attributes Description
per_page number <optional>

Number of results per page.

page number <optional>

Page number, zero indexed.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example

This method takes an optional object as first argument that may be used to specify pagination settings. If pagination options are not present, the first page of a limited number of results will be returned.

// Pagination settings.
var params = {
  per_page: 10,
  page: 0
};

management.actions.getAllTriggers(params, function (err, actions) {
  console.log(actions.length);
});

getExecution(params, cbopt) → {Promise|undefined}

Get an execution by ID.

Source:
Parameters:
Name Type Attributes Description
params object

Action Execution parameters.

Name Type Description
id string

Action Execution ID.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
management.actions.getExecution({ execution_id: EXECUTION_ID }, function (err, action) {
  if (err) {
    // Handle error.
  }

  console.log(ActionExecution);
});

getTriggerBindings(params, cbopt) → {Promise|undefined}

Get the actions bound to a trigger .

Source:
Parameters:
Name Type Attributes Description
params object

Actions Binding parameters.

Name Type Description
trigger_id string

Actions Trigger ID.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params = { trigger_id: TRIGGER_ID };

// Using auth0 instance.
management.actions.getTriggerBindings(params, function (err, bindings) {
  if (err) {
    // Handle error.
  }

  console.log(bindings.length);  // 2
});

getVersion(params, cbopt) → {Promise|undefined}

Get an Action Version.

Source:
Parameters:
Name Type Attributes Description
params object

Action parameters.

Name Type Description
id string

Action ID.

version_id string

ActionVersion ID.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params = { id: ACTION_ID, version_id: VERSION_ID };
management.actions.getVersion(params, function (err, actionVersion) {
  if (err) {
    // Handle error.
  }
});

getVersions(paramsopt, cbopt) → {Promise|undefined}

Get all action versions

Source:
Parameters:
Name Type Attributes Description
params object <optional>

ActionVersions parameters.

Name Type Attributes Description
per_page number <optional>

Number of results per page.

page number <optional>

Page number, zero indexed.

id string <optional>

Action ID.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example

This method takes an optional object as first argument that may be used to specify pagination settings. If pagination options are not present, the first page of a limited number of results will be returned.

// Pagination settings.
var params = {
  per_page: 10,
  page: 0
};

management.actions.getVersions({ id: ACTION_ID }, function (err, actionVersions) {
  console.log(actionVersions.length);
});

test(params, payload, cbopt) → {Promise|undefined}

test an Action.

Source:
Parameters:
Name Type Attributes Description
params object

Action parameters.

Name Type Description
id string

Action ID.

payload object

Payload represents the entire structure necessary to test a particular trigger

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params = { id: ACTION_ID};
management.actions.test(params, payload, function (err) {
  if (err) {
    // Handle error.
  }
});

update(params, data, cbopt) → {Promise|undefined}

Update an existing action.

Source:
Parameters:
Name Type Attributes Description
params object

Action parameters.

Name Type Description
id string

Action ID.

data object

Updated action data.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var data = { name: 'new-name' };
var params = { id: ACTION_ID };

// Using auth0 instance.
management.updateAction(params, data, function (err, action) {
  if (err) {
    // Handle error.
  }

  console.log(action.name);  // 'new-name'
});

// Using the Actions manager directly.
management.actions.update(params, data, function (err, action) {
  if (err) {
    // Handle error.
  }

  console.log(action.name);  // 'new-name'
});

updateTriggerBindings(params, data, cbopt) → {Promise|undefined}

Update the actions bound to a trigger .

Source:
Parameters:
Name Type Attributes Description
params object

Actions Binding parameters.

Name Type Description
trigger_id string

Actions Trigger ID.

data object

bindings array

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var data = { bindings: [{ id_type: "action_id", id_value: ACTION_ID1},{id_type: "action_name", id_value: ACTION_NAME2}];
var params = { trigger_id: TRIGGER_ID };

// Using auth0 instance.
management.actions.updateTriggerBindings(params, data, function (err, bindings) {
  if (err) {
    // Handle error.
  }

  console.log(bindings.length);  // 2
});