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

# Identify a user

> Identify a user.



## OpenAPI

````yaml https://api.trophy.so/v1/openapi put /users/{id}
openapi: 3.1.0
info:
  title: Trophy
  version: 1.19.0
servers:
  - x-fern-server-name: Application API
    url: https://api.trophy.so/v1
    description: Application API
security: []
paths:
  /users/{id}:
    servers:
      - url: https://api.trophy.so/v1
        description: Application API
    parameters:
      - $ref: '#/components/parameters/TenantId'
    put:
      tags:
        - Users
      summary: Identify a user
      description: Identify a user.
      operationId: users_identify
      parameters:
        - name: id
          in: path
          description: ID of the user to identify.
          required: true
          schema:
            type: string
          example: id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdatedUser'
              description: The user object.
            example:
              email: user@example.com
              tz: Europe/London
              attributes:
                department: engineering
                role: developer
      responses:
        '200':
          description: Upserted user
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '422':
          description: Unprocessible Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: javascript
          source: |
            import { TrophyApiClient } from '@trophyso/node';

            const trophy = new TrophyApiClient({
              apiKey: 'YOUR_API_KEY'
            });

            const response = await trophy.users.identify("user-id", {
              email: 'user@example.com',
              tz: 'Europe/London',
              attributes: {
                department: 'engineering',
                role: 'developer'
              }
            });
        - lang: python
          source: |
            from trophy import TrophyApi

            client = TrophyApi(api_key='YOUR_API_KEY')

            response = client.users.identify(
              id="123",
              email="user@example.com",
              tz="Europe/London",
              subscribedToEmails=True,
              attributes={
                "department": "engineering",
                "role": "developer"
              }
            )
        - lang: go
          source: |
            import (
              "context"

              api "github.com/trophyso/trophy-go"
              trophyclient "github.com/trophyso/trophy-go/client"
              "github.com/trophyso/trophy-go/option"
            )

            client := trophyclient.NewClient(
              option.WithApiKey("YOUR_API_KEY"),
            )

            response, err := client.Users.Identify(
              context.TODO(),
              "user-id",
              &api.UpdatedUser{},
            )
components:
  parameters:
    TenantId:
      name: Tenant-ID
      in: header
      description: >-
        The tenant identifier for multi-tenant organisations. Required when the
        organisation has multi-tenancy enabled. The value should be your
        internal ID for the tenant. Ignored for single-tenant organisations.
      required: false
      schema:
        type: string
      example: customer_12345
  schemas:
    UpdatedUser:
      title: Updated User
      type: object
      description: An object with editable user fields.
      properties:
        email:
          type: string
          description: The user's email address. Required if subscribeToEmails is true.
          example: user@example.com
        name:
          type: string
          description: The name to refer to the user by in emails.
          example: User
        tz:
          type:
            - string
            - 'null'
          description: The user's timezone (used for email scheduling).
          example: Europe/London
        deviceTokens:
          type:
            - array
            - 'null'
          description: The user's device tokens, used for push notifications.
          items:
            type: string
            description: The device token.
          example:
            - token1
            - token2
        subscribeToEmails:
          type: boolean
          default: true
          description: >-
            Whether the user should receive Trophy-powered emails. If false,
            Trophy will not store the user's email address.
          example: true
        attributes:
          type: object
          additionalProperties:
            type: string
          description: >-
            User attributes as key-value pairs. Keys must match existing user
            attributes set up in the Trophy dashboard.
          example:
            department: engineering
            role: developer
    User:
      title: User
      type: object
      description: A user of your application.
      properties:
        id:
          type: string
          description: The ID of the user in your database. Must be a string.
          example: user-id
        email:
          type:
            - string
            - 'null'
          description: The user's email address.
          example: user@example.com
        name:
          type:
            - string
            - 'null'
          description: The name of the user.
          example: John Doe
        tz:
          type:
            - string
            - 'null'
          description: The user's timezone.
          example: Europe/London
        deviceTokens:
          type:
            - array
            - 'null'
          description: The user's device tokens.
          items:
            type: string
            description: The device token.
          example:
            - token1
            - token2
        subscribeToEmails:
          type: boolean
          description: Whether the user is opted into receiving Trophy-powered emails.
          example: true
        attributes:
          type: object
          additionalProperties:
            type: string
          description: >-
            User attributes as key-value pairs. Keys must match existing user
            attributes set up in the Trophy dashboard.
          example:
            department: engineering
            role: developer
        control:
          type: boolean
          description: >-
            Whether the user is in the control group, meaning they do not
            receive emails or other communications from Trophy.
          example: false
        created:
          type: string
          format: date-time
          description: The date and time the user was created, in ISO 8601 format.
          example: '2021-01-01T00:00:00Z'
        updated:
          type: string
          format: date-time
          description: The date and time the user was last updated, in ISO 8601 format.
          example: '2021-01-01T00:00:00Z'
      required:
        - id
        - email
        - name
        - tz
        - subscribeToEmails
        - attributes
        - control
        - created
        - updated
    ErrorBody:
      title: ErrorBody
      type: object
      properties:
        error:
          type: string
      required:
        - error
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY

````