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

# Create invitations

> Creates a batch of invitations. Invitations are supported only for SURVEY Studies, not IN_PRODUCT_SURVEY Studies.



## OpenAPI

````yaml /reference/study-api-v2.json post /v2/studies/{studyId}/invitations
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}/invitations:
    post:
      tags:
        - Invitations
      summary: Create invitations
      description: >-
        Creates a batch of invitations. Invitations are supported only for
        SURVEY Studies, not IN_PRODUCT_SURVEY Studies.
      operationId: createInvitations
      parameters:
        - schema:
            type: string
            format: uuid
          required: true
          name: studyId
          in: path
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateInvitationsBody'
      responses:
        '201':
          description: Invitation batch created or returned for the idempotency key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateInvitationsResponse'
        '400':
          description: The request is invalid, or the Study is not a shareable survey.
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/ErrorResponse'
                    title: API error
                  - $ref: '#/components/schemas/SimpleErrorResponse'
                    title: Legacy error
                title: Invitation request error
        '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'
      security:
        - EnvironmentApiKey: []
components:
  schemas:
    CreateInvitationsBody:
      type: object
      properties:
        count:
          type: integer
          minimum: 1
          maximum: 10000
          description: How many invitations to generate.
        idempotencyKey:
          type: string
          minLength: 1
          description: >-
            A key you choose to name this batch. Sending the same key again
            returns the batch it first created and generates nothing new, even
            if `count` differs, so a retried request never doubles up on
            invitations.
      required:
        - count
        - idempotencyKey
      additionalProperties: false
      description: A request for one batch of invitations.
    CreateInvitationsResponse:
      type: object
      properties:
        invitations:
          type: array
          items:
            $ref: '#/components/schemas/Invitation'
          description: Generated invitations in creation order.
      required:
        - invitations
      additionalProperties: false
      description: One generated invitation batch.
    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.
    SimpleErrorResponse:
      type: object
      properties:
        error:
          type: string
      required:
        - error
      additionalProperties: false
      description: Legacy error envelope returned by invitation creation.
    Invitation:
      type: object
      properties:
        code:
          type: string
          description: Invitation code used as the `iid` query parameter.
        url:
          type: string
          format: uri
          description: Link for exactly one respondent.
      required:
        - code
        - url
      additionalProperties: false
      description: >-
        A respondent link to a Study. Its response limit is controlled by the
        Study retake settings.
  securitySchemes:
    EnvironmentApiKey:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        Use `API-Key YOUR_API_KEY`. The key selects the Production or
        Development environment.

````