功能定价关于文章文档
开发者

API、SDK、MCP 和 webhook。

开发者平台快速开始身份验证API 参考SDKMCPWebhook错误分页速率限制幂等性更新日志迁移与版本控制策略
原始 API 文档OpenAPI YAMLAsyncAPI YAML
  1. 首页
  2. /
  3. 开发者
  4. /
  5. API 参考

API 参考

FabHub 公共 API 的完整参考。品牌化门户为权威来源;你也可以将机器可读的契约载入任意 OpenAPI 查看器(Swagger Editor、Redoc、Postman 或你的 IDE)。

  • OpenAPI JSON - OpenAPI YAML

基础 URL

https://api.fabhub.app/v1

约定

  • 使用 X-API-Key(或 Authorization: Bearer)进行身份验证。参见身份验证。
  • 请求主体为带 camelCase 键名的 JSON;列表过滤器为 snake_case 查询参数。
  • 列表端点为基于页码的分页,并返回 pagination 对象;参见分页。
  • 写端点需要 Idempotency-Key 标头;参见幂等性。
  • 错误使用带机器可读 code 的稳定信封;参见错误。

所有端点

此表由 OpenAPI 契约生成,始终列出每个公共操作及其所需作用域。下方各小节为最常见资源的实战示例;OpenAPI 契约是请求与响应 schema 的详尽来源。

方法路径作用域
GET/v1authenticated
GET/v1/audit/eventsaudit:read
GET/v1/auth/contextauthenticated
GET/v1/contactscontacts:read
POST/v1/contactscontacts:write
DELETE/v1/contacts/{contact_id}contacts:write
GET/v1/contacts/{contact_id}contacts:read
PATCH/v1/contacts/{contact_id}contacts:write
GET/v1/itemsitems:read
POST/v1/itemsitems:write
DELETE/v1/items/{item_id}items:write
GET/v1/items/{item_id}items:read
PATCH/v1/items/{item_id}items:write
GET/v1/items/{item_id}/ingredientsitems:read
POST/v1/items/{item_id}/ingredientsitems:write
DELETE/v1/items/{item_id}/ingredients/{ingredient_id}items:write
PATCH/v1/items/{item_id}/ingredients/{ingredient_id}items:write
GET/v1/items/{item_id}/suppliersitems:read
POST/v1/items/{item_id}/suppliersitems:write
DELETE/v1/items/{item_id}/suppliers/{supplier_id}items:write
PATCH/v1/items/{item_id}/suppliers/{supplier_id}items:write
GET/v1/ordersorders:read
POST/v1/ordersorders:write
GET/v1/orders/{order_id}orders:read
PATCH/v1/orders/{order_id}orders:write
GET/v1/orders/{order_id}/linesorders:read
GET/v1/organizationorganization:read
GET/v1/stock-documentsinventory:read
POST/v1/stock-documentsinventory:write
DELETE/v1/stock-documents/{document_id}inventory:write
GET/v1/stock-documents/{document_id}inventory:read
PATCH/v1/stock-documents/{document_id}inventory:write
POST/v1/stock-documents/{document_id}/approveinventory:write
POST/v1/stock-documents/{document_id}/cancelinventory:write
GET/v1/stock-documents/{document_id}/linesinventory:read
POST/v1/stock-documents/{document_id}/linesinventory:write
DELETE/v1/stock-documents/{document_id}/lines/{line_id}inventory:write
PATCH/v1/stock-documents/{document_id}/lines/{line_id}inventory:write
POST/v1/stock-documents/{document_id}/submitinventory:write
GET/v1/stock-levelsinventory:read
GET/v1/usageusage:read
GET/v1/webhookswebhooks:read
POST/v1/webhookswebhooks:write
DELETE/v1/webhooks/{webhook_id}webhooks:delete
GET/v1/webhooks/{webhook_id}webhooks:read
PATCH/v1/webhooks/{webhook_id}webhooks:write
GET/v1/webhooks/{webhook_id}/deliverieswebhooks:deliveries:read

服务

GET /v1

返回调用凭据可使用的能力(方法、路径、作用域)。无需作用域。

GET /v1/auth/context

返回调用凭据的租户、套餐、作用域、速率限制层级及过期时间。无需作用域。参见快速上手中的示例。


物料

GET /v1/items

作用域:items:read。列出物料(产品、材料、组合品)。

查询类型说明
pageinteger从 1 开始的页码(默认 1)
page_sizeinteger每页物料数(默认 20)
searchstring对名称/SKU 的自由文本匹配
curl "https://api.fabhub.app/v1/items?page=1&page_size=2&search=widget" \
  -H "X-API-Key: $FABHUB_API_KEY"
{
  "data": [
    {
      "id": "a1c9...",
      "name": "Blue Widget",
      "sku": "WIDG-BLUE",
      "itemType": "product",
      "salePrice": 19.99,
      "purchasePrice": 8.5,
      "isActive": true,
      "category": { "id": "cat_1", "name": "Widgets" },
      "supplier": { "id": "sup_1", "name": "Acme", "company": "Acme Ltd" },
      "updatedAt": "2026-06-19T14:02:00Z"
    }
  ],
  "pagination": { "page": 1, "pageSize": 2, "total": 57, "totalPages": 29 }
}

