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

# Refresh Token

> Refresh access token using refresh token

<Info>
  Issue a new access token using a valid refresh token. Implements token rotation for security.
</Info>

## Request

<ParamField body="refresh_token" type="string" required>
  Valid refresh token from login
</ParamField>

***

## Response

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

<ResponseField name="token" type="string">
  New JWT access token
</ResponseField>

<ResponseField name="refresh_token" type="string">
  New refresh token (old one is revoked)
</ResponseField>

<ResponseField name="expires_at" type="integer">
  Access token expiration timestamp
</ResponseField>

<ResponseField name="refresh_expires_at" type="integer">
  Refresh token expiration timestamp
</ResponseField>

<ResponseField name="user" type="object">
  User details object
</ResponseField>

***

## Examples

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://demo.api.vultlocal.com/api/v1/admin/refresh" \
    -H "Content-Type: application/json" \
    -d '{
      "refresh_token": "rt_abc123xyz..."
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 Success theme={null}
  {
    "success": true,
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "refresh_token": "new_refresh_token_string",
    "expires_at": 1704110400,
    "refresh_expires_at": 1704714400,
    "user": {
      "id": "123",
      "email": "admin@olive.sl",
      "first_name": "Admin",
      "last_name": "User",
      "role": "system_admin",
      "status": "active"
    }
  }
  ```

  ```json 401 Invalid Token theme={null}
  {
    "success": false,
    "error": "Invalid or expired refresh token",
    "code": "INVALID_TOKEN"
  }
  ```
</ResponseExample>

***

## Token Rotation

<Warning>
  For security, a new refresh token is issued on every refresh:

  1. Old refresh token is revoked immediately
  2. New refresh token is stored
  3. Both new tokens are returned
</Warning>

***

## Errors

| Status | Code              | Description                      |
| ------ | ----------------- | -------------------------------- |
| 400    | `INVALID_REQUEST` | Invalid request format           |
| 401    | `INVALID_TOKEN`   | Invalid or expired refresh token |
| 500    | `INTERNAL_ERROR`  | Server error                     |


## OpenAPI

````yaml olive-openapi.json POST /admin/refresh
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:
  /admin/refresh:
    post:
      tags:
        - Admin
      summary: Refresh access token
      description: Issues a new access token using a valid refresh token
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/handler.RefreshTokenRequest'
        description: Refresh token
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/handler.LoginResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
                additionalProperties:
                  type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                additionalProperties:
                  type: string
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                type: object
                additionalProperties:
                  type: string
components:
  schemas:
    handler.RefreshTokenRequest:
      type: object
      required:
        - refresh_token
      properties:
        refresh_token:
          type: string
    handler.LoginResponse:
      type: object
      properties:
        expires_at:
          type: integer
        refresh_expires_at:
          type: integer
        refresh_token:
          type: string
        success:
          type: boolean
        token:
          type: string
        user:
          $ref: '#/components/schemas/handler.UserInfo'
    handler.UserInfo:
      type: object
      properties:
        account_id:
          description: For processors
          type: string
        agent_id:
          type: string
        created_at:
          type: string
        email:
          type: string
        first_name:
          type: string
        id:
          type: string
        last_login_at:
          type: string
        last_name:
          type: string
        name:
          description: For processors
          type: string
        pep_access_authorized:
          type: boolean
        phone_number:
          type: string
        role:
          type: string
        status:
          type: string
        user_type:
          description: '"admin" or "processor"'
          type: string

````