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

# Batch assign/unassign tier structures

> 
<Info>

<Badge color="gray">Documentation in progress</Badge>

This documentation is in progress. The parameters, fields, request and response bodies, and other data may be subject to change. If you need more information or you want to share feedback, contact [Voucherify support](https://www.voucherify.io/contact-support) or your Technical Account Manager.

</Info>

Assigns and/or unassigns tier structures to/from a program in a single batch.
Unassign operations are processed before assign operations. Unassigning is only
allowed while the program is in `DRAFT` status - otherwise the request is rejected
with `423 Locked` (key `non_draft_program`). A program can have at most one tier
structure assigned. In strict mode (default) missing tier structures, inactive tier
structures or missing assignments cause the whole batch to fail.



## OpenAPI

````yaml /openapi/loyalties-v2.json post /v2/loyalties/programs/{programId}/tier-structures/batch
openapi: 3.1.0
info:
  title: Voucherify API - Loyalty v2
  version: v2018-08-01
  description: >-
    Voucherify promotion engine REST API. Please see
    https://docs.voucherify.io/docs for more details.
  contact:
    name: Voucherify Team
    url: https://www.voucherify.io/contact-support
    email: support@voucherify.io
  termsOfService: https://www.voucherify.io/legal/subscription-agreement
  license:
    name: MIT
    url: https://github.com/voucherifyio/voucherify-js-sdk/blob/main/LICENSE
servers:
  - url: https://{cluster}.voucherify.io
    description: Base URL
    variables:
      cluster:
        default: api
        enum:
          - api
          - us1.api
          - as1.api
          - download
          - us1.download
          - as1.download
security: []
paths:
  /v2/loyalties/programs/{programId}/tier-structures/batch:
    parameters:
      - name: programId
        in: path
        required: true
        description: Unique program identifier.
        schema:
          type: string
          pattern: ^lprg_[a-f0-9]+$
    post:
      tags:
        - Programs
      summary: Batch assign/unassign tier structures
      description: >-

        <Info>


        <Badge color="gray">Documentation in progress</Badge>


        This documentation is in progress. The parameters, fields, request and
        response bodies, and other data may be subject to change. If you need
        more information or you want to share feedback, contact [Voucherify
        support](https://www.voucherify.io/contact-support) or your Technical
        Account Manager.


        </Info>


        Assigns and/or unassigns tier structures to/from a program in a single
        batch.

        Unassign operations are processed before assign operations. Unassigning
        is only

        allowed while the program is in `DRAFT` status - otherwise the request
        is rejected

        with `423 Locked` (key `non_draft_program`). A program can have at most
        one tier

        structure assigned. In strict mode (default) missing tier structures,
        inactive tier

        structures or missing assignments cause the whole batch to fail.
      operationId: batchProgramTierStructureAssignments
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: >-
                #/components/schemas/V2LoyaltiesProgramsTierStructuresBatchRequestBody
      responses:
        '200':
          description: Batch processing result.
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/V2LoyaltiesProgramsTierStructuresBatchResponseBody
        '400':
          description: >-
            Validation error - request body or query parameters failed
            validation, or the operation is not allowed in the current resource
            state.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Resource not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: Conflict - e.g. duplicate resource or invalid state transition.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '423':
          description: >-
            Resource locked - a related resource is in a state that prevents
            this operation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                Internal server error:
                  value:
                    code: 500
                    key: api_error
                    message: >-
                      Something went wrong. Don't worry, your campaigns are
                      still safe and the Voucherify Team has been notified.
                      Check out our Help Center and forums for help, or head
                      back to home.
      security:
        - X-App-Id: []
          X-App-Token: []
        - bearerAuth: []
components:
  schemas:
    V2LoyaltiesProgramsTierStructuresBatchRequestBody:
      title: V2 Loyalties Programs Tier Structures Batch Request Body
      type: object
      description: >-
        Request body schema for **POST**
        `/v2/loyalties/programs/{programId}/tier-structures/batch`.
      allOf:
        - $ref: '#/components/schemas/ProgramTierStructureBatchRequest'
    V2LoyaltiesProgramsTierStructuresBatchResponseBody:
      title: V2 Loyalties Programs Tier Structures Batch Response Body
      type: object
      description: >-
        Response body schema for **POST**
        `/v2/loyalties/programs/{programId}/tier-structures/batch`.
      allOf:
        - $ref: '#/components/schemas/ProgramTierStructureBatchResponse'
    ErrorResponse:
      type: object
      description: Standard error response returned by all Loyalty v2 endpoints.
      properties:
        code:
          type: integer
          description: HTTP status code of the error.
        key:
          type: string
          description: Machine-readable error key.
        message:
          type: string
          description: Human-readable error message.
        details:
          type: string
          description: Additional details about the error.
        request_id:
          type: string
          description: Unique identifier of the request that produced the error.
        resource_id:
          type: string
          description: Unique identifier of the resource that produced the error.
        resource_type:
          type: string
          description: Type of the resource that produced the error.
    ProgramTierStructureBatchRequest:
      type: object
      description: >-
        Batch of tier structure assignment operations. `unassign` operations are
        processed

        before `assign` operations. Duplicate ids within a batch are rejected.
      properties:
        assign:
          description: Tier structures to assign.
          oneOf:
            - type: array
              items:
                $ref: '#/components/schemas/ProgramTierStructureAssignItem'
              maxItems: 10
            - type: 'null'
        unassign:
          description: Tier structures to unassign.
          oneOf:
            - type: array
              items:
                $ref: '#/components/schemas/ProgramTierStructureUnassignItem'
              maxItems: 10
            - type: 'null'
        options:
          description: Batch behavior. Defaults to strict mode when omitted.
          oneOf:
            - $ref: '#/components/schemas/ProgramTierStructureBatchOptions'
            - type: 'null'
      additionalProperties: false
    ProgramTierStructureBatchResponse:
      type: object
      description: >-
        Result of a tier structure assignment batch. Keys are null when the
        corresponding operation list was not provided.
      properties:
        assigned:
          description: >-
            Assignments created by the batch, or `null` when no assign
            operations were requested.
          oneOf:
            - type: array
              items:
                $ref: '#/components/schemas/ProgramTierStructureAssignment'
            - type: 'null'
        unassigned:
          description: >-
            Assignments removed by the batch, or `null` when no unassign
            operations were requested.
          oneOf:
            - type: array
              items:
                $ref: '#/components/schemas/ProgramTierStructureAssignment'
            - type: 'null'
    ProgramTierStructureAssignItem:
      description: Tier structure to assign to the program.
      allOf:
        - $ref: '#/components/schemas/ProgramTierStructureAssignmentItem'
      unevaluatedProperties: false
    ProgramTierStructureUnassignItem:
      description: Tier structure to unassign from the program.
      allOf:
        - $ref: '#/components/schemas/ProgramTierStructureAssignmentItem'
      unevaluatedProperties: false
    ProgramTierStructureBatchOptions:
      type: object
      description: Options for a tier structure assignment batch.
      properties:
        strict:
          type: boolean
          description: >-
            Fails the batch when a tier structure is missing or inactive, or
            when an assignment to remove is missing. Defaults to `true`.
          default: true
      additionalProperties: false
    ProgramTierStructureAssignment:
      type: object
      description: A tier structure assigned to a program.
      properties:
        tier_structure_id:
          type: string
          pattern: ^lts_[a-f0-9]+$
          description: Unique tier structure identifier.
        created_at:
          type: string
          format: date-time
          description: Assignment creation timestamp (ISO 8601).
        object:
          type: string
          description: Object type marker.
          const: program_tier_structure
      required:
        - tier_structure_id
        - created_at
        - object
    ProgramTierStructureAssignmentItem:
      type: object
      properties:
        id:
          type: string
          pattern: ^lts_[a-f0-9]+$
          description: Unique tier structure identifier.
      required:
        - id
  securitySchemes:
    X-App-Id:
      type: apiKey
      name: X-App-Id
      in: header
    X-App-Token:
      type: apiKey
      name: X-App-Token
      in: header
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.