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

# Update card PIN

> Change the PIN of the authenticated user's primary card.

<Note>
  Requires `Authorization: Bearer <user-access-token>` — the token from [Verify login code](/api-reference/users/verify-otp).
</Note>

<Tip>
  Pass `x-idempotency-key` with a unique UUID per request. Without it, duplicate-request detection is skipped and a retried call may change the PIN twice.
</Tip>

The PIN must be 4 to 12 digits. When no `cardId` is sent, the new PIN is applied to every active card the user has, not just the primary card.


## OpenAPI

````yaml api-reference/openapi.json PUT /api/v1/cards/pin
openapi: 3.1.0
info:
  title: QASH API
  description: >-
    QASH endpoints for exchange rates, cards, and partner-facing financial
    workflows.
  version: 1.0.0
servers:
  - url: https://api.qash.ai
    description: Partner API (Production)
  - url: https://staging.qash.ai
    description: Staging
  - url: https://app.qash.ai
    description: Production
security: []
tags:
  - name: Exchange rates
    description: Public endpoints for supported assets and TRM-based quotes.
  - name: Cards
    description: >-
      Authenticated partner endpoints for card state, controls, limits, and
      balances.
  - name: Users
    description: Admin endpoints for user provisioning and account management.
paths:
  /api/v1/cards/pin:
    put:
      tags:
        - Cards
      summary: Update card PIN
      description: >-
        Updates the PIN for the authenticated user's primary card (or every
        active card when no cardId is sent).
      operationId: updateMyCardPin
      parameters:
        - $ref: '#/components/parameters/IdempotencyKeyHeader'
        - name: cardId
          in: query
          required: false
          description: Target a specific card (Rain card id) instead of the primary card.
          schema:
            type: string
      requestBody:
        description: New PIN, 4 to 12 digits.
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateCardPinRequest'
            examples:
              default:
                summary: New PIN
                value:
                  pin: '9876'
      responses:
        '200':
          description: PIN updated successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CardPinUpdateResponse'
              examples:
                default:
                  summary: PIN updated
                  value:
                    success: true
        '400':
          description: Invalid PIN format (must be 4 to 12 digits).
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/CardNotFound'
        '409':
          $ref: '#/components/responses/DuplicateIdempotencyKey'
      security:
        - bearerAuth: []
components:
  parameters:
    IdempotencyKeyHeader:
      name: x-idempotency-key
      in: header
      required: true
      description: >-
        Unique idempotency key for the operation. Use a UUID to prevent
        duplicate processing.
      schema:
        type: string
        format: uuid
  schemas:
    UpdateCardPinRequest:
      type: object
      properties:
        pin:
          type: string
          example: '9876'
          pattern: ^\d{4,12}$
          description: New PIN, 4 to 12 digits.
      required:
        - pin
    CardPinUpdateResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        cardId:
          type:
            - string
            - 'null'
          format: uuid
          description: Representative card id when no cardId was targeted.
        last4:
          type:
            - string
            - 'null'
          example: '8567'
        updatedCount:
          type: integer
          example: 1
          description: Number of active cards updated (present when no cardId is sent).
        failedCount:
          type: integer
          example: 0
        results:
          type: array
          items:
            type: object
            properties:
              cardId:
                type: string
                format: uuid
              rainCardId:
                type:
                  - string
                  - 'null'
              success:
                type: boolean
      required:
        - success
  responses:
    Unauthorized:
      description: Invalid or expired JWT.
    CardNotFound:
      description: The authenticated user does not have a registered card.
    DuplicateIdempotencyKey:
      description: The provided idempotency key has already been used.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````