manicanldes-backend/docs/b2b-custom-candles-api.md

2.7 KiB
Raw Permalink Blame History

B2B custom candle requests (Phase 3I)

Staff capture requests for verified business accounts under /api/v1/b2b/custom-candles. All endpoints require a bearer session and are scoped to its organization.

Method Path Permission Purpose
GET / b2b.custom.read List with optional accountId, status, limit, offset
GET /:id b2b.custom.read Read specifications and decision
POST / b2b.custom.request Capture immutable specifications
POST /:id/decision b2b.custom.review Independently approve or reject

Request example:

{
  "accountId": "b92c23e5-794d-47e7-a7f4-428b84543fa1",
  "quantity": 500,
  "waxType": "Soy",
  "fragrance": "Rose",
  "container": "Glass jar, 200g fill",
  "color": "Ivory",
  "brandingRequirements": "Printed logo label",
  "specifications": "Cotton wick; individual gift boxes",
  "idempotencyKey": "10fc5585-34a6-4ead-b5ce-d83418eb50df"
}

Quantity must be an integer from 1 to 1,000,000. Wax type and color allow 100 characters; fragrance and container 160; branding requirements 1,000; specifications 2,000 (minimum three). Text is trimmed and required; use None or Unscented where appropriate. Unknown fields are rejected.

Decision body: { "decision": "APPROVED", "note": "Feasibility reviewed", "idempotencyKey": "<uuid>" }, or REJECTED. Notes require 3–1,000 characters. The requester cannot review their own request. Approval rechecks business verification. Each request permits one decision, enforced by a unique constraint; request and decision updates/deletes are blocked by database triggers.

Responses include the decision (initially null) and computed status: REQUESTED, APPROVED, or REJECTED. Request and decision idempotency keys each have their own organization-scoped namespace. Identical retries return the current representation; different content using the same key returns 409. Unauthorized commands return 403, out-of-scope resources 404, unverified accounts and repeat decisions 409. Audit events record request capture and the decision in the same transaction.

Approval means staff accepted the specifications for further commercial work. It creates no quotation, price, order, credit exposure, BOM, stock reservation, production batch, or artwork approval. Revised specifications require a new request and review. Existing system Owner roles receive permissions through the migration; custom roles require explicit grants through RBAC.