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

# API Keys

> Create and manage API keys

<Info>
  Generate API keys for integrations. Only system administrators can create API keys.
</Info>

## Request

<ParamField header="Authorization" type="string" required>
  `Bearer <token>` - System Admin JWT
</ParamField>

### Body Parameters

<ParamField body="name" type="string" required>
  Friendly name for the API key
</ParamField>

<ParamField body="scopes" type="array">
  Permission scopes for the key (e.g., `["payments:read", "balance:read"]`)
</ParamField>

<ParamField body="expires_at" type="string">
  Expiration date (ISO 8601). Leave empty for no expiration.
</ParamField>

***

## Response

<ResponseField name="api_key" type="string">
  The generated API key (shown only once)
</ResponseField>

<ResponseField name="name" type="string">
  Key name
</ResponseField>

<ResponseField name="scopes" type="array">
  Assigned permission scopes
</ResponseField>

<ResponseField name="created_at" type="string">
  Creation timestamp
</ResponseField>

<ResponseField name="expires_at" type="string">
  Expiration timestamp (if set)
</ResponseField>

***

## Examples

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://demo.api.vultlocal.com/api/v1/admin/api-keys" \
    -H "Authorization: Bearer ADMIN_JWT" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Partner Integration",
      "scopes": ["payments:read", "balance:read"],
      "expires_at": "2026-01-01T00:00:00Z"
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 201 Created theme={null}
  {
    "api_key": "olive_live_xxxxxxxxxxxxx",
    "name": "Partner Integration",
    "scopes": ["payments:read", "balance:read"],
    "created_at": "2025-01-15T10:00:00Z",
    "expires_at": "2026-01-01T00:00:00Z"
  }
  ```

  ```json 403 Forbidden theme={null}
  {
    "success": false,
    "error": "Not authorized to create API keys",
    "code": "FORBIDDEN"
  }
  ```
</ResponseExample>

***

## Available Scopes

| Scope               | Description          |
| ------------------- | -------------------- |
| `payments:read`     | Read payment data    |
| `payments:write`    | Create payments      |
| `balance:read`      | Read wallet balances |
| `subscribers:read`  | Read subscriber data |
| `subscribers:write` | Modify subscribers   |
| `compliance:read`   | Read compliance data |
| `admin:full`        | Full admin access    |

***

## Security

<Warning>
  The API key is only shown once at creation. Store it securely immediately.

  * API keys should be rotated periodically
  * Use the minimum required scopes
  * Set expiration dates for temporary integrations
</Warning>

***

## Errors

| Status | Code              | Description                       |
| ------ | ----------------- | --------------------------------- |
| 400    | `INVALID_REQUEST` | Invalid request format            |
| 403    | `FORBIDDEN`       | Not authorized to create API keys |
| 500    | `INTERNAL_ERROR`  | Server error                      |


## OpenAPI

````yaml olive-openapi.json POST /api-keys
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:
  /api-keys:
    post:
      tags:
        - API Keys
      summary: Create a new API key
      description: Create a new API key for third-party integration
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/handler.CreateAPIKeyRequest'
        description: API key details
        required: true
      responses:
        '201':
          description: API key created
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '500':
          description: Internal error
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
      security:
        - ApiKeyAuth: []
components:
  schemas:
    handler.CreateAPIKeyRequest:
      type: object
      required:
        - name
        - scopes
      properties:
        description:
          type: string
        expires_in_days:
          type: integer
        integration_type:
          description: whatsapp, smart_pay, vult, agent_app
          type: string
        ip_whitelist:
          type: array
          items:
            type: string
        name:
          type: string
        rate_limit:
          type: integer
        scopes:
          type: array
          minItems: 1
          items:
            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

````