Route: POST /v1/backend/integrations/bees/orders
Headers: Authorization: Bearer <token>, x-app-stage, x-app-uid
Query: companyId, storeId, distributionCenterId (required)
Body: JSON array of order objects conforming to the ROMA contract in goal-backend/resources/bees/orders/contracts/orders.jsonc.
Response: ActionResult with data = per-order results (status, message, validation fields).
| HTTP | When |
|---|---|
| 200 | At least one order validated and saved/updated |
| 422 | No valid orders, or validation failure on batch |
| 401 / 403 | Auth / permission |
| 500 | Unexpected error |
BeesSaveOrdersAction::validateSingleOrder).orders.jsonc template (ValidateBeesRomaOrderContractAction).normalizeOrderPayload): DC id as string, factor default, canonical line types, contact fields, promotionHints.Inbound BEES status values such as PENDING are accepted; on first save Couch status is set to PLACED.
external-orders)| Case | Behavior |
|---|---|
New beesOrderUuid |
add() — status = PLACED, placed_at set |
| Existing document | Upsert — merge payload, preserve order_number, _rev, placed_at; set last_bees_payload_at; status = MODIFIED if order_number already assigned, else PLACED |
Re-sending the same order updates the document; the API returns UPDATED (message: order updated successfully), not EXISTS.
user_email / user_phone — optional; copied to customer_email / customer_phone on the Couch doc when absent.seller — optional { code, name }; seller.code stored as bees_seller_code for downstream seller traceability.lines[].factor — required (min 1); maps to GOAL OrderLine.conversion_factor on process.lines[].summaryItem.discounts[] — optional; vendorPromotionId used for promo traceability when discount > 0.lines[].freeGoodRuleCode — required on FREEGOOD lines (price must be ~0).See also BEES integration hub and backend doc BEES_ORDER_PROMOTION_POLICY.md.
{
"lines": [
{
"type": "REGULAR",
"factor": 48,
"typeOfUnit": "PQT",
"summaryItem": {
"basePrice": 2.46,
"discount": 0.5,
"price": 1.96,
"discounts": [
{
"type": "LINE_ITEM_DISCOUNT",
"vendorPromotionId": "21123459",
"value": 0.5
}
]
}
}
]
}
After Couch save, ProcessAllBeesOrdersAction polls PLACED / MODIFIED orders and runs CreateOrderFromBeesAction to materialize PostgreSQL orders. Header-only updates apply when a PG order already exists (line replace is out of scope unless configured later).