ManagementClient

management. ManagementClient

ManagementClient Management API SDK. The Auth0 Management API is meant to be used by back-end servers or trusted parties performing administrative tasks. Generally speaking, anything that can be done through the Auth0 dashboard (and more) can also be done through this API.

Constructor

new ManagementClient(options)

Parameters:
Name Type Description
options Object Options for the ManagementClient SDK.
Properties
Name Type Attributes Description
token String API access token.
domain String <optional>
ManagementClient server domain.
Source:
Example

Initialize your client class with an API v2 token (you can generate one here) and a domain.

var ManagementClient = require('auth0').ManagementClient;
var auth0 = new ManagementClient({
  token: '{YOUR_API_V2_TOKEN}',
  domain: '{YOUR_ACCOUNT}.auth0.com'
});

Members

blacklistedTokens :BlacklistedtokensManager

Simple abstraction for performing CRUD operations on the blacklisted tokens endpoint.
Type:
  • BlacklistedtokensManager
Source:

clients :ClientsManager

Simple abstraction for performing CRUD operations on the clients endpoint.
Type:
  • ClientsManager
Source:

connections :ConnectionsManager

Simple abstraction for performing CRUD operations on the connections endpoint.
Type:
  • ConnectionsManager
Source:

deviceCredentials :DeviceCredentialsManager

Simple abstraction for performing CRUD operations on the device credentials endpoint.
Type:
  • DeviceCredentialsManager
Source:

emailProvider :EmailProviderManager

Simple abstraction for performing CRUD operations on the email provider endpoint.
Type:
  • EmailProviderManager
Source:

jobs :JobsManager

Jobs manager.
Type:
  • JobsManager
Source:

logs :LogsManager

Logs manager.
Type:
  • LogsManager
Source:

rules :RulesManager

Simple abstraction for performing CRUD operations on the rules endpoint.
Type:
  • RulesManager
Source:

stats :StatsManager

ManagementClient account statistics manager.
Type:
  • StatsManager
Source:

tenant :TenantManager

ManagementClient tenant settings manager.
Type:
  • TenantManager
Source:

tickets :TicketsManager

Tickets manager.
Type:
  • TicketsManager
Source:

users :UsersManager

Simple abstraction for performing CRUD operations on the users endpoint.
Type:
  • UsersManager
Source:

Methods

blacklistToken(token, cbopt) → {Promise|undefined}

Blacklist a new token.
Parameters:
Name Type Attributes Description
token Object Token data.
Properties
Name Type Description
aud String Audience (your app client ID).
jti String The JWT ID claim.
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
var token = {
 aud: 'aud',
 jti: 'jti'
};

management.blacklistToken(token, function (err) {
  if (err) {
    // Handle error.
  }

  // Token blacklisted.
});

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

Configure the email provider.
Parameters:
Name Type Attributes Description
data Object The email provider data object.
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
management.configureEmailProvider(data, function (err) {
  if (err) {
    // Handle error.
  }

  // Email provider configured.
});

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

Create an Auth0 client.
Parameters:
Name Type Attributes Description
data Object The client data object.
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
management.createClient(data, function (err) {
  if (err) {
    // Handle error.
  }

  // Client created.
});

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

Create a new connection.
Parameters:
Name Type Attributes Description
data Object Connection data object.
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
management.createConnection(data, function (err) {
  if (err) {
    // Handle error.
  }

  // Conection created.
});

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

Create an Auth0 credential.
Parameters:
Name Type Attributes Description
data Object The device credential data object.
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
management.createConnection(data, function (err) {
  if (err) {
    // Handle error.
  }

  // Credential created.
});

createEmailVerificationTicket(cbopt) → {Promise}

Create an email verification ticket.
Parameters:
Name Type Attributes Description
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise
Example
var data = {
  user_id: '{USER_ID}',
  result_url: '{REDIRECT_URL}' // Optional redirect after the ticket is used.
};

auth0.createEmailVerificationTicket(data, function (err) {
  if (err) {
    // Handle error.
  }
});

createPasswordChangeTicket(cbopt) → {Promise}

Create a new password change ticket.
Parameters:
Name Type Attributes Description
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise
Example
var params = {
  result_url: '{REDIRECT_URL}',  // Redirect after using the ticket.
  user_id: '{USER_ID}',  // Optional.
  email: '{USER_EMAIL}',  // Optional.
  new_password: '{PASSWORD}'
};

