# SCIM User Response Converter Lambda

Learn how to convert a FusionAuth user into the SCIM user response a SCIM client expects.

> For the index of this section of the site, see [llms.txt](https://fusionauth.io/docs/llms.txt)

If you would like to convert an outgoing FusionAuth User response into a SCIM User and optionally SCIM EnterpriseUser, you must specify a lambda in the SCIM configuration. This lambda will be invoked after the User was acted upon.

When you create a new lambda using the FusionAuth UI we will provide you an empty function for you to implement.

## Lambda Structure

If you are using the API to create the lambda you will need to ensure your function has the following signature:

```javascript
function convert(scimUser, user, context) {
  // Lambda code goes here
}
```

This lambda must contain a function named `convert` that accepts the following parameters:

*   `scimUser` - the SCIM response object. You can modify this object.
*   `user` - the FusionAuth User object. This object is read-only.
*   `context` - Available since `1.64.0` - an object containing the context of the request, including access to [secrets](https://fusionauth.io/docs/lambdas.md#secrets). This object is read-only.

The FusionAuth `user` object is well documented in the [User API](https://fusionauth.io/docs/apis/users.md) documentation. The SCIM User object is a JavaScript object containing the SCIM User and optionally the SCIM EnterpriseUser response JSON payload. See [SCIM User](https://datatracker.ietf.org/doc/html/rfc7643#section-4.1) and [SCIM EnterpriseUser extension](https://datatracker.ietf.org/doc/html/rfc7643#section-4.3).

You may add or modify anything in the `scimUser` object.

## Assigning The Lambda

Once a lambda is created, you must assign it to a Tenant. See the SCIM tab in the Tenant configuration.

## Default Lambda

A default SCIM User Response Converter Lambda that converts an outgoing FusionAuth User to a SCIM USER and SCIM EnterpriseUser response to a FusionAuth User is available and may be used or modified. The lambda function is documented below.

```javascript
function convert(scimUser, user) {
  // Un-comment this line to see the user object printed to the event log
  // console.info(JSON.stringify(user, null, 2));

  scimUser.active = user.active;
  scimUser.userName = user.username;
  scimUser.name = {
    formatted: user.fullName,
    familyName: user.lastName,
    givenName: user.firstName,
    middleName: user.middleName,
    honorificPrefix: user.data.honorificPrefix,
    honorificSuffix: user.data.honorificSuffix
  };

  scimUser.phoneNumbers = [{
    primary: true,
    value: user.mobilePhone,
    type: "mobile"
  }];

  scimUser.emails = [{
    primary: true,
    value: user.email,
    type: "work"
  }];

  // Optionally return any custom extensions stored in user.data
  if (user.data && user.data.extensions) {
    for (var extension in user.data.extensions) {
      if (scimUser.schemas.indexOf(extension) === -1) {
        scimUser.schemas.push(extension);
      }
      scimUser[extension] = user.data.extensions[extension];
    }
  }
}
```

Related

[Lambdas SCIM User Request Converter Lambda Learn how to convert an incoming SCIM user request into a FusionAuth user with a lambda. scim user lambdascim provisioningfusionauth lambda](https://fusionauth.io/docs/lambdas/scim/scim-user-request-converter.md)

[Lambdas SCIM Group Response Converter Lambda Learn how to convert a FusionAuth group into the SCIM group response a SCIM client expects. scim provisioningfusionauth lambdascim response](https://fusionauth.io/docs/lambdas/scim/scim-group-response-converter.md)

[Lambdas SCIM Group Request Converter Lambda Learn how to convert an incoming SCIM group request into a FusionAuth group with a lambda. scim provisioningfusionauth lambdauser provisioning](https://fusionauth.io/docs/lambdas/scim/scim-group-request-converter.md)

[Users Azure AD SCIM Client Learn how to configure Azure AD/Microsoft Entra ID as a SCIM client. scim provisioninguser provisioning](https://fusionauth.io/docs/users/provision/scim/azure-ad-client.md)
---

## Other pages in Scim

> For the full index of this section, see [Lambdas](https://fusionauth.io/docs/llms-lambdas.txt).

- [SCIM Group Request Converter Lambda](https://fusionauth.io/docs/lambdas/scim/scim-group-request-converter.md): Learn how to convert an incoming SCIM group request into a FusionAuth group with a lambda.
- [SCIM Group Response Converter Lambda](https://fusionauth.io/docs/lambdas/scim/scim-group-response-converter.md): Learn how to convert a FusionAuth group into the SCIM group response a SCIM client expects.
- [SCIM User Request Converter Lambda](https://fusionauth.io/docs/lambdas/scim/scim-user-request-converter.md): Learn how to convert an incoming SCIM user request into a FusionAuth user with a lambda.
