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

# Create a new leaderboard configuration

> Creates a leaderboard configuration that defines how user data should be aggregated



## OpenAPI

````yaml /openapi/admin.json post /leaderboards
openapi: 3.1.0
info:
  title: Nudj Admin API
  version: 1.0.0
servers:
  - url: https://{subdomain}.nudj.cx/api/v2/admin
    description: Organization API Server
    variables:
      subdomain:
        description: Your organization's subdomain (required)
        default: your-org
security:
  - ApiToken: []
paths:
  /leaderboards:
    post:
      tags:
        - Leaderboard
      summary: Create a new leaderboard configuration
      description: >-
        Creates a leaderboard configuration that defines how user data should be
        aggregated
      operationId: createLeaderboardConfig
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  minLength: 1
                  description: The name of the leaderboard
                description:
                  type: string
                  description: The description of the leaderboard
                metricType:
                  type: string
                  enum:
                    - total-xp
                    - total-challenges-completed
                    - total-challenges-started
                    - total-actions-completed
                  description: The type of metric to track in the leaderboard
                startsAt:
                  type: string
                  description: The start date of the leaderboard
                expiresAt:
                  type: string
                  description: The expiry date of the leaderboard
                status:
                  type: string
                  enum:
                    - archived
                    - draft
                    - expired
                    - live
                    - scheduled
                  description: The status of the leaderboard config
                period:
                  type: string
                  enum:
                    - daily
                    - weekly
                    - monthly
                    - yearly
                    - open
                  description: The period for the leaderboard
                conditions:
                  type: array
                  items:
                    oneOf:
                      - type: object
                        properties:
                          type:
                            type: string
                            const: community
                          communityId:
                            type: string
                            pattern: ^[0-9a-fA-F]{24}$
                            description: >-
                              The community ID to filter leaderboard
                              participants by
                        required:
                          - type
                          - communityId
                      - type: object
                        properties:
                          type:
                            type: string
                            const: variable-config
                          variableConfigId:
                            type: string
                            pattern: ^[0-9a-fA-F]{24}$
                            description: The variable config ID to filter by
                          value:
                            anyOf:
                              - type: string
                              - type: number
                              - type: boolean
                            description: The value that the variable must match
                        required:
                          - type
                          - variableConfigId
                          - value
                  default: []
                  description: The conditions for leaderboard participation
              required:
                - name
                - metricType
                - startsAt
                - status
                - period
              description: The input required to create a leaderboard config
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LeaderboardConfigAdmin'
        '400':
          description: Invalid input data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.BAD_REQUEST'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.INTERNAL_SERVER_ERROR'
components:
  schemas:
    LeaderboardConfigAdmin:
      type: object
      properties:
        id:
          type: string
          pattern: ^[0-9a-fA-F]{24}$
          description: The id of the leaderboard config
        organisationId:
          type: string
          pattern: ^[0-9a-fA-F]{24}$
          description: The id of the organisation the leaderboard config belongs to
        name:
          type: string
          minLength: 1
          description: The name of the leaderboard
        description:
          type:
            - string
            - 'null'
          description: The description of the leaderboard
        metricType:
          type: string
          enum:
            - total-xp
            - total-challenges-completed
            - total-challenges-started
            - total-actions-completed
          description: The type of metric to track in the leaderboard
        period:
          type: string
          enum:
            - daily
            - weekly
            - monthly
            - yearly
            - open
          description: >-
            The period for the leaderboard (daily, weekly, monthly, yearly,
            open)
        startsAt:
          type: string
          description: The start date of the leaderboard
        expiresAt:
          type:
            - string
            - 'null'
          description: The expiry date of the leaderboard
        status:
          type: string
          enum:
            - archived
            - draft
            - expired
            - live
            - scheduled
          description: The status of the leaderboard config
        conditions:
          type: array
          items:
            oneOf:
              - type: object
                properties:
                  type:
                    type: string
                    const: community
                  communityId:
                    type: string
                    pattern: ^[0-9a-fA-F]{24}$
                    description: The community ID to filter leaderboard participants by
                required:
                  - type
                  - communityId
              - type: object
                properties:
                  type:
                    type: string
                    const: variable-config
                  variableConfigId:
                    type: string
                    pattern: ^[0-9a-fA-F]{24}$
                    description: The variable config ID to filter by
                  value:
                    anyOf:
                      - type: string
                      - type: number
                      - type: boolean
                    description: The value that the variable must match
                required:
                  - type
                  - variableConfigId
                  - value
          description: >-
            The conditions that participants must meet to appear on this
            leaderboard
        rewardsConfig:
          type: array
          items:
            $ref: '#/components/schemas/LeaderboardRewardsConfig'
          description: The reward configuration for different rank ranges
        createdAt:
          type: string
          description: The creation date of the leaderboard config
        updatedAt:
          type: string
          description: The update date of the leaderboard config
        createdBy:
          type: string
          description: The admin user who created this leaderboard config
        updatedBy:
          type: string
          description: The admin user who last updated this leaderboard config
      required:
        - id
        - organisationId
        - name
        - metricType
        - period
        - startsAt
        - status
        - conditions
        - rewardsConfig
        - createdAt
        - updatedAt
        - createdBy
        - updatedBy
      description: A leaderboard configuration (admin view)
      title: LeaderboardConfigAdmin
    error.BAD_REQUEST:
      type: object
      properties:
        message:
          type: string
          description: The error message
          example: Invalid input data
        code:
          type: string
          description: The error code
          example: BAD_REQUEST
        issues:
          type: array
          items:
            type: object
            properties:
              message:
                type: string
            required:
              - message
          description: An array of issues that were responsible for the error
          example: []
      required:
        - message
        - code
      title: Error
      description: The error information
      example:
        code: BAD_REQUEST
        message: Invalid input data
        issues: []
    error.INTERNAL_SERVER_ERROR:
      type: object
      properties:
        message:
          type: string
          description: The error message
          example: Internal server error
        code:
          type: string
          description: The error code
          example: INTERNAL_SERVER_ERROR
        issues:
          type: array
          items:
            type: object
            properties:
              message:
                type: string
            required:
              - message
          description: An array of issues that were responsible for the error
          example: []
      required:
        - message
        - code
      title: Error
      description: The error information
      example:
        code: INTERNAL_SERVER_ERROR
        message: Internal server error
        issues: []
    LeaderboardRewardsConfig:
      type: object
      properties:
        startRank:
          type: number
          minimum: 1
          description: The starting rank (inclusive) for this reward tier
        endRank:
          type: number
          minimum: 1
          description: The ending rank (inclusive) for this reward tier
        distributionEventId:
          type: string
          pattern: ^[0-9a-fA-F]{24}$
          description: >-
            The distribution event ID that defines the rewards for this rank
            range
      required:
        - startRank
        - endRank
        - distributionEventId
      description: Configuration for rewards distribution based on leaderboard rank
      title: LeaderboardRewardsConfig
  securitySchemes:
    ApiToken:
      type: apiKey
      in: header
      name: x-api-token

````