statsig Feature Gates API

Endpoints for evaluating feature gates for users, returning boolean pass/fail values along with rule identification.

OpenAPI Specification

statsig-feature-gates-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Statsig Client SDK Audit Logs Feature Gates API
  description: The Statsig Client SDK API provides endpoints that power Statsig's client-side SDKs for JavaScript, React, React Native, iOS, Android, Unity, and other platforms. Client SDKs use Client-SDK Keys that are safe to embed in mobile apps and front-end web applications. They access the initialize endpoint to retrieve all evaluated gates, configs, and experiments for a given user, and the log_event endpoint for sending analytics events. The SDKs handle local evaluation, caching, and automatic error handling for performant client-side feature flagging.
  version: 1.0.0
  contact:
    name: Statsig Support
    url: https://statsig.com/support
  termsOfService: https://statsig.com/terms
servers:
- url: https://api.statsig.com/v1
  description: Statsig API Server
security:
- clientSdkKey: []
tags:
- name: Feature Gates
  description: Endpoints for evaluating feature gates for users, returning boolean pass/fail values along with rule identification.
paths:
  /check_gate:
    post:
      operationId: checkGate
      summary: Check a feature gate
      description: Evaluates a single feature gate for the specified user and returns the boolean pass/fail result along with rule identification. Statsig automatically logs an exposure event for the gate check.
      tags:
      - Feature Gates
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - user
              - gateName
              properties:
                user:
                  $ref: '#/components/schemas/StatsigUser'
                gateName:
                  type: string
                  description: The name of the feature gate to evaluate.
      responses:
        '200':
          description: Gate evaluation result
          content:
            application/json:
              schema:
                type: object
                properties:
                  name:
                    type: string
                    description: The name of the gate that was evaluated.
                  value:
                    type: boolean
                    description: Whether the user passes the gate.
                  rule_id:
                    type: string
                    description: The identifier of the rule that was matched.
                  group_name:
                    type: string
                    description: The name of the group the user was assigned to.
        '401':
          $ref: '#/components/responses/Unauthorized'
  /check_gate_multiple:
    post:
      operationId: checkGateMultiple
      summary: Check multiple feature gates
      description: Evaluates multiple feature gates for the specified user in a single request and returns the boolean pass/fail results for each gate. Statsig automatically logs exposure events for each gate check.
      tags:
      - Feature Gates
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - user
              - gateNames
              properties:
                user:
                  $ref: '#/components/schemas/StatsigUser'
                gateNames:
                  type: array
                  items:
                    type: string
                  description: An array of feature gate names to evaluate.
      responses:
        '200':
          description: Multiple gate evaluation results
          content:
            application/json:
              schema:
                type: object
                properties:
                  results:
                    type: array
                    items:
                      type: object
                      properties:
                        name:
                          type: string
                          description: The name of the gate that was evaluated.
                        value:
                          type: boolean
                          description: Whether the user passes the gate.
                        rule_id:
                          type: string
                          description: The identifier of the rule that was matched.
                        group_name:
                          type: string
                          description: The name of the group the user was assigned to.
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  responses:
    Unauthorized:
      description: Missing or invalid API key
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Error message describing the authentication failure.
  schemas:
    StatsigUser:
      type: object
      description: The user object representing the end user being evaluated. At minimum, a userID should be provided. Additional properties enable more sophisticated targeting.
      properties:
        userID:
          type: string
          description: A unique identifier for the user.
        email:
          type: string
          format: email
          description: The email address of the user, used for email-based targeting.
        ip:
          type: string
          description: The IP address of the user, used for IP-based targeting.
        userAgent:
          type: string
          description: The user agent string, used for browser or device targeting.
        country:
          type: string
          description: The two-letter country code of the user.
        locale:
          type: string
          description: The locale identifier for the user.
        appVersion:
          type: string
          description: The version of the application the user is using.
        custom:
          type: object
          additionalProperties: true
          description: Custom properties for the user, used for custom targeting rules.
        privateAttributes:
          type: object
          additionalProperties: true
          description: Private user attributes used for evaluation but stripped before logging to Statsig servers.
        customIDs:
          type: object
          additionalProperties:
            type: string
          description: Custom identifier mappings for the user, such as companyID or teamID.
  securitySchemes:
    clientSdkKey:
      type: apiKey
      in: header
      name: statsig-api-key
      description: Client-SDK Key that is safe to embed in mobile apps and front-end web applications. Created in Project Settings > API Keys tab.
externalDocs:
  description: Statsig Client SDK Documentation
  url: https://docs.statsig.com/client/introduction