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

# Create User

> Create a new system user

<Info>
  Create a new admin/system user with specified role. Only system administrators can create users.
</Info>

## Request

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

### Body Parameters

<ParamField body="email" type="string" required>
  Email address for login
</ParamField>

<ParamField body="password" type="string" required>
  Password (min 8 chars, uppercase, lowercase, number, special char)
</ParamField>

<ParamField body="first_name" type="string" required>
  First name
</ParamField>

<ParamField body="last_name" type="string" required>
  Last name
</ParamField>

<ParamField body="phone_number" type="string">
  Phone number for notifications
</ParamField>

<ParamField body="role" type="string" required>
  User role (see valid roles below)
</ParamField>

<ParamField body="pep_access_authorized" type="boolean">
  Grant access to PEP accounts
</ParamField>

***

## Valid Roles

| Role              | Description            |
| ----------------- | ---------------------- |
| `system_admin`    | Full system access     |
| `compliance_user` | Compliance monitoring  |
| `support_user`    | Customer support       |
| `sales_user`      | Sales operations       |
| `audit_user`      | Audit/reporting access |
| `super_agent`     | Agent network manager  |
| `sub_agent`       | Field agent            |

***

## Response

<ResponseField name="success" type="boolean">
  Whether user was created
</ResponseField>

<ResponseField name="user_id" type="string">
  New user ID
</ResponseField>

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

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

***

## Examples

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://demo.api.vultlocal.com/api/v1/admin/users" \
    -H "Authorization: Bearer ADMIN_JWT" \
    -H "Content-Type: application/json" \
    -d '{
      "email": "newuser@olive.sl",
      "password": "SecureP@ss123",
      "first_name": "New",
      "last_name": "User",
      "phone_number": "+23277123456",
      "role": "support_user",
      "pep_access_authorized": false
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 201 Created theme={null}
  {
    "success": true,
    "user_id": "123",
    "message": "User created successfully",
    "user": {
      "id": "123",
      "email": "newuser@olive.sl",
      "first_name": "New",
      "last_name": "User",
      "role": "support_user",
      "status": "active"
    }
  }
  ```

  ```json 409 Conflict theme={null}
  {
    "success": false,
    "error": "User with email already exists",
    "code": "USER_EXISTS"
  }
  ```
</ResponseExample>

***

## Notes

<Warning>
  * Credentials are sent via WhatsApp if phone\_number is provided
  * Password must meet security requirements
  * Only `system_admin` role can create new users
</Warning>

***

## Errors

| Status | Code              | Description                      |
| ------ | ----------------- | -------------------------------- |
| 400    | `INVALID_REQUEST` | Invalid request or weak password |
| 403    | `FORBIDDEN`       | Not authorized to create users   |
| 409    | `USER_EXISTS`     | User with email already exists   |


## OpenAPI

````yaml olive-openapi.json POST /admin/users
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/users:
    post:
      tags:
        - Admin
      summary: Create a new system user
      description: >-
        Allows system admin to create new users with roles (admin, sales, agent,
        etc.)
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/handler.CreateUserRequest'
        description: User details
        required: true
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/handler.CreateUserResponse'
        '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
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                type: object
                additionalProperties:
                  type: string
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                type: object
                additionalProperties:
                  type: string
      security:
        - ApiKeyAuth: []
components:
  schemas:
    handler.CreateUserRequest:
      type: object
      required:
        - email
        - first_name
        - last_name
        - password
        - role
      properties:
        email:
          type: string
        first_name:
          type: string
        last_name:
          type: string
        password:
          type: string
        pep_access_authorized:
          type: boolean
        phone_number:
          type: string
        role:
          type: string
    handler.CreateUserResponse:
      type: object
      properties:
        message:
          type: string
        success:
          type: boolean
        user:
          $ref: '#/components/schemas/handler.UserInfo'
        user_id:
          type: string
    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
  securitySchemes:
    ApiKeyAuth:
      description: >-
        API Key for third-party integrations (WhatsApp, Smart PAY, VULT).
        Format: 'Bearer olive_live_xxxxxxxxxxxxx'
      type: apiKey
      name: Authorization
      in: header

````