---
updatedAt: 2026-04-20T19:21:14.000Z
---

# Link or unlink accounts

Account linking/unlinking requires a valid access token (from a previous Authentication or Registration). It is not possible to link one existing user record to another, so the only scenario that needs to be addressed is linking to a Social account.

For linking and unlinking, it will be necessary to first make an API call to the [/entity](https://techdocs.akamai.com/identity-cloud-entity/reference/post-entity) operation to retrieve or to verify the current list of the user’s linked accounts.

[block:code]
{
  "codes": [
    {
      "code": "$api_call= '/entity';\n$params= array(\n    'access_token'=> $_SESSION['access_token'],\n    // attributes containing user's linked accounts\n    'attributes'=> '[\"profiles.domain\", \"profiles.identifier\"]'\n);\n$curl= curl_init();\ncurl_setopt($curl,CURLOPT_URL,JANRAIN_CAPTURE_URL.$api_call);\ncurl_setopt($curl,CURLOPT_POST,true);\ncurl_setopt($curl,CURLOPT_RETURNTRANSFER,true);\ncurl_setopt($curl,CURLOPT_POSTFIELDS,http_build_query($params));\n$api_response= json_decode(curl_exec($curl));\ncurl_close($curl);",
      "language": "curl"
    }
  ]
}
[/block]

<br />

# Account link

1. Authenticate with the social provider to retrieve the social login token. (See [Social login configuration guides](https://techdocs.akamai.com/identity-cloud/docs/social-login-identity-provider-configuration-guides) for instructions.)

2. Link the social account via the [oauth/link\_account\_native](https://techdocs.akamai.com/identity-cloud-auth/reference/post-oauth-link-account-native) call.

For example:

[block:code]
{
  "codes": [
    {
      "code": "$api_call= '/oauth/link_account_native';\n$params= array(\n    'client_id'=> JANRAIN_LOGIN_CLIENT_ID,\n    'flow'=> JANRAIN_FLOW_NAME,\n    'flow_version'=> JANRAIN_FLOW_VERSION,\n    'locale'=> 'en-US',\n    'redirect_uri'=> 'https://localhost',\n    // valid access token\n    'access_token'=> $_SESSION['access_token'],\n    // social login token obtained from previous step\n    'token'=> $_POST['token']\n);\n$curl= curl_init();\ncurl_setopt($curl,CURLOPT_URL,JANRAIN_CAPTURE_URL.$api_call);\ncurl_setopt($curl,CURLOPT_POST,true);\ncurl_setopt($curl,CURLOPT_RETURNTRANSFER,true);\ncurl_setopt($curl,CURLOPT_POSTFIELDS,http_build_query($params));\n$api_response= json_decode(curl_exec($curl));\ncurl_close($curl);",
      "language": "curl"
    }
  ]
}
[/block]

| **Response**                                      | **Outcome / Next Step**                   |
| :------------------------------------------------ | :---------------------------------------- |
| Success (ok)                                      | Account is linked.                        |
| Social account already exists (unique\_violation) | Provide a resolution path for this error. |

<br />

# Account unlink

Unlink a social account via the /oauth/unlink\_account\_native call.

[block:code]
{
  "codes": [
    {
      "code": "$api_call= '/oauth/unlink_account_native';\n$params= array(\n    'client_id'=> JANRAIN_LOGIN_CLIENT_ID,\n    'flow'=> JANRAIN_FLOW_NAME,\n    'flow_version'=> JANRAIN_FLOW_VERSION,\n    'locale'=> 'en-US',\n    // valid access token\n    'access_token'=> $_SESSION['access_token'],\n    // identifier value from profiles.[profile].identifier schema attribute\n    'identifier_to_remove'=> $_POST['identifier']\n);\n$curl= curl_init();\ncurl_setopt($curl,CURLOPT_URL,JANRAIN_CAPTURE_URL.$api_call);\ncurl_setopt($curl,CURLOPT_POST,true);\ncurl_setopt($curl,CURLOPT_RETURNTRANSFER,true);\ncurl_setopt($curl,CURLOPT_POSTFIELDS,http_build_query($params));\n$api_response= json_decode(curl_exec($curl));\ncurl_close($curl);",
      "language": "curl"
    }
  ]
}
[/block]

| **Response** | **Outcome / Next Step** |
| :----------- | :---------------------- |
| Success (ok) | Account is unlinked.    |

# Sibling pages

* [Complete traditional login and registration](https://techdocs.akamai.com/identity-cloud/docs/traditional-login-and-registration-api-based.md)
* [Complete social login and registration](https://techdocs.akamai.com/identity-cloud/docs/social-login-and-registration-api-based.md)
* [Merge accounts](https://techdocs.akamai.com/identity-cloud/docs/account-merging-api-based.md)
* [Verify an email address](https://techdocs.akamai.com/identity-cloud/docs/email-verification-api-based.md)
* [Reset a password](https://techdocs.akamai.com/identity-cloud/docs/the-forgot-password-process-api-based.md)
* [Update a user profile](https://techdocs.akamai.com/identity-cloud/docs/user-profile-update-api-based.md)
* [Exchange an authorization code](https://techdocs.akamai.com/identity-cloud/docs/the-exchange-authorization-code-process-api-based.md)