auth0.createPasswordChangeTicket(params, function (err) {
  if (err) {
    // Handle error.
  }
});

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

Create a new rule.
Parameters:
Name Type Attributes Description
data Object Rule data object.
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
management.createRule(data, function (err) {
  if (err) {
    // Handle error.
  }

  // Rule created.
});

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

Create a new user.
Parameters:
Name Type Attributes Description
data Object User data.
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
management.createUser(data, function (err) {
  if (err) {
    // Handle error.
  }

  // User created.
});

deleteAllUsers(cbopt) → {Promise|undefined}

Delete all users.
Parameters:
Name Type Attributes Description
cb function <optional>
Callback function
Source:
Returns:
Type
Promise | undefined
Example
management.deleteAllUsers(function (err) {
  if (err) {
    // Handle error.
  }

  // Users deleted
});

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

Delete an Auth0 client.
Parameters:
Name Type Attributes Description
params Object Client parameters.
Properties
Name Type Description
client_id String Application client ID.
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
management.deleteClient({ client_id: CLIENT_ID }, function (err) {
  if (err) {
    // Handle error.
  }

  // Client deleted.
});

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

Delete an existing connection.
Parameters:
Name Type Attributes Description
params Object Connection parameters.
Properties
Name Type Description
id String Connection ID.
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
management.deleteConnection({ id: CONNECTION_ID }, function (err) {
  if (err) {
    // Handle error.
  }

  // Conection deleted.
});

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

Delete an Auth0 device credential.
Parameters:
Name Type Attributes Description
params Object Credential parameters.
Properties
Name Type Description
id String Device credential ID.
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
var params = { id: CREDENTIAL_ID };

management.deleteDeviceCredential(params, function (err) {
  if (err) {
    // Handle error.
  }

  // Credential deleted.
});

deleteEmailProvider(cbopt) → {Promise|undefined}

Delete email provider.
Parameters:
Name Type Attributes Description
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
management.deleteEmailProvider(function (err) {
  if (err) {
    // Handle error.
  }

  // Email provider deleted.
});

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

Delete an existing rule.
Parameters:
Name Type Attributes Description
params Object Rule parameters.
Properties
Name Type Description
id String Rule ID.
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
auth0.deleteRule({ id: RULE_ID }, function (err) {
  if (err) {
    // Handle error.
  }

  // Rule deleted.
});

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

Delete a user by its id.
Parameters:
Name Type Attributes Description
params Object The user data object..
Properties
Name Type Description
id String The user id.
cb function <optional>
Callback function
Source:
Returns:
Type
Promise | undefined
Example
management.deleteUser({ id: USER_ID }, function (err) {
  if (err) {
    // Handle error.
  }

  // User deleted.
});

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

Delete a multifactor provider for a user.
Parameters:
Name Type Attributes Description
params Object Data object.
Properties
Name Type Description
id String The user id.
provider String Multifactor provider.
cb function <optional>
Callback function
Source:
Returns:
Type
Promise | undefined
Example
var params = { id: USER_ID, provider: MULTIFACTOR_PROVIDER };

management.deleteUserMultifcator(params, function (err, user) {
  if (err) {
    // Handle error.
  }

  // Users accounts unlinked.
});

getActiveUsersCount(cbopt) → {Promise|undefined}

Get a the active users count.
Parameters:
Name Type Attributes Description
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
management.getActiveUsersCount(function (err, usersCount) {
  if (err) {
    // Handle error.
  }

  console.log(usersCount);
});

getBlacklistedTokens(cbopt) → {Promise|undefined}

Get all blacklisted tokens.
Parameters:
Name Type Attributes Description
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
management.getBlacklistedTokens(function (err, tokens) {
  console.log(tokens.length);
});

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

Get an Auth0 client.
Parameters:
Name Type Attributes Description
params Object Client parameters.
Properties
Name Type Description
client_id String Application client ID.
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
management.getClient({ client_id: CLIENT_ID }, function (err, client) {
  if (err) {
    // Handle error.
  }

  console.log(client);
});

getClientInfo() → {Object}

Return an object with information about the current client,
Source:
Returns:
Object containing client information.
Type
Object

getClients(cbopt) → {Promise|undefined}

Get all Auth0 clients.
Parameters:
Name Type Attributes Description
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
management.getClients(function (err, clients) {
  console.log(clients.length);
});

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

