REST API

ทุกการทำงานในหน้าจอ Celerp คือ REST endpoint ตัวเดียวกับที่ UI เรียกใช้ภายใน คุณจึงนำไปทำงานอัตโนมัติ เชื่อมกับระบบอื่น หรือสร้างเครื่องมือของคุณเองได้ API ทำงานในเครื่องบนข้อมูลของคุณ ไม่มีอะไรถูกส่งขึ้นคลาวด์

🔗 URL ฐาน

http://localhost:8000 เมื่อติดตั้งด้วย pip ส่วนแอปเดสก์ท็อปจะเลือกพอร์ตเอง ดูที่ celerp-data/api-port

🔑 Auth

Bearer JWT จาก /auth/login

📦 รูปแบบ

รับ JSON คืน JSON

📖 Spec

GET /openapi.json (OpenAPI 3.1)

ต้องใช้พอร์ตไหน หากติดตั้งด้วย pip install celerp API server จะทำงานที่ localhost:8000 (เปลี่ยนได้ด้วย --api-port) ส่วนพอร์ต 8080 คือหน้าเว็บสำหรับคนใช้ ไม่ใช่ API ส่วนแอปเดสก์ท็อปจะเลือกพอร์ตที่ว่างทุกครั้งที่เปิด และบันทึกพอร์ตของ API ไว้ในไฟล์ api-port ในโฟลเดอร์ celerp-data หากต้องการกำหนดพอร์ตตายตัว ให้ตั้งค่า CELERP_API_PORT ก่อนเปิดแอป

การยืนยันตัวตน

Celerp ใช้ JSON Web Tokens ที่มีอายุสั้น เข้าสู่ระบบด้วยอีเมลและรหัสผ่าน Celerp เพื่อรับ access token จากนั้นส่งเป็น Bearer header ในทุกคำขอ

1. เข้าสู่ระบบ

curl -X POST http://localhost:8000/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email": "[email protected]", "password": "your-password"}'

การตอบกลับมีสอง token:

{
  "access_token": "eyJhbGciOiJI...",
  "refresh_token": "eyJhbGciOiJI..."
}

2. เรียก API ด้วย token

curl http://localhost:8000/items \
  -H "Authorization: Bearer eyJhbGciOiJI..."
  • Token ระบุผู้ใช้ บทบาท และบริษัท คำขอจึงถูกจำกัดขอบเขตไปยังบริษัทนั้นโดยอัตโนมัติ ไม่ต้องใช้ header เพิ่มเติม
  • Access token มีอายุสูงสุด 24 ชั่วโมง เมื่อหมดอายุ รับคู่ใหม่โดย POST refresh_token ไปที่ /auth/token/refresh
  • อยู่หลายบริษัทใช่ไหม ดูรายชื่อด้วย GET /auth/my-companies แล้วขอ token สำหรับอีกบริษัทด้วย POST /auth/switch-company/{company_id}

Token พกสิทธิ์ของคุณไปด้วย Token ระดับ viewer อ่านได้อย่างเดียว เขียนไม่ได้ ส่วนข้อมูลต้นทุนต้องมีบทบาท manager ขึ้นไป ให้ดูแล token เหมือนรหัสผ่าน เพราะใครถือไว้ก็ทำอะไรในนามคุณได้

การส่งคำขอ

ทุก endpoint อยู่ใต้ที่อยู่ของ API server ของคุณ (http://localhost:8000 สำหรับการติดตั้งด้วย pip ตามตัวอย่างด้านล่าง) และคืนค่าเป็น JSON โดย endpoint แบบรายการจะคืนอาร์เรย์ items พร้อมจำนวนรวม total:

curl "http://localhost:8000/items?limit=20&offset=0" \
  -H "Authorization: Bearer $TOKEN"
{
  "items": [
    { "id": "item:...", "sku": "WIDGET-001", "name": "Widget", "quantity": 42 }
  ],
  "total": 142
}

Pagination: ส่ง ?limit= (ค่าเริ่มต้น 50) และ ?offset= endpoint แบบรายการส่วนใหญ่ยังรับคำค้น q= และตัวกรองรายคอลัมน์ได้ด้วย (เช่น ?status=available)

การสร้างข้อมูล

POST JSON เพื่อสร้างระเบียน การเขียนคืนค่า id ของ entity ใหม่ (และ event_id ที่อยู่เบื้องหลัง ทุกการเปลี่ยนแปลงใน Celerp คือ event)

curl -X POST http://localhost:8000/crm/contacts \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Acme Corp",
    "email": "[email protected]",
    "contact_type": "customer",
    "idempotency_key": "acme-2026-06-21"
  }'

