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

# Fund Agent

> Add float to an agent's account

<Info>
  Adds float balance to an agent's account. System admins can fund any agent. Super-agents can only fund their sub-agents.
</Info>

## Request

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

### Path Parameters

<ParamField path="id" type="string" required>
  Agent UUID to fund (e.g., `agent_abc123`)
</ParamField>

### Body Parameters

<ParamField body="amount" type="string" required>
  Amount to add (e.g., `500000.00` or `500000`)
</ParamField>

<ParamField body="description" type="string">
  Funding description/reference
</ParamField>

***

## Response

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

<ResponseField name="transaction_id" type="string">
  Funding transaction ID
</ResponseField>

<ResponseField name="new_balance" type="string">
  Agent's new float balance
</ResponseField>

***

## Examples

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://demo.api.vultlocal.com/api/v1/agents/agent_abc123/fund" \
    -H "Authorization: Bearer olive_live_xxx" \
    -H "Content-Type: application/json" \
    -d '{
      "amount": "500000.00",
      "description": "Weekly float top-up"
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 Success theme={null}
  {
    "success": true,
    "message": "Agent funded successfully",
    "transaction_id": "txn_fund_abc123",
    "amount": "500,000.00 SLE",
    "new_balance": "1,500,000.00 SLE",
    "funded_by": "admin@olive.sl"
  }
  ```

  ```json 403 Forbidden theme={null}
  {
    "error": "Not authorized to fund this agent",
    "code": "FORBIDDEN"
  }
  ```
</ResponseExample>

***

## Funding Sources

<CardGroup cols={2}>
  <Card title="OLIVE Admin" icon="building">
    System admin funds from OLIVE pool
  </Card>

  <Card title="Super-Agent" icon="crown">
    Super-agent transfers own float to sub-agent
  </Card>
</CardGroup>

***

## Permissions

| Funder Role  | Can Fund            |
| ------------ | ------------------- |
| System Admin | Any agent           |
| Super-Agent  | Own sub-agents only |
| Sub-Agent    | None                |

***

## Errors

| Status | Code                 | Description                          |
| ------ | -------------------- | ------------------------------------ |
| 400    | `INVALID_AMOUNT`     | Invalid amount format                |
| 401    | `UNAUTHORIZED`       | Invalid API key                      |
| 403    | `FORBIDDEN`          | Not authorized to fund               |
| 403    | `INSUFFICIENT_FLOAT` | Super-agent has insufficient balance |
| 404    | `NOT_FOUND`          | Agent not found                      |
| 500    | `INTERNAL_ERROR`     | Server error                         |


## OpenAPI

````yaml olive-openapi.json POST /agents/{id}/fund
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/{id}/fund:
    post:
      tags:
        - Agents
      summary: Fund agent account
      description: >-
        Add float to an agent's account. Admin can fund any agent. Super-agent
        can fund their sub-agents.
      parameters:
        - description: Agent ID
          name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/handler.FundAgentRequest'
        description: Fund amount
        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.FundAgentRequest:
      type: object
      required:
        - amount
      properties:
        amount:
          description: Accepts decimal format like "1289.00" or "1289"
          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

````