Get an Auth0 connection.
Parameters:
Name Type Attributes Description
params Object Connection parameters.
Properties
Name Type Description
id String Connection ID.
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
management.getConnection({ id: CONNECTION_ID }, function (err, connection) {
  if (err) {
    // Handle error.
  }

  console.log(connection);
});

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

Get all connections.
Parameters:
Name Type Attributes Description
data Object Connection data object.
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
management.getConnections(function (err, connections) {
  console.log(connections.length);
});

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

Get the daily stats.
Parameters:
Name Type Attributes Description
params Object Stats parameters.
Properties
Name Type Description
from String The first day in YYYYMMDD format.
to String The last day in YYYYMMDD format.
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
var params = {
  from: '{YYYYMMDD}',  // First day included in the stats.
  to: '{YYYYMMDD}'  // Last day included in the stats.
};

management.getDaily(params, function (err, stats) {
  if (err) {
    // Handle error.
  }

  console.log(stats);
});

getDeviceCredentials(cbopt) → {Promise|undefined}

Get all Auth0 credentials.
Parameters:
Name Type Attributes Description
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
management.getDeviceCredentials(function (err, credentials) {
  console.log(credentials.length);
});

getEmailProvider(cbopt) → {Promise|undefined}

Get the email provider.
Parameters:
Name Type Attributes Description
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
management.getEmailProvider(function (err, provider) {
  console.log(provider.length);
});

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

Get a job by its ID.
Parameters:
Name Type Attributes Description
params Object Job parameters.
Properties
Name Type Description
id String Job ID.
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
var params = {
  id: '{JOB_ID}'
};

management.getJob(params, function (err, job) {
  if (err) {
    // Handle error.
  }

  // Retrieved job.
  console.log(job);
});

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

Get an Auth0 log.
Parameters:
Name Type Attributes Description
params Object Log parameters.
Properties
Name Type Description
id String Event ID.
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
management.getLog({ id: EVENT_ID }, function (err, log) {
  if (err) {
    // Handle error.
  }

  console.log(log);
});

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

Get all logs.
Parameters:
Name Type Attributes Description
data Object Log data object.
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
management.getLogs(function (err, logs) {
  console.log(logs.length);
});

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

Get an Auth0 rule.
Parameters:
Name Type Attributes Description
params Object Rule parameters.
Properties
Name Type Description
id String Rule ID.
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
management.getRule({ id: RULE_ID }, function (err, rule) {
  if (err) {
    // Handle error.
  }

  console.log(rule);
});

getRules(cbopt) → {Promise|undefined}

Get all rules.
Parameters:
Name Type Attributes Description
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
management.getRules(function (err, rules) {
  console.log(rules.length);
});

getTenantSettings(cbopt) → {Promise|undefined}

Get the tenant settings..
Parameters:
Name Type Attributes Description
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
management.getSettings(function (err, settings) {
  if (err) {
    // Handle error.
  }

  console.log(settings);
});

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

Get a user by its id.
Parameters:
Name Type Attributes Description
data Object The user data object.
Properties
Name Type Description
id String The user id.
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
management.getUser({ id: USER_ID }, function (err, user) {
  console.log(user);
});

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

Get all users.
Parameters:
Name Type Attributes Description
params Object <optional>
Users params.
Properties
Name Type Attributes Description
per_page Number <optional>
Number of users per page.
page Number <optional>
Page number.
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example

This method takes an optional object as first argument that may be used to specify pagination settings and the search query.

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

auth0.getUsers(params, function (err, users) {
  console.log(users.length);
});

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

Given a path to a file and a connection id, create a new job that imports the users contained in the file and associate them with the given connection.
Parameters:
Name Type Attributes Description
data Object Users import data.
Properties
Name Type Description
connectionId String Connection for the users insertion.
users String Path to the users data file.
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
var params = {
  connection_id: '{CONNECTION_ID}',
  users: '{PATH_TO_USERS_FILE}'
};

management.get(params, function (err) {
  if (err) {
    // Handle error.
  }
});

linkUsers(userId, params, cbopt) → {Promise|undefined}

Link the user with another account.
Parameters:
Name Type Attributes Description
userId String ID of the primary user.
params Object Secondary user data.
Properties
Name Type Description
user_id String ID of the user to be linked.
connection_id String ID of the connection to be used.
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
var params = { id: USER_ID };
var data = {
  user_id: 'OTHER_USER_ID',
  connection_id: 'CONNECTION_ID'
};

