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

# Get Study targeting

> Returns canonical targeting for an IN_PRODUCT_SURVEY Study, or null when targeting is not configured.



## OpenAPI

````yaml /reference/study-api-v2.json get /v2/studies/{studyId}/targeting
openapi: 3.1.0
info:
  title: Sprig Public API V2 — Studies
  version: 1.0.0
  description: >-
    Programmatically create and manage Sprig Studies (surveys), their Questions,
    Blocks, invitations, and translations.
  contact:
    name: Support
    email: support@sprig.com
servers:
  - url: https://api.sprig.com
security: []
tags:
  - name: Studies
    description: The root resource for a programmatically managed survey.
  - name: Questions
    description: Questions, with their nested options, owned by a Study.
  - name: Blocks
    description: >-
      Blocks and Pages; Pages are not supported for IN_PRODUCT_SURVEY Studies.
      Group skip and display logic live on the Block. Question logic is member
      display, plus skip logic only outside a Page.
  - name: Invitations
    description: >-
      Invitation codes for SURVEY Studies; invitations are not supported for
      IN_PRODUCT_SURVEY Studies.
  - name: Translations
    description: >-
      Per-locale translated content for a Study, and the asynchronous jobs that
      generate it. Job cancellation is best-effort and does not roll back
      committed output.
  - name: Attributes
    description: Custom Attribute definitions available in the environment.
  - name: Targeting
    description: Event triggers and audience conditions for IN_PRODUCT_SURVEY Studies.
  - name: Events
    description: Existing tracked and page-URL Events available for Study targeting.
paths:
  /v2/studies/{studyId}/targeting:
    get:
      tags:
        - Targeting
      summary: Get Study targeting
      description: >-
        Returns canonical targeting for an IN_PRODUCT_SURVEY Study, or null when
        targeting is not configured.
      operationId: getStudyTargeting
      parameters:
        - schema:
            type: string
            format: uuid
          required: true
          name: studyId
          in: path
      responses:
        '200':
          description: The complete targeting sub-resource.
          headers:
            ETag:
              description: >-
                Quoted Study version validator matching Study.version, for
                example "126300".
              schema:
                type: string
                example: '"126300"'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StudyTargetingResponse'
        '400':
          description: The request is not valid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: >-
            The environment API key is missing or invalid, cannot access this
            resource, or the Study API is not available for the account.
        '404':
          description: Study not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: Stored targeting cannot be represented by the Public API.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - EnvironmentApiKey: []
