> ## Documentation Index
> Fetch the complete documentation index at: https://docs.snagsolutions.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom user attributes

> Define custom profile fields, let users edit them, fetch them from the Users API, and save updates.

<head>
  <script type="application/ld+json">
    {JSON.stringify({
            "@context": "https://schema.org",
            "@graph": [
              {
                "@type": "TechArticle",
                "headline": "Custom user attributes",
                "description": "Define custom profile fields, let users edit them, fetch them from the Users API, and save updates.",
                "author": {"@type": "Organization", "name": "Snag Solutions", "url": "https://www.snagsolutions.io/"},
                "publisher": {"@type": "Organization", "name": "Snag Solutions", "url": "https://www.snagsolutions.io/", "logo": {"@type": "ImageObject", "url": "https://assets.snagsolutions.io/public/docs/snag-logo-dark-no-bg.svg"}},
                "mainEntityOfPage": "https://docs.snagsolutions.io/users/website-user-attributes"
              },
              {
                "@type": "BreadcrumbList",
                "itemListElement": [
                  {"@type": "ListItem", "position": 1, "name": "Home", "item": "https://docs.snagsolutions.io/welcome"},
                  {"@type": "ListItem", "position": 2, "name": "Loyalty", "item": "https://docs.snagsolutions.io/loyalty/loyalty-overview"},
                  {"@type": "ListItem", "position": 3, "name": "Advanced workflows", "item": "https://docs.snagsolutions.io/loyalty/managing-user-accounts"},
                  {"@type": "ListItem", "position": 4, "name": "Website user attributes"}
                ]
              }
            ]
          })}
  </script>
</head>

You can add custom fields to user profiles and use them across your website and APIs.

<Tip>
  Custom attributes are ideal for capturing structured data like "Favorite Team"
  or "External Profile Link" that isn't part of the default profile.
</Tip>

## Where custom attributes come from

* You can define attributes in Admin → Customization → User Profiles.
* Or you can create them via API.

<Steps>
  <Step title="Create a custom user attribute (UI or API)">
    If you're using the Admin UI, add a new field in the User Profiles section. To use the API, create attributes with a label that users will see.

    * API: See [Create a new website user attribute](/api-reference/identity/create-a-new-website-user-attribute).

    <Check>
      You should see the new attribute in Admin → Customization → User Profiles.
    </Check>

    <Warning>
      You must include a valid `X-API-KEY`. Missing or invalid keys result in 403 Forbidden.
    </Warning>
  </Step>

  <Step title="Let users edit attributes in the profile modal">
    In Snag's template, custom attributes appear as editable fields in the Edit Profile modal automatically. No extra code is required after you create the attributes.

    <Info>
      Field order and labels come from how you configured attributes in Admin or via the API.
    </Info>
  </Step>

  <Step title="Fetch users along with their attribute values">
    Use the Users API to retrieve users and their saved values for any defined attributes.

    * API: See [Get users](/api-reference/identity/get-users).

    <Check>
      Confirm the response includes each user and their stored values for the attributes you defined.
    </Check>
  </Step>

  <Step title="Save or update a user's attribute value via API">
    When a user edits their profile (or when you set values server-side), upsert attribute values using the attribute values endpoint.

    * API: See [Create a new website user attribute value](/api-reference/identity/create-a-new-website-user-attribute-value).

    <Check>
      Re-fetch the user and verify the updated value appears.
    </Check>
  </Step>
</Steps>

<AccordionGroup>
  <Accordion title="403 Forbidden">
    * **Cause**: Missing or invalid `X-API-KEY`, or insufficient permissions.
    * **Fix**: Provide a valid API key with permission to write attributes/values for the given `websiteId` and `organizationId`.
  </Accordion>

  <Accordion title="400 Validation error">
    * **Cause**: Missing required fields (`websiteId`, `organizationId`, `data`),
      or invalid IDs. - **Fix**: Ensure all IDs are valid UUIDs and the `data` array
      has the correct shape.
  </Accordion>

  <Accordion title="User not updated after save">
    * **Cause**: Value upsert succeeded, but UI cache not refreshed.
    * **Fix**: Re-fetch the user or invalidate client cache after saving.
  </Accordion>
</AccordionGroup>

## Related APIs

* [Create a new website user attribute — see API reference](/api-reference/identity/create-a-new-website-user-attribute).
* [Get users — see API reference](/api-reference/identity/get-users).
* [Create a new website user attribute value — see API reference](/api-reference/identity/create-a-new-website-user-attribute-value).

<Tip>
  Use consistent labels and avoid storing secrets or sensitive PII in custom
  attributes.
</Tip>