management.linkUsers(params, data, function (err, user) {
  if (err) {
    // Handle error.
  }

  // Users linked.
});

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

Send a verification email to a user.
Parameters:
Name Type Attributes Description
data Object User data object.
Properties
Name Type Description
user_id String ID of the user to be verified.
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
var params = {
	user_id: '{USER_ID}'
};

management.sendEmailVerification(function (err) {
  if (err) {
    // Handle error.
  }
});

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

Unlink the given accounts.
Parameters:
Name Type Attributes Description
params Object Linked users data.
Properties
Name Type Description
id String Primary user ID.
provider String Identity provider in use.
user_id String Secondary user ID.
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
var params = { id: USER_ID, provider: 'auht0', user_id: OTHER_USER_ID };

management.unlinkUsers(params, function (err, user) {
  if (err) {
    // Handle error.
  }

  // Users accounts unlinked.
});

updateAppMetadata(params, metadata, cbopt) → {Promise|undefined}

Update the app metadata for a user.
Parameters:
Name Type Attributes Description
params Object The user data object..
Properties
Name Type Description
id String The user id.
metadata Object New app metadata.
cb function <optional>
Callback function
Source:
Returns:
Type
Promise | undefined
Example
var params = { id: USER_ID };
var metadata = {
  foo: 'bar'
};

management.updateAppMetadata(params, metadata, function (err, user) {
  if (err) {
    // Handle error.
  }

  // Updated user.
  console.log(user);
});

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

Update an Auth0 client.
Parameters:
Name Type Attributes Description
params Object Client parameters.
Properties
Name Type Description
client_id String Application client ID.
data Object Updated client data.
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
var data = { name: 'newClientName' };
var params = { client_id: CLIENT_ID };

management.updateClient(params, data, function (err, client) {
  if (err) {
    // Handle error.
  }

  console.log(client.name);  // 'newClientName'
});

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

Update an existing connection.
Parameters:
Name Type Attributes Description
params Object Conneciton parameters.
Properties
Name Type Description
id String Connection ID.
data Object Updated connection data.
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
var data = { name: 'newConnectionName' };
var params = { id: CONNECTION_ID };

management.updateConnection(params, data, function (err, connection) {
  if (err) {
    // Handle error.
  }

  console.log(connection.name);  // 'newConnectionName'
});

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

Update the email provider.
Parameters:
Name Type Attributes Description
data Object Updated email provider data.
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
management.updateEmailProvider(data, function (err, provider) {
  if (err) {
    // Handle error.
  }

  // Updated email provider.
  console.log(provider);
});

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

Delete an existing rule.
Parameters:
Name Type Attributes Description
params Object Rule parameters.
Properties
Name Type Description
id String Rule ID.
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
management.deleteRule({ id: RULE_ID }, function (err) {
  if (err) {
    // Handle error.
  }

  // Rule deleted.
});

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

Update the tenant settings.
Parameters:
Name Type Attributes Description
data Object The new tenant settings.
cb function <optional>
Callback function.
Source:
Returns:
Type
Promise | undefined
Example
management.updateTenantSettings(data, function (err) {
  if (err) {
    // Handle error.
  }
});

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

Update a user by its id.
Parameters:
Name Type Attributes Description
params Object The user parameters.
Properties
Name Type Description
id String The user id.
data Object New user data.
cb function <optional>
Callback function
Source:
Returns:
Type
Promise | undefined
Example
var params = { id: USER_ID };

management.updateUser(params, data, function (err, user) {
  if (err) {
    // Handle error.
  }

  // Updated user.
  console.log(user);
});

updateUserMetadata(params, metadata, cbopt) → {Promise|undefined}

Update the user metadata for a user.
Parameters:
Name Type Attributes Description
params Object The user data object..
Properties
Name Type Description
id String The user id.
metadata Object New user metadata.
cb function <optional>
Callback function
Source:
Returns:
Type
Promise | undefined
Example
var params = { id: USER_ID };
var metadata = {
  address: '123th Node.js Street'
};

management.updateUserMetadata(params, metadata, function (err, user) {
  if (err) {
    // Handle error.
  }

  // Updated user.
  console.log(user);
});