# Contrato — Bridge FOSS ↔ OpenPanel (Ligbox v2)

**Base URL:** `http://10.10.10.123:18087`  
**Auth:** Bearer token (obtido via POST `/api` com credenciais OpenAdmin)

## POST /api — login

**Request:**
```json
{"username": "ligboxadmin", "password": "LbOpen805353"}
```

**Response 200:**
```json
{"access_token": "ligbox-community-bridge-token"}
```

## POST /api/users — provisionar

**Headers:** `Authorization: Bearer <token>`

**Request:**
```json
{
  "username": "string [a-z][a-z0-9]{2,15}",
  "password": "string",
  "email": "string",
  "plan_name": "ligbox-site-cms",
  "domain": "string (opcional mas recomendado)"
}
```

**Response 200:**
```json
{
  "success": true,
  "response": {
    "message": "Successfully added user ...\nDomain ... added successfully",
    "username": "cliente1",
    "domain": "cliente1.com"
  }
}
```

## Compatibilidade FOSSBilling OpenPanel.php

O módulo oficial envia `username`, `password`, `email`, `plan_name`.  
Patch Ligbox adiciona `domain` via `$account->getDomain()`.

FOSS considera sucesso se `success: true` OU mensagem contém `Successfully added user`.

## SLA operacional

- Timeout recomendado: **180s** por request (provisionamento Docker)
- Retry: não automático — idempotência parcial (user exists → erro)
