> For the complete documentation index, see [llms.txt](/docs/llms.txt)

# Links | FusionAuth Docs

Learn about the APIs for creating, retrieving, and deleting Identity Provider Links.

# Links

Available since version `1.28.0`

This page contains the APIs that are used to manage Links that establish a relationship between a FusionAuth User and an Identity Provider.

## Link a User[#](#link-a-user)

This API is used to create a link between a FusionAuth User and a user in a 3rd party identity provider. This API may be useful when you already know the unique Id of a user in a 3rd party identity provider and the corresponding FusionAuth User.

### Request[#](#request)

Available since version `1.43.0`

Link a User

POST/api/identity-provider/link

OpenAPI Spec

#### Request Headers[#](#request-headers)

`X-FusionAuth-TenantId`Stringoptional

The unique Id of the tenant used to scope this API request.

The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.

Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.

See [Making an API request using a Tenant Id](/docs/apis/authentication#making-an-api-request-using-a-tenant-id) for additional information.

#### Request Body[#](#request-body)

`identityProviderLink.displayName`Stringoptional

A optional human readable name for this link such as an email address, username or given name. This value should be used to make it easier to identify the user this link represents in the remote identity provider.

Please note, that this value will always be overwritten during login to reflect the most current information from the identity provider. In most cases this value will be an email address or username.

`identityProviderLink.identityProviderId`UUIDrequired

The Id of the identify provider that will be linked to the User.

`identityProviderLink.identityProviderUserId`Stringrequired

The Id for the user that is provided by the upstream identity provider. This is the value that will allow FusionAuth to link this User on future logins. This value is expected to be immutable.

`identityProviderLink.userId`UUIDrequired

The unique Id of the FusionAuth User that is being linked to the identity provider.

`identityProviderLink.token`Stringoptional

The token returned from the identity provider. This is treated as an opaque token as the type varies by identity provider, this value may not be returned by all identity providers. When provided, this token is typically a long lived access or refresh token, but consult individual identity provider documentation for specifics.

*Example Request JSON*

```
{
  "identityProviderLink": {
    "displayName": "richard@piedpiper.com",
    "identityProviderId": "f50dbb83-4cc2-4e5e-aece-9efe068bddd9",
    "identityProviderUserId": "42",
    "userId": "fbf0e652-b2b5-45eb-b9c9-d4640889740b",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
  }
}
```

Deprecated in version `1.43.0`

While this API is still functional, its usage is discouraged. When available please use the [Link a User endpoint](/docs/apis/identity-providers/links#link-a-user) which takes a different request body.

Link a User

POST/api/identity-provider/link

OpenAPI Spec

#### Request Headers[#](#request-headers)

`X-FusionAuth-TenantId`Stringoptional

The unique Id of the tenant used to scope this API request.

The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.

Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.

See [Making an API request using a Tenant Id](/docs/apis/authentication#making-an-api-request-using-a-tenant-id) for additional information.

#### Request Body[#](#request-body-1)

`displayName`StringoptionalAvailable since 1.28.1

An optional human readable name for this link such as an email address, username or given name. This value should be used to make it easier to identify the user this link represents in the remote identity provider.

Please note, that this value will always be overwritten during login to reflect the most current information from the identity provider. In most cases this value will be an email address or username.

`identityProviderId`UUIDrequired

The Id of the identity provider.

`identityProviderUserId`Stringrequired

The Id for the User that is provided by the identity provider. This is the value that will allow FusionAuth to link this user on future logins. This value is expected to be immutable.

`userId`UUIDrequired

The FusionAuth Id of the User that is being linked to the identity provider.

*Example Request JSON*

```
{
  "displayName": "richard@piedpiper.com",
  "identityProviderId": "f50dbb83-4cc2-4e5e-aece-9efe068bddd9",
  "identityProviderUserId": "42",
  "userId": "fbf0e652-b2b5-45eb-b9c9-d4640889740b"
}
```

### Response[#](#response)

*Response Codes*

| Code | Description |
| --- | --- |
| 200 | The request was successful. The response will contain a JSON body. |
| 400 | The request was invalid and/or malformed. The response will contain an [Errors](/docs/apis/errors) JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present. |
| 401 | You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See [Authentication](/docs/apis/authentication). |
| 409 | A conflict was encountered processing this request. |
| 500 | There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty. |
| 504 | One or more Webhook endpoints returned an invalid response or were unreachable. Based on the transaction configuration for this event your action cannot be completed. A stack trace is provided and logged in the FusionAuth log files. |

#### Response Body[#](#response-body)

`identityProviderLink.displayName`String

A optional human readable name for this link such as an email address, username or given name. This value should be used to make it easier to identify the user this link represents in the remote identity provider.

Please note, that this value will always be overwritten during login to reflect the most current information from the identity provider. In most cases this value will be an email address or username.

`identityProviderLink.identityProviderId`UUID

The unique Id of the identity provider.

`identityProviderLink.identityProviderName`StringAvailable since 1.47.0

The name of the identity provider.

`identityProviderLink.identityProviderType`String

The type of the identity provider.

`identityProviderLink.identityProviderUserId`String

The Id for the User that is provided by the identity provider.

`identityProviderLink.insertInstant`Long

The [instant](/docs/reference/data-types#instants) the Link was created.

`identityProviderLink.lastLoginInstant`Long

The last [instant](/docs/reference/data-types#instants) of the User's most recent login to the identity provider linked Application.

`identityProviderLink.tenantId`UUID

The Id of the Tenant that this User belongs to.

`identityProviderLink.token`String

The token returned from the identity provider. This is treated as an opaque token as the type varies by identity provider, this value may not be returned by all identity providers. When provided, this token is typically a long lived access or refresh token, but consult individual identity provider documentation for specifics.

`identityProviderLink.userId`UUID

The unique Id of the FusionAuth User that is linked to the identity provider.

*Example Response JSON*

```
{
  "identityProviderLink": {
    "displayName": "richard@piedpiper.com",
    "identityProviderId": "f50dbb83-4cc2-4e5e-aece-9efe068bddd9",
    "identityProviderName": "My OpenIDConnect Identity Provider",
    "identityProviderType": "OpenIDConnect",
    "identityProviderUserId": "42",
    "insertInstant": 1623183147998,
    "lastLoginInstant": 1623183152224,
    "tenantId": "30663132-6464-6665-3032-326466613934",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
    "userId": "fbf0e652-b2b5-45eb-b9c9-d4640889740b"
  }
}
```

## Complete a Pending Link[#](#complete-a-pending-link)

This API is used complete a pending link. If an identity provider is configured with a linking strategy of `Create a pending link`, a `pendingLinkId` will be returned by the Identity Provider API (see the `Complete the Login` section for each respective IdP). This value can be used in the request below.

### Request[#](#request-1)

Available Since Version `1.43.0`

Complete a pending Link

POST/api/identity-provider/link

OpenAPI Spec

#### Request Headers[#](#request-headers)

`X-FusionAuth-TenantId`Stringoptional

The unique Id of the tenant used to scope this API request.

The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.

Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.

See [Making an API request using a Tenant Id](/docs/apis/authentication#making-an-api-request-using-a-tenant-id) for additional information.

#### Request Body[#](#request-body-2)

`pendingIdPLinkId`Stringrequired

The pending identity provider link Id.

`identityProviderLink.userId`Stringrequired

The unique Id of the FusionAuth User that is being linked to the identity provider.

*Example Request JSON*

```
{
  "pendingIdPLinkId": "elY3lKxvCQvsH_kfEMmBNLIl6TmydtCrNjHpFgVdxb8",
  "identityProviderLink": {
    "userId": "fbf0e652-b2b5-45eb-b9c9-d4640889740b"
  }
}
```

Deprecated in version 1.43.0.

While this API is still functional, its usage is discouraged. When available please use the [Complete a Pending Link](/docs/apis/identity-providers/links#complete-a-pending-link) which takes a different request body.

Complete a pending Link

POST/api/identity-provider/link

OpenAPI Spec

#### Request Headers[#](#request-headers)

`X-FusionAuth-TenantId`Stringoptional

The unique Id of the tenant used to scope this API request.

The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.

Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.

See [Making an API request using a Tenant Id](/docs/apis/authentication#making-an-api-request-using-a-tenant-id) for additional information.

#### Request Body[#](#request-body-3)

`pendingIdPLinkId`Stringrequired

The pending identity provider link Id.

`userId`Stringrequired

The Id of the User that is being linked to the identity provider.

*Example Request JSON*

```
{
  "pendingIdPLinkId": "elY3lKxvCQvsH_kfEMmBNLIl6TmydtCrNjHpFgVdxb8",
  "userId": "fbf0e652-b2b5-45eb-b9c9-d4640889740b"
}
```

### Response[#](#response-1)

*Response Codes*

| Code | Description |
| --- | --- |
| 200 | The request was successful. The response will contain a JSON body. |
| 400 | The request was invalid and/or malformed. The response will contain an [Errors](/docs/apis/errors) JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present. |
| 401 | You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See [Authentication](/docs/apis/authentication). |
| 409 | A conflict was encountered processing this request. |
| 500 | There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty. |
| 504 | One or more Webhook endpoints returned an invalid response or were unreachable. Based on the transaction configuration for this event your action cannot be completed. A stack trace is provided and logged in the FusionAuth log files. |

#### Response Body[#](#response-body)

`identityProviderLink.displayName`String

A optional human readable name for this link such as an email address, username or given name. This value should be used to make it easier to identify the user this link represents in the remote identity provider.

Please note, that this value will always be overwritten during login to reflect the most current information from the identity provider. In most cases this value will be an email address or username.

`identityProviderLink.identityProviderId`UUID

The unique Id of the identity provider.

`identityProviderLink.identityProviderName`StringAvailable since 1.47.0

The name of the identity provider.

`identityProviderLink.identityProviderType`String

The type of the identity provider.

`identityProviderLink.identityProviderUserId`String

The Id for the User that is provided by the identity provider.

`identityProviderLink.insertInstant`Long

The [instant](/docs/reference/data-types#instants) the Link was created.

`identityProviderLink.lastLoginInstant`Long

The last [instant](/docs/reference/data-types#instants) of the User's most recent login to the identity provider linked Application.

`identityProviderLink.tenantId`UUID

The Id of the Tenant that this User belongs to.

`identityProviderLink.token`String

The token returned from the identity provider. This is treated as an opaque token as the type varies by identity provider, this value may not be returned by all identity providers. When provided, this token is typically a long lived access or refresh token, but consult individual identity provider documentation for specifics.

`identityProviderLink.userId`UUID

The unique Id of the FusionAuth User that is linked to the identity provider.

*Example Response JSON*

```
{
  "identityProviderLink": {
    "displayName": "richard@piedpiper.com",
    "identityProviderId": "f50dbb83-4cc2-4e5e-aece-9efe068bddd9",
    "identityProviderName": "My OpenIDConnect Identity Provider",
    "identityProviderType": "OpenIDConnect",
    "identityProviderUserId": "42",
    "insertInstant": 1623183147998,
    "lastLoginInstant": 1623183152224,
    "tenantId": "30663132-6464-6665-3032-326466613934",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
    "userId": "fbf0e652-b2b5-45eb-b9c9-d4640889740b"
  }
}
```

## Retrieve a Link[#](#retrieve-a-link)

This API is used to retrieve a single Link, all Links for a specific identity provider and user, or all Links for a user.

### Request[#](#request-2)

Retrieve a single link

GET/api/identity-provider/link?identityProviderId={identityProviderId}&identityProviderUserId={identityProviderUserId}&userId={userId}

OpenAPI Spec

#### Request Headers[#](#request-headers)

`X-FusionAuth-TenantId`Stringoptional

The unique Id of the tenant used to scope this API request.

The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.

Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.

See [Making an API request using a Tenant Id](/docs/apis/authentication#making-an-api-request-using-a-tenant-id) for additional information.

#### Request Parameters[#](#request-parameters)

`identityProviderId`UUIDrequired

The unique Id of the identity provider.

`identityProviderUserId`Stringrequired

The unique user Id in the 3rd party identity provider. Ideally this value never change and will always uniquely identify the user in the 3rd party identity provider.

`userId`UUIDoptional

The FusionAuth User Id that is linked to the identity provider. When this value is provided, a `404` status code will be returned if the link does not exist, or the link exists but is linked to a different `userId`. If you wish to identify if any user is linked, omit this parameter.

Retrieve all links for a specific user by identity provider

GET/api/identity-provider/link?identityProviderId={identityProviderId}&userId={userId}

OpenAPI Spec

#### Request Headers[#](#request-headers)

`X-FusionAuth-TenantId`Stringoptional

The unique Id of the tenant used to scope this API request.

The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.

Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.

See [Making an API request using a Tenant Id](/docs/apis/authentication#making-an-api-request-using-a-tenant-id) for additional information.

#### Request Parameters[#](#request-parameters-1)

`identityProviderId`UUIDrequired

The unique Id of the identity provider.

`userId`UUIDrequired

The FusionAuth User Id that is linked to the identity provider.

Retrieve all links for a user

GET/api/identity-provider/link?userId={userId}

OpenAPI Spec

#### Request Headers[#](#request-headers)

`X-FusionAuth-TenantId`Stringoptional

The unique Id of the tenant used to scope this API request.

The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.

Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.

See [Making an API request using a Tenant Id](/docs/apis/authentication#making-an-api-request-using-a-tenant-id) for additional information.

#### Request Parameters[#](#request-parameters-2)

`userId`UUIDrequired

The FusionAuth User Id that is linked to the identity provider.

### Response[#](#response-2)

*Response Codes*

| Code | Description |
| --- | --- |
| 200 | The request was successful. The response will contain a JSON body. |
| 400 | The request was invalid and/or malformed. The response will contain an [Errors](/docs/apis/errors) JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present. |
| 401 | You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See [Authentication](/docs/apis/authentication). |
| 404 | The object you requested doesn't exist. The response will be empty. |
| 500 | There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty. |

#### Response Body[#](#response-body)

The response body for this API contains either a single Link or an array of Links. When you call this API with **identityProviderId**, **identityProviderUserId**, and optionally the **userId**, the response will contain a single Link. When you call this API with **userId** and either **identityProviderId** or **identityProviderUserId**, the response will contain an array of Links. All response types are defined below along with an example JSON response.

`identityProviderLink.displayName`String

A optional human readable name for this link such as an email address, username or given name. This value should be used to make it easier to identify the user this link represents in the remote identity provider.

Please note, that this value will always be overwritten during login to reflect the most current information from the identity provider. In most cases this value will be an email address or username.

`identityProviderLink.identityProviderId`UUID

The unique Id of the identity provider.

`identityProviderLink.identityProviderName`StringAvailable since 1.47.0

The name of the identity provider.

`identityProviderLink.identityProviderType`StringAvailable since 1.46.0

The type of the identity provider.

`identityProviderLink.identityProviderUserId`String

The unique user Id in the third-party identity provider. Ideally this value never changes and will always uniquely identify the user in the third-party identity provider.

`identityProviderLink.insertInstant`Long

The [instant](/docs/reference/data-types#instants) that the Link was created.

`identityProviderLink.lastLoginInstant`Long

The [instant](/docs/reference/data-types#instants) when the User logged in last with this identity provider using this link.

`identityProviderLink.tenantId`UUID

The Id of the Tenant that this User belongs to.

`identityProviderLink.token`String

The token returned from the identity provider. This is treated as an opaque token as the type varies by identity provider, this value may not be returned by all identity providers. When provided, this token is typically a long lived access or refresh token, but consult individual identity provider documentation for specifics.

**Note:** Prior to version `1.28.0`, this value can be retrieved using the [User Registration APIs](/docs/apis/registrations) using the **registration.token** field.

`identityProviderLink.userId`UUID

The FusionAuth User Id that is linked to the identity provider.

*Example Response JSON*

```
{
  "identityProviderLink": {
    "displayName": "richard@piedpiper.com",
    "identityProviderId": "f50dbb83-4cc2-4e5e-aece-9efe068bddd9",
    "identityProviderName": "My OpenIDConnect Identity Provider",
    "identityProviderType": "OpenIDConnect",
    "identityProviderUserId": "42",
    "insertInstant": 1623183147998,
    "lastLoginInstant": 1623183152224,
    "tenantId": "30663132-6464-6665-3032-326466613934",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
    "userId": "fbf0e652-b2b5-45eb-b9c9-d4640889740b"
  }
}
```

#### Response Body[#](#response-body)

`identityProviderLinks`Array

The list of Link objects.

`identityProviderLinks[x].displayName`String

A optional human readable name for this link such as an email address, username or given name. This value should be used to make it easier to identify the user this link represents in the remote identity provider.

Please note, that this value will always be overwritten during login to reflect the most current information from the identity provider. In most cases this value will be an email address or username.

`identityProviderLinks[x].identityProviderId`UUID

The unique Id of the identity provider.

`identityProviderLinks[x].identityProviderName`StringAvailable since 1.47.0

The name of the identity provider.

`identityProviderLinks[x].identityProviderType`StringAvailable since 1.46.0

The type of the identity provider.

`identityProviderLinks[x].identityProviderUserId`String

The unique user Id in the third-party identity provider. Ideally this value never changes and will always uniquely identify the user in the third-party identity provider.

`identityProviderLinks[x].insertInstant`Long

The [instant](/docs/reference/data-types#instants) that the Link was created.

`identityProviderLinks[x].lastLoginInstant`Long

The [instant](/docs/reference/data-types#instants) when the User logged in last with this identity provider using this link.

`identityProviderLinks[x].tenantId`UUID

The Id of the Tenant that this User belongs to.

`identityProviderLinks[x].token`String

The token returned from the identity provider. This is treated as an opaque token as the type varies by identity provider, this value may not be returned by all identity providers. When provided, this token is typically a long lived access or refresh token, but consult individual identity provider documentation for specifics.

**Note:** Prior to version `1.28.0`, this value can be retrieved using the [User Registration APIs](/docs/apis/registrations) using the **registration.token** field.

`identityProviderLinks[x].userId`UUID

The FusionAuth User Id that is linked to the identity provider.

*Example Response JSON for a collection of Links*

```
{
  "identityProviderLinks": [
    {
      "displayName": "richard@piedpiper.com",
      "identityProviderId": "f50dbb83-4cc2-4e5e-aece-9efe068bddd9",
      "identityProviderName": "My OpenIDConnect Identity Provider",
      "identityProviderType": "OpenIDConnect",
      "identityProviderUserId": "42",
      "insertInstant": 1623183147998,
      "lastLoginInstant": 1623183152224,
      "tenantId": "30663132-6464-6665-3032-326466613934",
      "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI0MiIsIm5hbWUiOiJSaWNoYXJkIiwiaWF0IjoxNTE2MjM5MDIyfQ.hFtOTx0nZ58YNJlYLI9kV2Tt0Jg1yxdW7Gy-43V4clc",
      "userId": "fbf0e652-b2b5-45eb-b9c9-d4640889740b"
    },
    {
      "displayName": "richard@hooli.com",
      "identityProviderId": "363ae8d9-dd4d-4473-bdc6-3694f1d0329e",
      "identityProviderName": "Another OpenIDConnect Identity Provider",
      "identityProviderType": "OpenIDConnect",
      "identityProviderUserId": "9821123",
      "insertInstant": 1623183147998,
      "lastLoginInstant": 1623183152225,
      "tenantId": "30663132-6464-6665-3032-326466613934",
      "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI5ODIxMTIzIiwibmFtZSI6IlJpY2hhcmQiLCJpYXQiOjE1MTYyMzkwMjJ9.bGRRUQBhdg6kS4sjiWrR-7xrOa6A2MzI9QhWlDcNf-Y",
      "userId": "fbf0e652-b2b5-45eb-b9c9-d4640889740b"
    }
  ]
}
```

## Retrieve a Pending Link[#](#retrieve-a-pending-link)

This API has been available since 1.46.0

This API is used to retrieve a pending IdP Link. A pending IdP Link is created after a user completes login with an Identity Provider configured with a linking strategy of **Create a Pending Link**. This pending IdP link is then used to link a user in a 3rd party identity provider to a user in FusionAuth.

Retrieving this link may be useful if you are building your own login pages, and need to identify the Identity Provider or various meta-data associated with his pending link.

### Request[#](#request-3)

Retrieve a single pending link by Id

GET/api/identity-provider/link/pending/{pendingLinkId}?userId={userId}

OpenAPI Spec

#### Request Headers[#](#request-headers)

`X-FusionAuth-TenantId`Stringoptional

The unique Id of the tenant used to scope this API request.

The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.

Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.

See [Making an API request using a Tenant Id](/docs/apis/authentication#making-an-api-request-using-a-tenant-id) for additional information.

#### Request Parameters[#](#request-parameters-3)

`pendingLinkId`Stringrequired

The unique pending IdP Link Id.

`userId`UUIDoptional

The optional User Id that you intend to link using this pending IdP Link. When provided the user's current link count will be returned in the response body.

This can be useful if you are limiting the number of links a user may have to a single identity provider. This will help you understand if the link will succeed for this user.

### Response[#](#response-3)

*Response Codes*

| Code | Description |
| --- | --- |
| 200 | The request was successful. The response will contain a JSON body. |
| 400 | The request was invalid and/or malformed. The response will contain an [Errors](/docs/apis/errors) JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present. |
| 401 | You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See [Authentication](/docs/apis/authentication). |
| 404 | The object you requested doesn't exist. The response will be empty. |
| 500 | There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty. |

#### Response Body[#](#response-body)

`identityProviderTenantConfiguration.limitUserLinkCount.enabled`Boolean

The tenant configuration for identity provider linking. If enabled the **maximumLinks** value will be enforced during linking. This will only be present if you have configured a tenant policy for this identity provider.

`identityProviderTenantConfiguration.limitUserLinkCount.maximumLinks`Integer

The maximum number of links a user can have to a single identity provider. This will only be present if you have configured a tenant policy for this identity provider.

`linkCount`Long

The user's current link count. This will only be present if a **userId** was provided on the request.

`pendingIdPLink.displayName`String

A optional human readable name for this link such as an email address, username or given name. This value should be used to make it easier to identify the user this link represents in the remote identity provider.

`pendingIdPLink.email`String

The optional email address provided by the identity provider. This value will not always be present, it will depend upon the identity provider.

`pendingIdPLink.identityProviderId`UUID

The unique Id of the identity provider.

`pendingIdPLink.identityProviderName`UUID

The name of the identity provider.

`pendingIdPLink.identityProviderType`UUID

The type of the identity provider.

`pendingIdPLink.identityProviderUserId`String

The unique user Id in the 3rd party identity provider. Ideally this value never changes and will always uniquely identify the user in the 3rd party identity provider.

`pendingIdPLink.username`String

The optional username provided by the identity provider. This value will not always be present, it will depend upon the identity provider.

*Example Response JSON*

```
{
  "identityProviderTenantConfiguration": {
    "limitUserLinkCount": {
      "enabled": false,
      "maximumLinks": 2
    }
  },
  "linkCount": 0,
  "pendingIdPLink": {
    "displayName": "richard@piedpiper.com",
    "email": "richard@piedpiper.com",
    "identityProviderId": "af53ab21-34c3-468a-8ba2-ecb3905f67f2",
    "identityProviderName": "Xbox",
    "identityProviderType": "Xbox",
    "identityProviderUserId": "42",
    "username": "richard"
  }
}
```

## Unlink a User[#](#unlink-a-user)

This API is used to remove a link between a FusionAuth User and a 3rd party identity provider.

### Request[#](#request-4)

Delete the Link with the given Id

DELETE/api/identity-provider/link?identityProviderId={identityProviderId}&identityProviderUserId={identityProviderUserId}&userId={userId}

OpenAPI Spec

#### Request Headers[#](#request-headers)

`X-FusionAuth-TenantId`Stringoptional

The unique Id of the tenant used to scope this API request.

The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.

Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.

See [Making an API request using a Tenant Id](/docs/apis/authentication#making-an-api-request-using-a-tenant-id) for additional information.

#### Request Parameters[#](#request-parameters-4)

`identityProviderId`UUIDrequired

The unique Id of the identity provider.

`identityProviderUserId`Stringrequired

The Id for the user that is provided by the upstream identity provider. This is the value that will allow FusionAuth to link this user on future logins. This value is expected to be immutable.

`userId`UUIDrequired

The FusionAuth User Id that is linked to the identity provider.

### Response[#](#response-4)

This API does not return a JSON response body.

*Response Codes*

| Code | Description |
| --- | --- |
| 200 | The request was successful. |
| 400 | The request was invalid and/or malformed. The response will contain an [Errors](/docs/apis/errors) JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present. |
| 401 | You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See [Authentication](/docs/apis/authentication). |
| 404 | The object you requested doesn't exist. The response will be empty. |
| 500 | There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty. |