POST /v1/items

作用域:items:write。需要 Idempotency-Key。创建一个物料。

主体字段类型说明
namestring必填
itemTypeproduct | material | combo默认为 product
sku、mpn、barcodestring | null可选标识符
categoryId、unitId、supplierIdstring | null可选引用
salePrice、purchasePricenumber | null可选定价
supplierCode、notesstring | null可选
isActiveboolean默认为 true
curl -X POST https://api.fabhub.app/v1/items \
  -H "X-API-Key: $FABHUB_API_KEY" \
  -H "Idempotency-Key: 0b9c4a2e-..." \
  -H "Content-Type: application/json" \
  -d '{"name":"Blue Widget","itemType":"product","salePrice":19.99}'

返回 { "data": { ...item } },包含已创建的物料。

GET /v1/items/{item_id}

作用域:items:read。返回 { "data": { ...item } },或返回 404 并带有 code: "NOT_FOUND"。

PATCH /v1/items/{item_id}

作用域:items:write。需要 Idempotency-Key。接受创建字段的任意子集,并返回更新后的物料。

物料子资源

  • GET /v1/items/{item_id}/ingredients(作用域 items:read)- 用于 combo/制造类物料的组件。
  • GET /v1/items/{item_id}/suppliers(作用域 items:read)- 关联到某个物料的供应商。

订单

GET /v1/orders

作用域:orders:read。

查询类型说明
modulebuy | sell | make | check | fix必填
status订单状态可选过滤(draft、open、in_progress、waiting、completed、cancelled)
page、page_size、search-标准列表参数
{
  "data": [
    {
      "id": "ord_1",
      "module": "sell",
      "orderNumber": "SO-1042",
      "status": "open",
      "contactId": "con_7",
      "orderDate": "2026-06-18",
      "dueDate": "2026-06-25",
      "siteId": null,
      "priority": "normal",
      "assignedTo": null,
      "contact": { "id": "con_7", "name": "Globex" },
      "site": null,
      "createdAt": "2026-06-18T10:00:00Z",
      "updatedAt": "2026-06-18T10:05:00Z"
    }
  ],
  "pagination": { "page": 1, "pageSize": 20, "total": 3, "totalPages": 1 }
}

订单还支持 POST /v1/orders、GET /v1/orders/{order_id} 和 PATCH /v1/orders/{order_id}(写操作需要 Idempotency-Key),以及用于行项目的 GET /v1/orders/{order_id}/lines(作用域 orders:read)。请参阅 OpenAPI 契约了解确切的请求主体。


联系人

GET /v1/contacts

作用域:contacts:read。

查询类型说明
contact_typesstring以逗号分隔:customer、supplier、both
page、page_size、search-标准列表参数

每个联系人:id、name、email、phone、company、contactType、country、contactGroup、isPrimaryContact、isActive、updatedAt。

联系人还支持 POST /v1/contacts、GET /v1/contacts/{contact_id} 和 PATCH /v1/contacts/{contact_id}(写操作需要 Idempotency-Key);字段请参阅 OpenAPI 契约。


组织

GET /v1/organization

作用域:organization:read。返回 { "data": { "id", "name", "slug", "plan", "createdAt" } },其中 plan 为 free | standard | pro | enterprise。


用量

GET /v1/usage

作用域:usage:read。返回当前计费周期、请求总数(整体及按能力划分),以及速率限制层级和剩余额度。参见速率限制。


审计事件

GET /v1/audit/events

作用域:audit:read(企业版)。基于游标的分页导出。

查询类型说明
since、untilISO 8601时间窗口
action_prefixstring按动作前缀过滤
actor_typeuser | system | api按行为者过滤
limitinteger页大小
cursor_created_at、cursor_id-从上一页继续
{
  "data": [
    {
      "id": "evt_1",
      "actorType": "api",
      "actorId": "key_8f...",
      "action": "item.created",
      "resourceType": "item",
      "resourceId": "a1c9...",
      "metadata": {},
      "ipAddress": "203.0.113.10",
      "createdAt": "2026-06-19T14:02:00Z"
    }
  ],
  "pagination": { "hasMore": true, "nextCursor": { "createdAt": "2026-06-19T14:02:00Z", "id": "evt_1" } }
}

库存

GET /v1/stock-levels

返回租户物料的当前库存水平(所需作用域见上表,过滤器及响应结构见 OpenAPI 契约)。


Webhook

完整的生命周期与签名细节请见 Webhook。

方法路径作用域
GET/v1/webhookswebhooks:read
POST/v1/webhookswebhooks:write(企业版)
GET/v1/webhooks/{webhook_id}webhooks:read
PATCH/v1/webhooks/{webhook_id}webhooks:write
DELETE/v1/webhooks/{webhook_id}webhooks:delete
GET/v1/webhooks/{webhook_id}/deliverieswebhooks:deliveries:read
首页功能定价关于文章文档开发者
© FabHub隐私与 Cookie条款无障碍