Learn how to use the Management API Unlink a User Account endpoint to unlink an identity from the target user account making it a separate user account again.
Use this file to discover all available pages before exploring further.
Use the Auth0 Unlink a User Account endpoint or the Auth0.js library to unlink an identity from the target user account making it a separate user account again.The result of the unlinking process is the following:
The secondary account is removed from the identities array of the primary account.
A new secondary user account is created.
The secondary account will have no metadata.
If your goal is to delete the secondary identity entirely, you must first unlink the accounts, and then delete the newly created secondary account.Depending on from where you call the endpoint, use one of these two scopes:
identity provider name of the secondary linked account (e.g. google-oauth2)
user_id
string
ID of the secondary linked account (e.g. 123456789081523216417 part after the `
If your instance has users from multiple providers, you may also include [connection_name]| before the user_id stringto name the provider (for example, "user-id": "google-oauth2|123456789081523216417").
function unlinkAccount(secondaryProvider, secondaryUserId) { var primaryUserId = localStorage.getItem('user_id'); var primaryAccessToken = localStorage.getItem('access_token'); // Uses the Access Token of the primary user as a bearer token to identify the account // which will have the account unlinked to, and the user id of the secondary user, to identify // the user that will be unlinked from the primary account. $.ajax({ type: 'DELETE', url: 'https://' + AUTH0_DOMAIN +'/api/v2/users/' + primaryUserId + '/identities/' + secondaryProvider + '/' + secondaryUserId, headers: { 'Authorization': 'Bearer ' + primaryAccessToken } }).then(function(identities){ alert('unlinked!'); showLinkedAccounts(identities); }).fail(function(jqXHR){ alert('Error unlinking Accounts: ' + jqXHR.status + ' ' + jqXHR.responseText); });}