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

# Agent Cash-In

> Credit subscriber wallet through agent

<Info>
  Agent cash-in allows field agents to deposit cash into subscriber wallets. The agent's float balance is debited, and the subscriber is credited.
</Info>

## Endpoint

```http theme={null}
POST /api/v1/agents/cashin
```

## Authentication

<ParamField header="Authorization" type="string" required>
  Bearer token (API key or Agent JWT)
</ParamField>

***

## Request Body

<ParamField body="agent_id" type="string" required>
  UUID of the agent performing cash-in
</ParamField>

<ParamField body="subscriber_id" type="string" required>
  UUID of subscriber receiving funds
</ParamField>

<ParamField body="card_serial" type="string">
  Card serial number (alternative to subscriber\_id)
</ParamField>

<ParamField body="amount" type="string" required>
  Amount in SLE (e.g., `50.00` or `50`)
</ParamField>

<ParamField body="agent_pin" type="string" required>
  Agent's 4-digit PIN for authentication
</ParamField>

***

## Transaction Flow

<Steps>
  <Step title="Validation">
    Agent PIN verified, subscriber looked up by ID or card serial
  </Step>

  <Step title="Compliance Check">
    Transaction checked against daily limits and fraud rules
  </Step>

  <Step title="Fee Calculation">
    Agent fee calculated based on fee settings
  </Step>

  <Step title="Balance Updates">
    Agent debited, subscriber credited atomically
  </Step>

  <Step title="Notifications">
    WhatsApp notification sent to subscriber
  </Step>
</Steps>

***

## Example

<Tabs>
  <Tab title="Request">
    ```bash theme={null}
    curl -X POST "https://demo.api.vultlocal.com/api/v1/agents/cashin" \
      -H "Authorization: Bearer olive_live_xxx" \
      -H "Content-Type: application/json" \
      -d '{
        "agent_id": "agent_abc123",
        "subscriber_id": "sub_xyz789",
        "amount": "50.00",
        "agent_pin": "1234"
      }'
    ```
  </Tab>

  <Tab title="Response">
    ```json theme={null}
    {
      "success": true,
      "message": "Cash-in successful",
      "transaction_id": "txn_cashin_abc123",
      "amount": "50.00 SLE",
      "agent_balance": "450,000.00 SLE",
      "subscriber_balance": "75,000.00 SLE",
      "commission_earned": "0.25 SLE"
    }
    ```
  </Tab>

  <Tab title="By Card Serial">
    ```bash theme={null}
    curl -X POST "https://demo.api.vultlocal.com/api/v1/agents/cashin" \
      -H "Authorization: Bearer olive_live_xxx" \
      -H "Content-Type: application/json" \
      -d '{
        "agent_id": "agent_abc123",
        "card_serial": "OLIV0001",
        "amount": "100.00",
        "agent_pin": "1234"
      }'
    ```
  </Tab>
</Tabs>

***

## Errors

| Code | Error                  | Description                   |
| ---- | ---------------------- | ----------------------------- |
| 400  | `INVALID_AMOUNT`       | Amount format incorrect       |
| 400  | `INVALID_PIN`          | Agent PIN is wrong            |
| 400  | `INSUFFICIENT_FLOAT`   | Agent float balance too low   |
| 404  | `SUBSCRIBER_NOT_FOUND` | Subscriber/card not found     |
| 403  | `SUBSCRIBER_BLOCKED`   | Subscriber account is blocked |
| 403  | `COMPLIANCE_REJECTED`  | Transaction exceeds limits    |

***

## Related

<CardGroup cols={2}>
  <Card title="Agent Balance" icon="wallet" href="/api-reference/agents/balance">
    Check agent float balance before cash-in
  </Card>

  <Card title="Fund Agent" icon="plus" href="/api-reference/agents/fund">
    Add float to agent account
  </Card>
</CardGroup>


## OpenAPI

````yaml olive-openapi.json POST /agents/cashin
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:
  /agents/cashin:
    post:
      tags:
        - Agents
      summary: Agent cash-in transaction
      description: >-
        Process cash-in transaction from agent to subscriber. Agent
        authenticates with their own PIN, not subscriber's PIN.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/handler.AgentCashInRequest'
        description: Cash-in details
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
      security:
        - ApiKeyAuth: []
        - ApiKeyAuth: []
        - BearerAuth: []
components:
  schemas:
    handler.AgentCashInRequest:
      type: object
      required:
        - agent_id
        - agent_pin
        - amount
        - subscriber_id
      properties:
        agent_id:
          type: string
        agent_pin:
          description: Agent's PIN for authentication
          type: string
        amount:
          description: Accepts decimal format like "50.00" or "50"
          type: string
        card_serial:
          type: string
        subscriber_id:
          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

````