AI API Reference

Pełna dokumentacja REST API dla integracji z MideroERP. Wszystkie endpointy zwracają JSON.

🔑 Autentykacja

Użyj Bearer token w nagłówku Authorization lub parametru ?token=YOUR_TOKEN

# Bearer Token curl -H "Authorization: Bearer YOUR_API_TOKEN" \ https://erp.example.com/api/ai/overview # Query parameter curl https://erp.example.com/api/ai/overview?token=YOUR_API_TOKEN

Base URL

https://your-domain.com/api/ai

📋 Endpointy

GET

/overview

Przegląd systemu — KPI firmy, statystyki modułów, ostatnia aktywność.

curl "https://erp.example.com/api/ai/overview?token=YOUR_TOKEN"
{ "company": { "name": "MIDERO S.A.", "employees": 38 }, "kpi": { "revenue_ytd": 2450000, "costs_ytd": 1230000, "invoices_unpaid": 12, "projects_active": 8, "tasks_open": 45 }, "modules": ["crm", "hrm", "finance", "iso"] }
GET

/dashboard

Dane dashboardu — wykresy, alerty, zadania na dziś.

curl "https://erp.example.com/api/ai/dashboard?token=YOUR_TOKEN"
GET

/finance

Podsumowanie finansowe — przychody, koszty, zaległe faktury, cashflow.

curl "https://erp.example.com/api/ai/finance?token=YOUR_TOKEN&year=2026"

Parametry: year (opcjonalny, default: bieżący rok)

GET

/hr

Podsumowanie HR — pracownicy, urlopy, rekrutacja, szkolenia.

curl "https://erp.example.com/api/ai/hr?token=YOUR_TOKEN"
GET

/iso

Status ISO compliance — audyty, ryzyka, dokumenty, CAPA, incydenty.

curl "https://erp.example.com/api/ai/iso?token=YOUR_TOKEN"
GET

/crm

Podsumowanie CRM — pipeline, leady, firmy, kontakty.

curl "https://erp.example.com/api/ai/crm?token=YOUR_TOKEN"
GET

/query

Zapytanie o konkretny moduł — lista rekordów z paginacją.

curl "https://erp.example.com/api/ai/query?module=leads&status=WON&token=YOUR_TOKEN"

Parametry: module (wymagany), status, limit, offset

GET

/record/{module}/{id}

Szczegóły jednego rekordu z relacjami.

curl "https://erp.example.com/api/ai/record/leads/UUID?token=YOUR_TOKEN"
GET

/schema

Schema bazy danych — tabele, kolumny, typy. Przydatne dla AI do generowania zapytań.

curl "https://erp.example.com/api/ai/schema?token=YOUR_TOKEN"
GET

/docs

Auto-generowana dokumentacja endpointów (ta strona w JSON).

curl "https://erp.example.com/api/ai/docs?token=YOUR_TOKEN"
POST

/create/{module}

Utwórz nowy rekord w module. Pola zależą od modułu (użyj /schema aby poznać).

curl -X POST "https://erp.example.com/api/ai/create/leads?token=YOUR_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "title": "Nowy lead z API", "company_name": "Firma ABC", "contact_name": "Jan Kowalski", "value": 50000, "stage": "NEW" }'
// Response 201 { "success": true, "id": "550e8400-e29b-41d4-a716-446655440000", "message": "Record created" }
PUT

/update/{module}/{id}

Zaktualizuj istniejący rekord. Wysyłaj tylko pola do zmiany.

curl -X PUT "https://erp.example.com/api/ai/update/leads/UUID?token=YOUR_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "stage": "NEGOTIATION", "value": 75000 }'
POST

/status

Szybka zmiana statusu rekordu (shortcut dla update).

curl -X POST "https://erp.example.com/api/ai/status?token=YOUR_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "module": "tasks", "id": "UUID", "status": "DONE" }'
POST

/note

Dodaj notatkę/komentarz do rekordu.

curl -X POST "https://erp.example.com/api/ai/note?token=YOUR_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "module": "leads", "record_id": "UUID", "content": "Klient zainteresowany ofertą enterprise" }'

📦 Dostępne moduły

companies contacts leads projects tasks tickets proposals contracts meetings employees leaves candidates invoices transactions budgets expenses documents risks audits wiki announcements objectives trainings benefits reviews time_entries

⚡ Rate Limits