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

# Create points triggers

> Create points triggers in bulk. Maximum 100 triggers per request.



## OpenAPI

````yaml https://admin.trophy.so/v1/openapi post /points/{systemId}/triggers
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:
  /points/{systemId}/triggers:
    servers:
      - url: https://admin.trophy.so/v1
        description: Admin API
    parameters:
      - $ref: '#/components/parameters/TenantId'
    post:
      tags:
        - Admin
      summary: Create points triggers
      description: Create points triggers in bulk. Maximum 100 triggers per request.
      operationId: admin_points_triggers_create
      parameters:
        - name: systemId
          in: path
          description: The UUID of the points system.
          required: true
          schema:
            type: string
            format: uuid
          example: 550e8400-e29b-41d4-a716-446655440000
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreatePointsTriggersRequest'
      responses:
        '200':
          description: >-
            Request was valid but no triggers were created (all items had
            issues).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreatePointsTriggersResponse'
        '201':
          description: At least one trigger was created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreatePointsTriggersResponse'
              examples:
                Created triggers:
                  value:
                    created:
                      - id: 550e8400-e29b-41d4-a716-446655440000
                        type: metric
                        points: 10
                        status: active
                        userAttributes: []
                        metricId: 660f9500-f30c-42e5-b827-557766550001
                        metricThreshold: 5
                        eventAttributes: []
                        blockIfOutOfPoints: false
                    issues: []
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AdminErrorBody'
        '404':
          description: Not Found (points system not found)
          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 result = await
            trophy.admin.points.triggers.create('system-uuid', [
              {
                type: 'metric',
                points: 10,
                metricId: 'metric-uuid',
                metricThreshold: 5
              }
            ]);
        - lang: python
          source: |
            from trophy import TrophyApi

            client = TrophyApi(api_key='YOUR_API_KEY')

            result = client.admin.points.triggers.create(
              system_id='system-uuid',
              request=[{
                'type': 'metric',
                'points': 10,
                'metric_id': 'metric-uuid',
                'metric_threshold': 5
              }]
            )
        - 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.Points.Triggers.Create(context.TODO(),
            "system-uuid", api.CreatePointsTriggersRequest{})
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:
    CreatePointsTriggersRequest:
      title: CreatePointsTriggersRequest
      type: array
      description: Array of points triggers to create. Maximum 100 triggers per request.
      items:
        $ref: '#/components/schemas/CreatePointsTriggerRequestItem'
      maxItems: 100
      minItems: 1
    CreatePointsTriggersResponse:
      title: CreatePointsTriggersResponse
      type: object
      description: Response containing created triggers and any per-item issues.
      properties:
        created:
          type: array
          items:
            $ref: '#/components/schemas/AdminPointsTrigger'
          description: Array of successfully created triggers.
        issues:
          type: array
          items:
            $ref: '#/components/schemas/AdminIssue'
          description: Array of issues encountered during trigger creation.
      required:
        - created
        - issues
    AdminErrorBody:
      title: AdminErrorBody
      type: object
      properties:
        error:
          type: string
      required:
        - error
    CreatePointsTriggerRequestItem:
      title: CreatePointsTriggerRequestItem
      type: object
      description: A points trigger to create.
      properties:
        type:
          type: string
          enum:
            - metric
            - achievement
            - streak
            - time
            - user_creation
          description: The type of trigger.
          example: metric
        points:
          type: integer
          description: >-
            The number of points to award or deduct when the trigger fires.
            Cannot be zero.
          example: 10
        status:
          type: string
          enum:
            - active
            - inactive
          default: inactive
          description: The status of the trigger. Defaults to 'inactive'.
          example: inactive
        userAttributes:
          type:
            - array
            - 'null'
          description: Optional user attribute filters for the trigger.
          items:
            type: object
            properties:
              attributeId:
                type: string
                format: uuid
                description: The UUID of the user attribute.
              attributeValue:
                type: string
                description: The value to match.
            required:
              - attributeId
              - attributeValue
        metricId:
          type: string
          format: uuid
          description: Required if type is `metric`. The UUID of the metric.
        metricThreshold:
          type: integer
          minimum: 1
          description: >-
            Required if type is `metric`. The metric increment that triggers the
            points.
        eventAttributes:
          type:
            - array
            - 'null'
          description: >-
            Optional event attribute filters. Only permitted if type is
            `metric`.
          items:
            type: object
            properties:
              attributeId:
                type: string
                format: uuid
                description: The UUID of the event attribute.
              attributeValue:
                type: string
                description: The value to match.
            required:
              - attributeId
              - attributeValue
        achievementId:
          type: string
          format: uuid
          description: Required if type is `achievement`. The UUID of the achievement.
        streakLength:
          type: integer
          minimum: 1
          description: >-
            Required if type is `streak`. The number of streak periods that
            triggers the points.
        timeUnit:
          type: string
          enum:
            - hours
            - days
          description: Required if type is `time`. The unit for the time interval.
        timeInterval:
          type: integer
          minimum: 1
          description: >-
            Required if type is `time`. The number of time units between
            recurring awards.
        blockIfOutOfPoints:
          type: boolean
          default: false
          description: >-
            Whether to block metric events that would reduce the user's points
            below zero. Defaults to false.
      required:
        - type
        - points
    AdminPointsTrigger:
      title: AdminPointsTrigger
      type: object
      description: A points trigger as returned from admin endpoints.
      properties:
        id:
          type: string
          format: uuid
          description: The UUID of the trigger.
        type:
          type: string
          enum:
            - metric
            - achievement
            - streak
            - time
            - user_creation
          description: The type of trigger.
        points:
          type: integer
          description: The number of points awarded or deducted when the trigger fires.
        status:
          type: string
          enum:
            - active
            - inactive
          description: The status of the trigger.
        userAttributes:
          type: array
          description: User attribute filters applied to the trigger.
          items:
            type: object
            properties:
              attributeId:
                type: string
                format: uuid
              attributeValue:
                type: string
            required:
              - attributeId
              - attributeValue
        metricId:
          type: string
          format: uuid
          description: The UUID of the metric. Only present for metric triggers.
        metricThreshold:
          type: integer
          description: The metric threshold. Only present for metric triggers.
        eventAttributes:
          type: array
          description: >-
            Event attribute filters applied to the trigger. Only present for
            metric triggers.
          items:
            type: object
            properties:
              attributeId:
                type: string
                format: uuid
              attributeValue:
                type: string
            required:
              - attributeId
              - attributeValue
        achievementId:
          type: string
          format: uuid
          description: The UUID of the achievement. Only present for achievement triggers.
        streakLength:
          type: integer
          description: The streak length. Only present for streak triggers.
        timeUnit:
          type: string
          enum:
            - hours
            - days
          description: The time unit. Only present for time triggers.
        timeInterval:
          type: integer
          description: The time interval. Only present for time triggers.
        blockIfOutOfPoints:
          type: boolean
          description: >-
            Whether metric events that would reduce the user's points below zero
            are blocked.
      required:
        - id
        - type
        - points
        - status
        - userAttributes
        - blockIfOutOfPoints
    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

````