Idempotency: ใส่ idempotency_key ในทุกการเขียน คำขอซ้ำที่ใช้ key เดิมจะไม่สร้างรายการซ้ำ ปลอดภัยสำหรับเครือข่ายที่ไม่เสถียรและงาน batch

ข้อตกลง

  • ข้อผิดพลาด การตอบกลับที่ไม่ใช่ 2xx คืนค่า {"detail": "..."} พร้อม HTTP status code มาตรฐาน
  • Rate limit 60 คำขอ/นาทีต่อ IP โดยค่าเริ่มต้น การเข้าสู่ระบบจำกัดที่ 10/นาที การเกินขีดจำกัดคืนค่า 429
  • สิทธิ์ แต่ละ endpoint ถูกจำกัดตามบทบาทของคุณ: viewer → operator → manager → admin → owner
  • ขอบเขตบริษัท ทุกคำขอดำเนินการกับบริษัทใน token ของคุณ สลับบริษัทเพื่อดำเนินการกับบริษัทอื่น

Endpoints ทั่วไป

นี่เป็นเพียงส่วนเล็ก ๆ ไว้ให้เริ่มต้น แต่ละโมดูลจะเพิ่ม endpoint ของตัวเองเข้ามา ดูรายการทั้งหมดได้จาก OpenAPI schema ด้านล่าง

เมธอดพาธคำอธิบาย
POST/auth/loginรับ access token (ไม่ต้องยืนยันตัวตน)
GET/healthสถานะบริการ (ไม่ต้องยืนยันตัวตน)
GET/itemsดูรายการสินค้าคงคลัง
POST/itemsสร้างสินค้า
GET/docsดูรายการเอกสาร (ใบแจ้งหนี้ ใบสั่งซื้อ ใบวางบิล …)
POST/docsสร้างเอกสาร
GET/crm/contactsดูรายชื่อลูกค้าและซัพพลายเออร์
POST/crm/contactsสร้างผู้ติดต่อ
GET/dashboard/kpisKPI ทางธุรกิจ

เอกสารอ้างอิงฉบับเต็มแยกตามหมวด

endpoint ทั้งหมดที่ API ให้บริการ แบ่งตามหมวด แต่ละหน้าระบุเมธอด พาธ พารามิเตอร์ รูปแบบคำขอและคำตอบ และตัวอย่างการเรียกใช้

Auth

Authentication API for Celerp users, login, logout, password recovery, company switching, and API access. (13 endpoints)

Companies

Company settings and administration API for users, roles, locations, taxes, payment terms, price lists, modules, and company preferences. (70 endpoints)

Items

Inventory API for products and stock items, quantities, pricing, locations, barcodes, valuation, imports, reservations, transfers, transformations, and stock status. (39 endpoints)

Docs

Business document API for invoices, bills, purchase orders, quotations, credit notes, shipping documents, payments, fulfillment, PDF output, and document lifecycle operations. (52 endpoints)

Lists

Inventory list API for stock audits, transfers, write-offs, manifests, scans, reservations, notes, exports, and list lifecycle operations. (38 endpoints)

Accounting

Celerp accounting REST API for the chart of accounts, journal entries, general ledger, bank reconciliation, financial statements, transfers, and fiscal period controls. (59 endpoints)

Ledger

Event ledger API for reading Celerp business events and rebuilding derived application data. (3 endpoints)

Reports

ERP reporting API for accounts receivable and payable aging, sales, purchases, and expiring inventory. (5 endpoints)

Manufacturing