components:
  schemas:
    StudyTargetingResponse:
      anyOf:
        - $ref: '#/components/schemas/StudyTargeting'
          title: Configured targeting
        - type: 'null'
          title: Not configured
      description: >-
        The complete targeting sub-resource, or null when an editable Study has
        no targeting.
    ErrorResponse:
      type: object
      properties:
        code:
          type: string
          description: A machine-readable error code (e.g. STUDY_NOT_FOUND).
        message:
          type: string
          description: A human-readable description of the error.
        errors:
          type: array
          items:
            type: object
            properties:
              code:
                type: string
              path:
                type: string
              message:
                type: string
              resource:
                type: object
                properties:
                  type:
                    type: string
                  id:
                    type: string
                required:
                  - type
                  - id
                description: >-
                  The other resource this issue points at, when the issue is not
                  about the request itself.
            required:
              - code
              - message
          description: >-
            Per-field validation issues, present when the request itself was
            malformed.
      required:
        - code
        - message
      description: Error response returned by the Public API V2.
    StudyTargeting:
      type: object
      properties:
        triggers:
          $ref: '#/components/schemas/StudyTargetingTriggers'
        audience:
          $ref: '#/components/schemas/StudyTargetingAudience'
        delaySeconds:
          type: integer
          minimum: 0
          maximum: 999
          description: >-
            Seconds to wait after the trigger before showing the Study. Use 0
            for no delay.
      required:
        - triggers
        - audience
        - delaySeconds
      additionalProperties: false
      description: The complete targeting sub-resource for an IN_PRODUCT_SURVEY Study.
      examples:
        - triggers:
            - id: 11111111-1111-4111-8111-111111111111
          audience:
            operator: AND
            conditions:
              - type: ATTRIBUTE
                attribute: plan
                comparator: EQUALS
                value: enterprise
              - type: PAGE_VIEW_COUNT
                comparator: GREATER_THAN_OR_EQUAL
                value: 3
          delaySeconds: 10
        - triggers:
            - id: 11111111-1111-4111-8111-111111111111
            - id: 22222222-2222-4222-8222-222222222222
          audience:
            operator: AND
            conditions:
              - type: USER_ID
                comparator: EXISTS
              - type: SESSION_COUNT
                comparator: GREATER_THAN_OR_EQUAL
                value: 2
          delaySeconds: 0
    StudyTargetingTriggers:
      type: array
      items:
        $ref: '#/components/schemas/EventReference'
      minItems: 1
      maxItems: 10
      description: >-
        One to 10 existing Events. A matching Event triggers the Study, so
        multiple entries use OR semantics.
    StudyTargetingAudience:
      anyOf:
        - $ref: '#/components/schemas/StudyTargetingExpression'
          title: Audience rule
        - type: 'null'
          title: Every visitor
      description: Audience rules, or null to target every visitor.
    EventReference:
      type: object
      properties:
        id:
          type: string
          format: uuid
      required:
        - id
      additionalProperties: false
      description: >-
        References an existing tracked or page-URL Event by the ID returned from
        GET /v2/events.
    StudyTargetingExpression:
      anyOf:
        - $ref: '#/components/schemas/AttributeScalarTargetingCondition'
          title: Attribute comparison
        - $ref: '#/components/schemas/AttributeStringTargetingCondition'
          title: Attribute text match
        - $ref: '#/components/schemas/AttributeExistenceTargetingCondition'
          title: Attribute presence
        - $ref: '#/components/schemas/UserIdTargetingCondition'
          title: Identified visitor
        - $ref: '#/components/schemas/LanguageTargetingCondition'
          title: Language
        - $ref: '#/components/schemas/DeviceTypeTargetingCondition'
          title: Device type
        - $ref: '#/components/schemas/GroupTargetingCondition'
          title: Group membership
        - $ref: '#/components/schemas/SessionCountTargetingCondition'
          title: Session count
        - $ref: '#/components/schemas/PageViewCountTargetingCondition'
          title: Page view count
        - type: object
          properties:
            operator:
              type: string
              enum:
                - AND
                - OR
            conditions:
              type: array
              items:
                $ref: '#/components/schemas/StudyTargetingExpression'
              minItems: 1
              maxItems: 20
          required:
            - operator
            - conditions
          additionalProperties: false
          title: Condition group
      description: >-
        Nested AND/OR audience conditions. Each group accepts at most 20
        children. Domain validation limits nesting to 5 levels and the full
        expression to 100 conditions.
    AttributeScalarTargetingCondition:
      type: object
      properties:
        type:
          type: string
          enum:
            - ATTRIBUTE
        attribute:
          type: string
          minLength: 1
          maxLength: 128
        comparator:
          type: string
          enum:
            - EQUALS
            - NOT_EQUALS
            - GREATER_THAN
            - GREATER_THAN_OR_EQUAL
            - LESS_THAN
            - LESS_THAN_OR_EQUAL
        value:
          anyOf:
            - type: string
              title: Text value
            - type: number
              title: Numeric value
            - type: boolean
              title: Boolean value
      required:
        - type
        - attribute
        - comparator
        - value
      additionalProperties: false
      description: Compares an Attribute with a text, numeric, or Boolean value.
    AttributeStringTargetingCondition:
      type: object
      properties:
        type:
          type: string
          enum:
            - ATTRIBUTE
        attribute:
          type: string
          minLength: 1
          maxLength: 128
        comparator:
          type: string
          enum:
            - CONTAINS
            - NOT_CONTAINS
            - STARTS_WITH
            - ENDS_WITH
        value:
          type: string
      required:
        - type
        - attribute
        - comparator
        - value
      additionalProperties: false
      description: Applies a text-matching comparator to an Attribute value.
    AttributeExistenceTargetingCondition:
      type: object
      properties:
        type:
          type: string
          enum:
            - ATTRIBUTE
        attribute:
          type: string
          minLength: 1
          maxLength: 128
        comparator:
          type: string
          enum:
            - EXISTS
            - NOT_EXISTS
      required:
        - type
        - attribute
        - comparator
      additionalProperties: false
      description: Tests whether an Attribute is present for the visitor.
    UserIdTargetingCondition:
      type: object
      properties:
        type:
          type: string
          enum:
            - USER_ID
        comparator:
          type: string
          enum:
            - EXISTS
            - NOT_EXISTS
      required:
        - type
        - comparator
      additionalProperties: false
      description: >-
        Matches identified or anonymous visitors without exposing internal
        visitor IDs.
    LanguageTargetingCondition:
      type: object
      properties:
        type:
          type: string
          enum:
            - LANGUAGE
        comparator:
          type: string
          enum:
            - EQUALS
        value:
          type: string
          minLength: 1
          maxLength: 35
      required:
        - type
        - comparator
        - value
      additionalProperties: false
      description: Matches an SDK locale or language code.
    DeviceTypeTargetingCondition:
      type: object
      properties:
        type:
          type: string
          enum:
            - DEVICE_TYPE
        comparator:
          type: string
          enum:
            - EQUALS
            - NOT_EQUALS
        value:
          type: string
          enum:
            - DESKTOP
            - MOBILE
      required:
        - type
        - comparator
        - value
      additionalProperties: false
      description: Matches the browser device class. Supported only for Web Studies.
    GroupTargetingCondition:
      type: object
      properties:
        type:
          type: string
          enum:
            - GROUP
        comparator:
          $ref: '#/components/schemas/StudyTargetingMembershipComparator'
        groupId:
          type: string
          minLength: 1
          maxLength: 128
      required:
        - type
        - comparator
        - groupId
      additionalProperties: false
      description: Matches membership in an environment Group by its stable string ID.
    SessionCountTargetingCondition:
      type: object
      properties:
        type:
          type: string
          enum:
            - SESSION_COUNT
        comparator:
          $ref: '#/components/schemas/StudyTargetingNumericComparator'
        value:
          type: integer
          minimum: 1
          maximum: 999
      required:
        - type
        - comparator
        - value
      additionalProperties: false
      description: Matches the visitor session count.
    PageViewCountTargetingCondition:
      type: object
      properties:
        type:
          type: string
          enum:
            - PAGE_VIEW_COUNT
        comparator:
          $ref: '#/components/schemas/StudyTargetingNumericComparator'
        value:
          type: integer
          minimum: 1
          maximum: 999
      required:
        - type
        - comparator
        - value
      additionalProperties: false
      description: >-
        Matches page views in the current session. Supported only for Web
        Studies.
    StudyTargetingMembershipComparator:
      type: string
      enum:
        - IN
        - NOT_IN
      description: Stable public membership comparators.
    StudyTargetingNumericComparator:
      type: string
      enum:
        - EQUALS
        - GREATER_THAN
        - GREATER_THAN_OR_EQUAL
        - LESS_THAN
        - LESS_THAN_OR_EQUAL
      description: Stable public comparators for numeric conditions.
  securitySchemes:
    EnvironmentApiKey:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        Use `API-Key YOUR_API_KEY`. The key selects the Production or
        Development environment.

````