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

# Update a token

> This endpoint allows you to update a token.

  In EV charging systems, tokens (also known as ID tags or charge keys) are unique identifiers that authenticate users to initiate a charging session. Spirii differentiates between three different types of tokens:

  - RFIDs represent a physical identifier with a MiFare chip that can be read by chargers.
  - Virtual tokens represent a digital identifier for authentication through the Spirii app (or a branded app)
  - Vehicle tokens (also known as “Autocharge”) represent the vehicle's MAC address or VIN code that when registered in Spirii’s platform. They allow a charger to recognize a vehicle and authorize charging when a vehicle is plugged in.



## OpenAPI

````yaml /openapi/integration-api-v2/openapi.yaml patch /v2/tokens/{id}
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/tokens/{id}:
    patch:
      tags:
        - Tokens
      summary: Update a token
      description: |-
        This endpoint allows you to update a token.

          In EV charging systems, tokens (also known as ID tags or charge keys) are unique identifiers that authenticate users to initiate a charging session. Spirii differentiates between three different types of tokens:

          - RFIDs represent a physical identifier with a MiFare chip that can be read by chargers.
          - Virtual tokens represent a digital identifier for authentication through the Spirii app (or a branded app)
          - Vehicle tokens (also known as “Autocharge”) represent the vehicle's MAC address or VIN code that when registered in Spirii’s platform. They allow a charger to recognize a vehicle and authorize charging when a vehicle is plugged in.
      operationId: updateToken
      parameters:
        - name: id
          required: true
          in: path
          description: Used to identify the token throughout the Spirii system
          schema:
            type: number
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateTokenDto'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenResponseDto'
        '400':
          description: Bad Request provided. A message will describe the issue.
        '403':
          description: Authorization header JWT token is invalid or not provided.
        '404':
          description: The provided token ID or customer ID was not found.
        '500':
          description: Internal Server Error.
      security:
        - Authorization: []
