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

# Change PIN

> Change subscriber's 4-digit PIN

<Warning>
  Changing PIN requires verification of the current PIN first.
</Warning>

## Request

<ParamField header="Authorization" type="string" required>
  `Bearer olive_live_xxx` or `Bearer eyJ...` (JWT)
</ParamField>

### Path Parameters

<ParamField path="id" type="string" required>
  Subscriber UUID (e.g., `sub_abc123`)
</ParamField>

### Body Parameters

<ParamField body="current_pin" type="string" required>
  Current 4-digit PIN
</ParamField>

<ParamField body="new_pin" type="string" required>
  New 4-digit PIN
</ParamField>

***

## Response

<ResponseField name="success" type="boolean">
  Whether change succeeded
</ResponseField>

<ResponseField name="message" type="string">
  Result message
</ResponseField>

***

## Examples

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://demo.api.vultlocal.com/api/v1/subscribers/sub_abc123/change-pin" \
    -H "Authorization: Bearer olive_live_xxx" \
    -H "Content-Type: application/json" \
    -d '{
      "current_pin": "1234",
      "new_pin": "5678"
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 Success theme={null}
  {
    "success": true,
    "message": "PIN changed successfully"
  }
  ```

  ```json 401 Wrong PIN theme={null}
  {
    "success": false,
    "message": "Current PIN is incorrect",
    "attempts_remaining": 2
  }
  ```

  ```json 400 Invalid New PIN theme={null}
  {
    "success": false,
    "message": "New PIN must be 4 digits",
    "code": "INVALID_PIN_FORMAT"
  }
  ```
</ResponseExample>

***

## PIN Rules

<CardGroup cols={2}>
  <Card title="Format" icon="hash">
    * Exactly 4 digits
    * Numbers only (0-9)
    * No spaces or special characters
  </Card>

  <Card title="Security" icon="shield-check">
    * Cannot be same as current PIN
    * Sequential patterns discouraged
    * Simple patterns (1111) warned
  </Card>
</CardGroup>

***

## Validation

| Rule            | Invalid Example | Reason            |
| --------------- | --------------- | ----------------- |
| Length          | `123`           | Must be 4 digits  |
| Numeric         | `12ab`          | Numbers only      |
| Same as current | `1234` → `1234` | Must be different |

***

## Notifications

<Info>
  A WhatsApp notification is sent to the subscriber when their PIN is changed.
</Info>

***

## Errors

| Status | Code                 | Description                |
| ------ | -------------------- | -------------------------- |
| 400    | `INVALID_PIN_FORMAT` | PIN must be 4 digits       |
| 400    | `SAME_PIN`           | New PIN same as current    |
| 401    | `UNAUTHORIZED`       | Invalid or missing API key |
| 401    | `WRONG_CURRENT_PIN`  | Current PIN incorrect      |
| 403    | `ACCOUNT_LOCKED`     | Too many failed attempts   |
| 404    | `NOT_FOUND`          | Subscriber not found       |
| 500    | `INTERNAL_ERROR`     | Server error               |

***

## Related

<Card title="Verify PIN" icon="lock-keyhole" href="/api-reference/subscribers/verify-pin">
  Verify a PIN without changing it
</Card>


## OpenAPI

````yaml olive-openapi.json POST /subscribers/{id}/change-pin
openapi: 3.0.0
info:
  description: >-
    API Gateway for OLIVE NFC Card Payment System - Comprehensive payment, card
    management, agent operations, and admin authentication. All /api/v1 routes
    require authentication using either API Key or JWT token.
  title: OLIVE NFC Card Payment API
  termsOfService: http://swagger.io/terms/
  contact:
    name: API Support
    email: support@olive.sl
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
  version: 1.0.0
servers:
  - url: https://olive-gateway-a6ba.onrender.com/api/v1
security: []
paths:
  /subscribers/{id}/change-pin:
    post:
      tags:
        - Subscribers
      summary: Change subscriber PIN
      description: Change a subscriber's 4-digit PIN
      parameters:
        - description: Subscriber ID
          name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/handler.ChangeSubscriberPINRequest'
        description: PIN change details
        required: true
      responses:
        '200':
          description: PIN changed successfully
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '400':
          description: Invalid request or PIN
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '404':
          description: Subscriber not found
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
      security:
        - ApiKeyAuth: []
        - BearerAuth: []
components:
  schemas:
    handler.ChangeSubscriberPINRequest:
      type: object
      required:
        - new_pin
        - old_pin
      properties:
        new_pin:
          type: string
        old_pin:
          type: string
  securitySchemes:
    ApiKeyAuth:
      description: >-
        API Key for third-party integrations (WhatsApp, Smart PAY, VULT).
        Format: 'Bearer olive_live_xxxxxxxxxxxxx'
      type: apiKey
      name: Authorization
      in: header
    BearerAuth:
      description: >-
        JWT token from admin login for administrative operations. Format:
        'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
      type: apiKey
      name: Authorization
      in: header

````