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

# Restore streaks for multiple users

> Restore streaks for multiple users to the maximum previously achieved streak length found within the current restore window: the last 90 days for daily streaks, weekly periods starting with the week containing the start of the current calendar year for weekly streaks, and monthly periods starting at the beginning of the previous calendar year for monthly streaks.



## OpenAPI

````yaml https://admin.trophy.so/v1/openapi post /streaks/restore
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:
  /streaks/restore:
    servers:
      - url: https://admin.trophy.so/v1
        description: Admin API
    parameters:
      - $ref: '#/components/parameters/TenantId'
    post:
      tags:
        - Admin
      summary: Restore streaks for multiple users
      description: >-
        Restore streaks for multiple users to the maximum previously achieved
        streak length found within the current restore window: the last 90 days
        for daily streaks, weekly periods starting with the week containing the
        start of the current calendar year for weekly streaks, and monthly
        periods starting at the beginning of the previous calendar year for
        monthly streaks.
      operationId: admin_streaks_restore
      requestBody:
        description: Array of users to restore streaks for
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RestoreStreaksRequest'
            examples:
              Restore streaks for multiple users:
                value:
                  users:
                    - id: user-123
                    - id: user-456
      responses:
        '200':
          description: Successful operation (no streaks restored)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestoreStreaksResponse'
              examples:
                Success with warnings:
                  value:
                    restoredUsers: []
                    issues:
                      - userId: user-123
                        severity: warning
                        message: No streak to restore
                Mixed success and errors:
                  value:
                    restoredUsers: []
                    issues:
                      - userId: non-existent-user
                        severity: error
                        message: User does not exist
                      - userId: user-789
                        severity: warning
                        message: No streak to restore
        '201':
          description: Created (at least one streak restored)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestoreStreaksResponse'
              examples:
                Success with no issues:
                  value:
                    restoredUsers:
                      - user-123
                      - user-456
                    issues: []
                Mixed success and errors:
                  value:
                    restoredUsers:
                      - user-123
                    issues:
                      - userId: non-existent-user
                        severity: error
                        message: User does not exist
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AdminErrorBody'
        '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: []
      x-codeSamples:
        - lang: javascript
          source: |
            import { TrophyApiClient } from '@trophyso/node';

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

            const response = await trophy.admin.streaks.restore({
              users: [{ id: 'user-123' }, { id: 'user-456' }]
            });
        - lang: python
          source: |
            from trophy import TrophyApi

            client = TrophyApi(api_key='YOUR_API_KEY')

            response = client.admin.streaks.restore({
              "users": [{"id": "user-123"}, {"id": "user-456"}]
            })
        - 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.Streaks.Restore(context.TODO(), nil)
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:
    RestoreStreaksRequest:
      title: RestoreStreaksRequest
      type: object
      description: Request body for restoring streaks for multiple users.
      properties:
        users:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
                description: The ID of the user to restore streaks for.
                example: user-123
            required:
              - id
          description: >-
            Array of users to restore streaks for. Maximum 100 users per
            request.
          maxItems: 100
          minItems: 1
          example:
            - id: user-123
            - id: user-456
      required:
        - users
    RestoreStreaksResponse:
      title: RestoreStreaksResponse
      type: object
      description: Response containing restored users and any issues encountered.
      properties:
        restoredUsers:
          type: array
          items:
            type: string
          description: Array of user IDs whose streaks were successfully restored.
          example:
            - user-123
            - user-456
        issues:
          type: array
          items:
            $ref: '#/components/schemas/AdminIssue'
          description: Array of issues encountered during streak restoration.
      required:
        - restoredUsers
        - issues
    AdminErrorBody:
      title: AdminErrorBody
      type: object
      properties:
        error:
          type: string
      required:
        - error
    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

````