# UserInfo Populate Lambda

Learn how to add custom claims to the UserInfo response.

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

If you would like to augment the claims provided in the UserInfo response, you can specify a lambda in the Application's OAuth configuration.

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 populate(userInfo, user, registration, jwt, context) {
  // Lambda code goes here
}
```

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

*   `userInfo` - the claims object to be returned as a JSON payload. You can modify this object.
*   `user` - the FusionAuth User object. This object is read-only.
*   `registration` - the FusionAuth UserRegistration object. This object is read-only.
*   `jwt` - the claims object from the provided JWT. 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 two FusionAuth objects are well documented in the [User API](https://fusionauth.io/docs/apis/users.md) and [Registration API](https://fusionauth.io/docs/apis/registrations.md) documentation. The JWT object is a JavaScript object containing the JWT payload. See [OpenID Connect & OAuth 2.0 Token](https://fusionauth.io/docs/authentication/oauth/tokens.md).

You may add, remove, or modify anything in the `userInfo` object except for certain reserved claims. The following claims are considered reserved and modifications or removal will not be reflected in the final UserInfo response:

*   `email`
*   `email_verified`
*   `phone_number_verified`
*   `sub`
*   `tid`

## Assigning The Lambda

Once a lambda is created, you must assign it to an Application. See the OAuth tab in the Application configuration.

## Example Lambda

Here is an example of a simple Lambda that adds a few extra claims to the UserInfo response.

```javascript
function populate(userInfo, user, registration, jwt) {
  // Add a new claim named 'favoriteColor' from a custom data attribute on the user
  userInfo.favoriteColor = user.data.favoriteColor;
  // Add a new claim named 'dept' using a custom data attribute on the registration
  userInfo.dept = registration.data.departmentName;
  // Copy a claim named 'applicationId' from the provided JWT
  userInfo.applicationId = jwt.applicationId;

  // Create an event log of type 'Debug' when the lambda has debug logging enabled
  console.debug('Added custom claims to the UserInfo response');
}
```

Related

[Lambdas Client Credentials JWT Populate Lambda Learn how to add custom claims to the access tokens FusionAuth issues for the Client Credentials grant. fusionauth lambdacustom claimsoauth2](https://fusionauth.io/docs/lambdas/tokens/client-credentials-jwt-populate.md)

[Lambdas JWT Populate Lambda Learn how to add custom claims to the access tokens and Id tokens FusionAuth issues. custom claimsfusionauth lambdaopenid connect](https://fusionauth.io/docs/lambdas/tokens/jwt-populate.md)

[APIs UserInfo API API documentation for the FusionAuth UserInfo OAuth2 endpoint. userinfo endpointopenid connect](https://fusionauth.io/docs/apis/oauth/userinfo.md)

[Lambdas Lambdas Learn about lambdas, the JavaScript functions that customize how FusionAuth logs users in and issues tokens. fusionauth lambdacustom claims](https://fusionauth.io/docs/lambdas.md)
---

## Other pages in Tokens

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

- [Client Credentials JWT Populate Lambda](https://fusionauth.io/docs/lambdas/tokens/client-credentials-jwt-populate.md): Learn how to add custom claims to the access tokens FusionAuth issues for the Client Credentials grant.
- [JWT Populate Lambda](https://fusionauth.io/docs/lambdas/tokens/jwt-populate.md): Learn how to add custom claims to the access tokens and Id tokens FusionAuth issues.
- [SAML v2 Populate Lambda](https://fusionauth.io/docs/lambdas/tokens/samlv2-response-populate.md): Learn how to customize the SAML v2 responses FusionAuth sends to service providers.