components:
  schemas:
    UpdateTokenDto:
      type: object
      properties:
        validFrom:
          format: date-time
          type: string
          description: >-
            Date and time from when the token can be used (ISO-8601 format).
            Defaults to current time if not provided.
          example: '2025-06-03T12:00:00.000Z'
        expiresAt:
          format: date-time
          type: string
          nullable: true
          description: Date and time when the token expires (ISO-8601 format).
          example: '2025-12-31T23:59:59.999Z'
        isActive:
          type: boolean
          description: Indicates if the token is currently active.
          default: true
          example: true
        roamingEnabled:
          type: boolean
          description: Indicates if roaming is enabled for this token.
          default: true
          example: true
        priorityChargingEnabled:
          type: boolean
          description: >-
            Enables priority charging on the operator owned locations if set to
            true.
          example: true
        billingReference:
          type: string
          nullable: true
          maxLength: 100
          description: |-
            Reference used for billing purposes.
                 This is a free field and can, for instance, be a billing reference on invoices or a cost centre reference.
                 Leaving it empty, means it won't show on Spirii-generated billing documents.
          example: Bil 246
        comment:
          type: string
          nullable: true
          maxLength: 100
          description: Optional comment about the token.
          example: This is a comment
        identifier:
          description: Token identifier information. Only appUserId can be updated.
          allOf:
            - $ref: '#/components/schemas/UpdateTokenIdentifier'
        customerId:
          type: number
          format: integer
          description: >-
            Unique identifier of the associated billing customer. Generally, the
            owner of the token and the entity that receives the monthly billing
                 in case no credit card is attached to the token. Ensure the right customerId for the right entity to be billed.
          example: 67890
    TokenResponseDto:
      type: object
      properties:
        id:
          type: number
          format: integer
          description: Used to identify the token throughout the Spirii system.
          example: 67890
          readOnly: true
        customerId:
          type: number
          format: integer
          description: >-
            Unique identifier of the associated billing customer. Generally, the
            owner of the token and the entity that receives the monthly billing
                 in case no credit card is attached to the token. Ensure the right customerId for the right entity to be billed.
          example: 67890
        identifier:
          description: Token identifier information.
          oneOf:
            - $ref: '#/components/schemas/RfidIdentifier'
            - $ref: '#/components/schemas/VirtualIdentifier'
            - $ref: '#/components/schemas/EVIdentifier'
        validFrom:
          format: date-time
          type: string
          description: >-
            Date and time from when the token can be used (ISO-8601 format).
            Defaults to current time if not provided.
          example: '2025-06-03T12:00:00.000Z'
        expiresAt:
          format: date-time
          type: string
          nullable: true
          description: Date and time when the token expires (ISO-8601 format).
          example: '2025-12-31T23:59:59.999Z'
        isActive:
          type: boolean
          description: Indicates if the token is currently active.
          default: true
          example: true
        roamingEnabled:
          type: boolean
          description: Indicates if roaming is enabled for this token.
          default: true
          example: true
        priorityChargingEnabled:
          type: boolean
          description: >-
            Enables priority charging on the operator owned locations if set to
            true.
          example: true
        billingReference:
          type: string
          nullable: true
          maxLength: 100
          description: |-
            Reference used for billing purposes.
                 This is a free field and can, for instance, be a billing reference on invoices or a cost centre reference.
                 Leaving it empty, means it won't show on Spirii-generated billing documents.
          example: Bil 246
        comment:
          type: string
          nullable: true
          maxLength: 100
          description: Optional comment about the token.
          example: This is a comment
        createdAt:
          format: date-time
          type: string
          description: The date and time when the token was created.
          example: '2025-06-03T12:00:00.000Z'
          readOnly: true
        updatedAt:
          format: date-time
          type: string
          description: The date and time when the token was last updated.
          example: '2025-06-03T12:00:00.000Z'
          readOnly: true
        tokenGroupIds:
          description: >-
            List of token group IDs this token belongs to (returned only when
            requested).
          example:
            - 1
            - 2
            - 5
          type: array
          items:
            type: number
      required:
        - id
        - customerId
        - identifier
        - createdAt
        - updatedAt
    UpdateTokenIdentifier:
      type: object
      properties:
        appUserId:
          type: number
          minimum: 1
          maximum: 10000000
          description: The unique identifier of the associated app user.
          example: 12345
    RfidIdentifier:
      type: object
      properties:
        type:
          enum:
            - rfid
          type: string
          default: rfid
          description: The identifier type of the token.
          example: rfid
        appUserId:
          type: number
          minimum: 1
          maximum: 10000000
          description: The unique identifier of the associated app user.
          example: 12345
        uid:
          type: string
          maxLength: 20
          description: >-
            Unique identifier of the token. Usually the physical and unique
            identifier of the RFID chip.
          example: A7E942F1C8D036B5A429
        label:
          type: string
          maxLength: 50
          pattern: ^[A-Z0-9.-]+$
          description: >-
            Token label - used for recognizing the individual token. This is a
            free field and can, for instance, be a printed label on the physical
            token (e.g. DK.SPI.0001234),
                  a driver name or a vehicle number of your fleet (EVBUS.0007)
          example: DK.SPI.V03198
      description: Physical identifier used to authenticate charging via a key.
      required:
        - type
        - uid
        - label
    VirtualIdentifier:
      type: object
      properties:
        type:
          enum:
            - virtual
          type: string
          default: virtual
          description: The identifier type of the token.
          example: virtual
        appUserId:
          type: number
          minimum: 1
          maximum: 10000000
          description: The unique identifier of the associated app user.
          example: 12345
        uid:
          type: string
          description: >-
            Unique identifier for the virtual token. It is a generated random 20
            characters string containing numbers and ABCDEF letters (Matching
            regular expression: ^[0-9A-F]{20}$).
          minLength: 20
          maxLength: 20
          example: A7E942F1C8D036B5A429
          readOnly: true
        label:
          type: string
          maxLength: 50
          pattern: ^[A-Z0-9.-]+$
          description: >-
            Token label - used for recognizing the individual token. This is
            free field and can, for instance, be a driver or vehicle name or a
            simple combination of letters/numbers.
                  
            If not provided, an autogenerated incremental label will be
            generated as follow DK.SPI.V<incremental 5 digits number>. e.g.
            DK.SPI.V00123
          example: DK.SPI.V03198
      description: Digital identifier used to authenticate charging via the app.
      required:
        - type
        - uid
    EVIdentifier:
      type: object
      properties:
        type:
          enum:
            - vehicleId
          type: string
          default: vehicleId
          description: The identifier type of the token.
          example: vehicleId
        appUserId:
          type: number
          minimum: 1
          maximum: 10000000
          description: The unique identifier of the associated app user.
          example: 12345
        uid:
          type: string
          maxLength: 20
          description: >-
            Unique identifier for the token. This can be a MAC address or a VIN
            (Autocharge) of a vehicle.
          example: 7d9e1a6c2b84
        label:
          type: string
          maxLength: 50
          description: >-
            Token label - used for recognizing the individual token. This is a
            free field and can, for instance, be the model of the EV.
          pattern: ^[A-Z0-9.-]+$
          example: DK.SPI.V03198
      description: EV charging authentication via MAC address or VIN (Autocharge).
      required:
        - type
        - uid
        - label
  securitySchemes:
    Authorization:
      type: apiKey
      in: header
      name: Authorization
      description: '`Authorization: Bearer <SPIRII_API_KEY>`'

````