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

# Associate a token to a voucher

> This endpoint allows you to associate a token to a voucher.

A Voucher belongs to a Voucher Group and is uniquely identified by a code.
It can be linked to multiple tokens (idtags) and appUsers.

When a driver starts a session at a location, the system checks:

If the driver’s token is linked to a voucher, or

If the driver’s appUser (linked to that token) is linked to a voucher.

If either is true and the voucher’s group is associated with the location, the voucher is applied — potentially affecting pricing or granting access.



## OpenAPI

````yaml /openapi/integration-api-v2/openapi.yaml post /v2/vouchers/{id}/tokens/{tokenId}
openapi: 3.0.0
info:
  title: Spirii API
  description: Spirii API
  version: 2.10.0
  contact: {}
servers:
  - url: https://api.spirii.com
security: []
tags: []
paths:
  /v2/vouchers/{id}/tokens/{tokenId}:
    post:
      tags:
        - Vouchers
      summary: Associate a token to a voucher
      description: >-
        This endpoint allows you to associate a token to a voucher.


        A Voucher belongs to a Voucher Group and is uniquely identified by a
        code.

        It can be linked to multiple tokens (idtags) and appUsers.


        When a driver starts a session at a location, the system checks:


        If the driver’s token is linked to a voucher, or


        If the driver’s appUser (linked to that token) is linked to a voucher.


        If either is true and the voucher’s group is associated with the
        location, the voucher is applied — potentially affecting pricing or
        granting access.
      operationId: associateTokenToVoucher
      parameters:
        - name: id
          required: true
          in: path
          description: Used to identify the voucher throughout the Spirii system
          schema:
            type: number
        - name: tokenId
          required: true
          in: path
          description: Used to identify the token throughout the Spirii system
          schema:
            type: number
      responses:
        '201':
          description: The token has been successfully associated with a voucher.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VoucherUsageDto'
        '404':
          description: >-
            The voucher with the provided ID was not found.


            Token for the given ID has not been found, or Voucher for the given
            ID has not been found.
components:
  schemas:
    VoucherUsageDto:
      type: object
      properties:
        id:
          type: number
          format: integer
          description: Used to identify the voucher link to customers and tokens.
          example: 67890
        customerId:
          type: number
          nullable: true
          format: integer
          description: Used to identify the customer throughout the Spirii system.
          example: 67890
        idTagId:
          type: number
          nullable: true
          format: integer
          description: >-
            Used to identify the id tag (token/charge key) throughout the Spirii
            system.
          example: 67890
        voucherId:
          type: number
          format: integer
          description: >-
            Used to identify the voucher (not to be confused with token/charge
            key) throughout the Spirii system.
          example: 67890
        createdAt:
          format: date-time
          type: string
          description: The date and time when the voucher was created.
          example: '2025-06-03T12:00:00.000Z'
      required:
        - voucherId
        - createdAt

````