> ## 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.

# Update a user's preferences

> Update a user's notification and streak preferences. Streak preferences require streak customization to be enabled in your Trophy dashboard settings.



## OpenAPI

````yaml https://api.trophy.so/v1/openapi patch /users/{id}/preferences
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}/preferences:
    servers:
      - url: https://api.trophy.so/v1
        description: Application API
    parameters:
      - $ref: '#/components/parameters/TenantId'
    patch:
      tags:
        - Users
      summary: Update a user's preferences
      description: >-
        Update a user's notification and streak preferences. Streak preferences
        require streak customization to be enabled in your Trophy dashboard
        settings.
      operationId: users_update_preferences
      parameters:
        - name: id
          in: path
          description: The user's ID in your database.
          required: true
          schema:
            type: string
          example: user-123
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateUserPreferencesRequest'
            examples:
              Disable streak reminders:
                value:
                  notifications:
                    streak_reminder: []
              Email only for recaps:
                value:
                  notifications:
                    recap:
                      - email
              Enable all for achievements:
                value:
                  notifications:
                    achievement_completed:
                      - email
                      - push
              Personalize streak settings:
                value:
                  streak:
                    evaluationMode: OR
                    metrics:
                      - key: words-written
                        threshold: 500
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserPreferencesResponse'
              examples:
                Successful operation:
                  value:
                    notifications:
                      achievement_completed:
                        - email
                        - push
                      recap:
                        - email
                      reactivation:
                        - email
                        - push
                      streak_reminder: []
                    streak:
                      evaluationMode: OR
                      metrics:
                        - key: words-written
                          threshold: 500
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '403':
          description: Streak customization is not enabled for this organisation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '404':
          description: User not found
          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.updatePreferences("user-123", {
              notifications: {
                recap: ["email"],
                streak_reminder: []
              }
            });
        - lang: python
          source: |
            from trophy import TrophyApi

            client = TrophyApi(api_key='YOUR_API_KEY')

            response = client.users.update_preferences(
              id="user-123",
              notifications={
                "recap": ["email"],
                "streak_reminder": []
              }
            )
        - 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.UpdatePreferences(
              context.TODO(),
              "user-123",
              &api.UpdateUserPreferencesRequest{},
            )
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:
    UpdateUserPreferencesRequest:
      title: UpdateUserPreferencesRequest
      type: object
      description: Request body for updating user preferences.
      properties:
        notifications:
          $ref: '#/components/schemas/NotificationPreferences'
        streak:
          $ref: '#/components/schemas/StreakPreferences'
    UserPreferencesResponse:
      title: UserPreferencesResponse
      type: object
      description: A user's preferences.
      properties:
        notifications:
          $ref: '#/components/schemas/NotificationPreferences'
        streak:
          $ref: '#/components/schemas/StreakPreferences'
      required:
        - notifications
    ErrorBody:
      title: ErrorBody
      type: object
      properties:
        error:
          type: string
      required:
        - error
    NotificationPreferences:
      title: NotificationPreferences
      type: object
      description: Notification preferences for each notification type.
      properties:
        achievement_completed:
          type: array
          items:
            $ref: '#/components/schemas/NotificationChannel'
          description: Channels to receive achievement completion notifications on.
        recap:
          type: array
          items:
            $ref: '#/components/schemas/NotificationChannel'
          description: Channels to receive recap notifications on.
        reactivation:
          type: array
          items:
            $ref: '#/components/schemas/NotificationChannel'
          description: Channels to receive reactivation notifications on.
        streak_reminder:
          type: array
          items:
            $ref: '#/components/schemas/NotificationChannel'
          description: Channels to receive streak reminder notifications on.
    StreakPreferences:
      title: StreakPreferences
      type: object
      description: >-
        Per-user streak configuration. Metric and evaluation mode overrides
        require streak customization to be enabled in dashboard settings.
      properties:
        enabled:
          type: boolean
          description: >-
            Whether streaks are calculated for this user. When false, the user's
            streak is always 0 and streak webhooks and notifications are not
            sent.
          default: true
        evaluationMode:
          $ref: '#/components/schemas/StreakEvaluationModePreference'
        metrics:
          type: array
          items:
            $ref: '#/components/schemas/StreakMetricPreference'
          description: Metrics and thresholds that count toward this user's streak.
    NotificationChannel:
      title: NotificationChannel
      type: string
      enum:
        - email
        - push
      description: A notification delivery channel.
    StreakEvaluationModePreference:
      title: StreakEvaluationModePreference
      type: string
      enum:
        - OR
        - AND
      description: >-
        Whether meeting any single metric threshold (`OR`) or all configured
        metric thresholds (`AND`) extends the user's streak. Matches the
        evaluation mode configured in dashboard streak settings.
    StreakMetricPreference:
      title: StreakMetricPreference
      type: object
      description: Per-metric streak threshold override for a user.
      properties:
        key:
          type: string
          description: The metric key.
          example: words-written
        threshold:
          type: number
          description: Minimum metric change in a streak period to count toward the streak.
          example: 500
      required:
        - key
        - threshold
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY

````