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

# Update Wallet Encryption

> Replace the stored encrypted private key after a passkey or PIN change

<RequestExample url="https://api.chipipay.com/v1/chipi-wallets/update-encryption-details" method="PATCH">
  ```bash cURL theme={null}
  curl -X PATCH "https://api.chipipay.com/v1/chipi-wallets/update-encryption-details" \
    -H "Authorization: Bearer sk_prod_xxxx" \
    -H "x-api-key: pk_xxxx" \
    -H "Content-Type: application/json" \
    -d '{
      "externalUserId": "user_123",
      "newEncryptedPrivateKey": "U2FsdGVkX1+newEncryptedKey..."
    }'
  ```

  ```typescript TypeScript theme={null}
  const response = await fetch(
    "https://api.chipipay.com/v1/chipi-wallets/update-encryption-details",
    {
      method: "PATCH",
      headers: {
        "Authorization": "Bearer sk_prod_xxxx",
        "x-api-key": "pk_xxxx",
        "Content-Type": "application/json"
      },
      body: JSON.stringify({
        externalUserId: "user_123",
        newEncryptedPrivateKey: "U2FsdGVkX1+newEncryptedKey..."
      })
    }
  );
  ```

  ```python Python theme={null}
  import requests

  response = requests.patch(
      "https://api.chipipay.com/v1/chipi-wallets/update-encryption-details",
      headers={
          "Authorization": "Bearer sk_prod_xxxx",
          "x-api-key": "pk_xxxx",
          "Content-Type": "application/json"
      },
      json={
          "externalUserId": "user_123",
          "newEncryptedPrivateKey": "U2FsdGVkX1+newEncryptedKey..."
      }
  )
  ```
</RequestExample>

<ResponseExample>
  ```json 200 Response theme={null}
  {
    "success": true
  }
  ```
</ResponseExample>

<Warning>
  After calling this endpoint, the previous passkey or PIN used to encrypt the
  private key will no longer work. Make sure the new encryption is persisted
  before discarding the old key material.
</Warning>


## OpenAPI

````yaml PATCH /chipi-wallets/update-encryption-details
openapi: 3.1.0
info:
  title: Chipi Pay API
  description: >-
    REST API for creating self-custodial wallets, executing gasless
    transactions, and purchasing services on Starknet.
  version: 14.0.0
  license:
    name: MIT
servers:
  - url: https://api.chipipay.com/v1
security:
  - bearerAuth: []
    apiKeyAuth: []
tags:
  - name: Wallets
    description: Create and manage self-custodial Starknet wallets
  - name: Transactions
    description: Record and query blockchain transactions
  - name: SKUs
    description: Browse available services for purchase
  - name: SKU Purchases
    description: Purchase services using blockchain payments
  - name: Exchanges
    description: Currency conversion rates
paths:
  /chipi-wallets/update-encryption-details:
    patch:
      tags:
        - Wallets
      summary: Update Wallet Encryption
      description: >-
        Replace the stored encrypted private key after the user changes their
        passkey or PIN. The old encryption key will no longer work after this
        call.
      operationId: updateWalletEncryption
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateWalletEncryptionBody'
      responses:
        '200':
          description: Encryption updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UpdateWalletEncryptionResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: Wallet not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  schemas:
    UpdateWalletEncryptionBody:
      type: object
      properties:
        externalUserId:
          type: string
          description: Your application's user identifier
        newEncryptedPrivateKey:
          type: string
          description: The private key re-encrypted with the new passkey or PIN
        publicKey:
          type: string
          description: Wallet public key (required when the user has multiple wallets)
      required:
        - externalUserId
        - newEncryptedPrivateKey
    UpdateWalletEncryptionResponse:
      type: object
      properties:
        success:
          type: boolean
          description: Whether the update succeeded
    Error:
      type: object
      properties:
        error:
          type: string
          description: Error code
        message:
          type: string
          description: Human-readable error message
      required:
        - error
        - message
  responses:
    BadRequest:
      description: Bad request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Unauthorized — invalid or missing API key / bearer token
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    RateLimited:
      description: Rate limit exceeded (100 requests/minute per API key)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Bearer token — use your secret key (sk_prod_xxx) for server-side calls,
        or the user's JWT for client-side calls
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: Your Chipi public API key (pk_xxx)

````