Manufacturing API for production orders, recipes, work centers, workflows, material requirements, costing, scheduling, component issue, and finished-goods receipt. (32 endpoints)

Labels

Inventory label and barcode API for label templates, single-item labels, bulk label sheets, and printable PDFs. (7 endpoints)

Crm

CRM REST API for customers, suppliers, contacts, addresses, people, notes, tags, files, imports, exports, and contact management. (25 endpoints)

Subscriptions

Recurring document and subscription API for invoice and purchase-order templates, scheduling, activation, pausing, resuming, cancellation, and on-demand generation. (6 endpoints)

Connectors

Integration API for connecting Celerp ERP to external commerce and business platforms, managing connector credentials, and running data synchronization. (9 endpoints)

Payments

Payment integration API for connecting payment processing, checking payment availability, and reading connection status. (7 endpoints)

Backup

Backup and restore API for exporting, importing, listing, creating, and restoring Celerp ERP backups. (8 endpoints)

Notifications

User notification API for listing notifications and marking individual or all notifications as read. (3 endpoints)

Events

Real-time server-sent events API for Celerp notifications and live application events. (1 endpoint)

System

System health, readiness, restart, and factory reset endpoints for a Celerp ERP installation. (10 endpoints)

Admin

Administrative diagnostics and system status endpoints for maintaining a Celerp ERP installation. (2 endpoints)

Ai

Celerp AI API for ERP assistant conversations, document extraction, batch jobs, memory, usage, and user-confirmed business actions. (22 endpoints)

Attachments

Inventory attachment API for uploading, downloading, tagging, previewing, and deleting item files and product images. (12 endpoints)

Dashboard

Dashboard API for ERP KPIs, recent business activity, and searchable activity history. (3 endpoints)

Payments Public

Public payment endpoints for customer payment links and payment-provider return handling. (2 endpoints)

Received

Received documents API for documents other Celerp users shared with you: list and review them, book one as your own draft, and bring a booked draft up to date with the sender's latest revision. (5 endpoints)

Search

Global Celerp ERP search API for finding permitted records across modules from a single query. (1 endpoint)

Settings

System settings and Celerp Connect API for account setup, cloud connection state, billing, backups, connectors, and partner configuration. (17 endpoints)

Share

Document sharing API for creating, inspecting, updating, and revoking public share links for Celerp documents and lists. (4 endpoints)

Share Public

Public document sharing and import endpoints for viewing shared Celerp documents and downloading or importing portable document bundles. (4 endpoints)

Stars

Supporter badge and Celerp community recognition API for badge verification, display, opt-out, and prompts. (6 endpoints)

Verticals

Industry preset and category schema API for configuring Celerp ERP fields and defaults by business vertical. (5 endpoints)

Company Backups

16 endpoints

Migrations

22 endpoints

สำรวจ API ทั้งหมด

เอกสารอ้างอิงฉบับสมบูรณ์ที่อัปเดตอยู่เสมอ คือ OpenAPI 3.1 schema ที่ instance ของคุณสร้างขึ้นเอง:

GET http://localhost:8000/openapi.json

โหลดเข้าเครื่องมือ OpenAPI ตัวไหนก็ได้ ไม่ว่าจะเป็น Postman, Insomnia, Swagger UI หรือตัวสร้าง client เพื่อไล่ดูทุก endpoint และ model ทดลองยิงคำขอ และสร้าง typed client ในภาษาที่คุณใช้ Celerp ให้ตัว schema มาตรง ๆ แทนที่จะทำหน้าเอกสารออนไลน์ หน้าตา API ของคุณจึงอยู่กับ instance ของคุณเท่านั้น

อยากสั่งด้วยภาษาคนมากกว่า ผู้ช่วย AI (Connect) เรียก API ชุดเดียวกันนี้ให้คุณ สั่งให้ดึงรายงานหรือสร้างเอกสารด้วยภาษาธรรมชาติได้เลย และจำไว้ว่าทุกอย่างที่ API ทำได้ ทำด้วยสิทธิ์เท่ากับผู้ใช้ที่ลงชื่อเข้าใช้ ไม่มีสิทธิ์พิเศษเพิ่ม