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

> Update leaderboards by ID. Updating `status` behaves the same as activating, scheduling, deactivating, or finishing a leaderboard in the dashboard.



## OpenAPI

````yaml https://admin.trophy.so/v1/openapi patch /leaderboards
openapi: 3.1.0
info:
  title: Trophy
  version: 1.19.0
servers:
  - x-fern-server-name: Admin API
    url: https://admin.trophy.so/v1
    description: Admin API
security: []
paths:
  /leaderboards:
    servers:
      - url: https://admin.trophy.so/v1
        description: Admin API
    parameters:
      - $ref: '#/components/parameters/TenantId'
    patch:
      tags:
        - Admin
      summary: Update leaderboards
      description: >-
        Update leaderboards by ID. Updating `status` behaves the same as
        activating, scheduling, deactivating, or finishing a leaderboard in the
        dashboard.
      operationId: admin_leaderboards_update
      requestBody:
        description: Array of leaderboards to update. Each item must include an ID.
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateLeaderboardsRequest'
            examples:
              Update leaderboards:
                value:
                  - id: 550e8400-e29b-41d4-a716-446655440100
                    name: Monthly Revenue Champions
                    description: Ranked by monthly revenue
                    status: active
                  - id: 550e8400-e29b-41d4-a716-446655440101
                    status: finished
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UpdateLeaderboardsResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AdminErrorBody'
        '422':
          description: Unprocessible Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AdminErrorBody'
      security:
        - ApiKeyAuth: []
      servers:
        - url: https://admin.trophy.so/v1
          description: Admin API
      x-codeSamples:
        - lang: javascript
          source: |
            import { TrophyApiClient } from '@trophyso/node';

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

            const response = await trophy.admin.leaderboards.update([
              {
                id: '550e8400-e29b-41d4-a716-446655440100',
                name: 'Monthly Revenue Champions',
                description: 'Ranked by monthly revenue',
                status: 'active'
              },
              {
                id: '550e8400-e29b-41d4-a716-446655440101',
                status: 'finished'
              }
            ]);
        - lang: python
          source: |
            from trophy import TrophyApi

            client = TrophyApi(api_key='YOUR_API_KEY')

            response = client.admin.leaderboards.update([
              {
                "id": "550e8400-e29b-41d4-a716-446655440100",
                "name": "Monthly Revenue Champions",
                "description": "Ranked by monthly revenue",
                "status": "active"
              },
              {
                "id": "550e8400-e29b-41d4-a716-446655440101",
                "status": "finished"
              }
            ])
        - 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.Admin.Leaderboards.Update(context.TODO(),
            api.UpdateLeaderboardsRequest{})
components:
  parameters:
    TenantId:
      name: Tenant-ID
      in: header
      description: >-
        The tenant identifier for multi-tenant organisations. Required when the
        organisation has multi-tenancy enabled. Pass your own internal customer
        ID for the tenant. Ignored for single-tenant organisations.
      required: false
      schema:
        type: string
      example: customer_12345
  schemas:
    UpdateLeaderboardsRequest:
      title: UpdateLeaderboardsRequest
      type: array
      description: Request body for updating leaderboards.
      items:
        $ref: '#/components/schemas/UpdateLeaderboardRequestItem'
      minItems: 1
      maxItems: 100
    UpdateLeaderboardsResponse:
      title: UpdateLeaderboardsResponse
      type: object
      description: >-
        Response containing updated leaderboards and any per-item issues
        identified by leaderboard ID.
      properties:
        updated:
          type: array
          items:
            $ref: '#/components/schemas/AdminLeaderboard'
          description: Array of successfully updated leaderboards.
        issues:
          type: array
          items:
            $ref: '#/components/schemas/AdminIssue'
          description: Array of issues encountered during leaderboard update.
      required:
        - updated
        - issues
    AdminErrorBody:
      title: AdminErrorBody
      type: object
      properties:
        error:
          type: string
      required:
        - error
    UpdateLeaderboardRequestItem:
      title: UpdateLeaderboardRequestItem
      type: object
      description: >-
        A leaderboard update object. `id` is required. Once a leaderboard has
        been activated, the dashboard-imposed restrictions on ranking
        configuration and scheduling changes still apply.
      properties:
        id:
          type: string
          format: uuid
          description: The UUID of the leaderboard to update.
          example: 550e8400-e29b-41d4-a716-446655440100
        name:
          type: string
          description: The updated leaderboard name.
        key:
          type: string
          pattern: ^[a-zA-Z\d-_]+$
          description: >-
            The updated leaderboard key. This can only be changed while the
            leaderboard is inactive.
        description:
          type: string
          description: The updated leaderboard description.
        status:
          type: string
          enum:
            - inactive
            - active
            - scheduled
            - finished
          description: >-
            The target user-facing status. `scheduled` activates a leaderboard
            whose start date is in the future. `finished` behaves like the
            dashboard finish action.
        rankBy:
          type: string
          enum:
            - metric
            - streak
            - points
          description: >-
            The updated ranking criterion. This can only be changed while the
            leaderboard is inactive.
        metricId:
          type: string
          format: uuid
          description: The metric ID to use when `rankBy` is `metric`.
        pointsSystemId:
          type: string
          format: uuid
          description: The points system ID to use when `rankBy` is `points`.
        maxParticipants:
          type:
            - integer
            - 'null'
          minimum: 1
          maximum: 1000
          description: The updated maximum number of participants.
        start:
          type: string
          format: date
          description: The updated start date in YYYY-MM-DD format.
        end:
          oneOf:
            - type: string
              format: date
            - type: 'null'
          description: The updated end date in YYYY-MM-DD format, or `null` to clear it.
        startTime:
          oneOf:
            - type: string
              pattern: ^([01][0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$
            - type: 'null'
          description: >-
            The updated start of the daily ranking time window in HH:mm format,
            or `null` to clear it.
          example: '09:00'
        endTime:
          oneOf:
            - type: string
              pattern: ^([01][0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$
            - type: 'null'
          description: >-
            The updated end of the daily ranking time window in HH:mm format, or
            `null` to clear it.
          example: '17:00'
        breakdownAttributes:
          type: array
          description: The updated breakdown attribute UUIDs.
          items:
            type: string
            format: uuid
        runUnit:
          oneOf:
            - type: string
              enum:
                - day
                - month
                - year
            - type: 'null'
          description: The updated recurrence unit.
        runInterval:
          type: integer
          minimum: 1
          description: The updated recurrence interval.
      required:
        - id
    AdminLeaderboard:
      title: AdminLeaderboard
      type: object
      description: A leaderboard returned from the admin leaderboards endpoints.
      properties:
        id:
          type: string
          format: uuid
          description: The UUID of the leaderboard.
        name:
          type: string
          description: The leaderboard name.
        key:
          type: string
          description: The leaderboard key.
        description:
          type: string
          description: The leaderboard description.
        status:
          type: string
          enum:
            - inactive
            - active
            - scheduled
            - finished
          description: The current user-facing status of the leaderboard.
        rankBy:
          type: string
          enum:
            - metric
            - streak
            - points
          description: What the leaderboard ranks by.
        metricId:
          type: string
          format: uuid
          description: The metric ID used when `rankBy` is `metric`.
        pointsSystemId:
          type: string
          format: uuid
          description: The points system ID used when `rankBy` is `points`.
        maxParticipants:
          type:
            - integer
            - 'null'
          description: The maximum number of participants.
        start:
          type: string
          format: date
          description: The leaderboard start date in YYYY-MM-DD format.
        end:
          type: string
          format: date
          description: The optional leaderboard end date in YYYY-MM-DD format.
        startTime:
          type: string
          pattern: ^([01][0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$
          description: >-
            When set, ranking only counts activity at or after this time of day
            in the user's timezone (HH:mm format).
          example: '09:00'
        endTime:
          type: string
          pattern: ^([01][0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$
          description: >-
            When set, ranking only counts activity before this time of day in
            the user's timezone (HH:mm format).
          example: '17:00'
        breakdownAttributes:
          type: array
          description: The UUIDs of the user attributes used for ranking breakdowns.
          items:
            type: string
            format: uuid
        runUnit:
          type: string
          enum:
            - day
            - month
            - year
          description: The recurrence unit when the leaderboard repeats.
        runInterval:
          type: integer
          description: The number of recurrence units between leaderboard runs.
      required:
        - id
        - name
        - key
        - status
        - rankBy
        - maxParticipants
        - start
        - breakdownAttributes
    AdminIssue:
      title: AdminIssue
      type: object
      description: An issue encountered while processing an item in an admin API request.
      properties:
        id:
          type: string
          description: The ID of the resource the issue relates to, when applicable.
          example: 550e8400-e29b-41d4-a716-446655440000
        userId:
          type: string
          description: The ID of the user the issue relates to, when applicable.
          example: user-123
        boostId:
          type: string
          description: The ID of the points boost the issue relates to, when applicable.
          example: 550e8400-e29b-41d4-a716-446655440000
        index:
          type: integer
          description: >-
            The zero-based index of the item the issue relates to, when no
            resource ID exists yet.
          example: 0
        severity:
          type: string
          enum:
            - error
            - warning
          description: The severity level of the issue.
          example: warning
        message:
          type: string
          description: A human-readable description of the issue.
          example: Would exceed maximum freeze limit
      required:
        - severity
        - message
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY

````