{"openapi":"3.1.0","info":{"title":"POST /api/v1/inventory/counts/{count_id}/preview-post","version":"1.0.0","description":"Preview posting a cycle count"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/inventory/counts/{count_id}/preview-post":{"post":{"tags":["inventory:counts"],"summary":"Preview posting a cycle count","description":"Side-effect free. Per inventory category: book vs counted value and the delta, plus the journal lines posting would write (to the category ledger when inventory ledgers are mapped, else Inventory) and a plan_hash. Pass plan_hash to POST /counts/{id}/post to refuse the post if anything moved since.","operationId":"inventory_gl_preview_post_count","parameters":[{"name":"count_id","in":"path","required":true,"schema":{"type":"string","title":"Count Id"}},{"name":"authorization","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Authorization"}},{"name":"x-business-id","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Business-Id"}}],"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessEnvelope_CountPostPreviewResponse_"}}}},"401":{"description":"Unauthorized - Missing or expired token, an MCP OAuth token used against the REST API, or no access to this business","content":{"application/json":{"example":{"error":"unauthorized","message":"Authentication required","code":"AUTH_001","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden - Insufficient permissions","content":{"application/json":{"example":{"error":"forbidden","message":"You don't have permission to access this resource","code":"AUTH_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not Found - Resource does not exist","content":{"application/json":{"example":{"error":"not_found","message":"Resource not found","code":"NOT_FOUND_001","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error - Request body or parameters failed validation","content":{"application/json":{"example":{"error":"validation_error","message":"Validation failed: amount: Input should be a valid integer","errors":{"amount":"Input should be a valid integer"},"code":"GEN_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"x-fastapi-operation-id":"inventory_gl_preview_post_count_api_v1_inventory_counts__count_id__preview_post_post"}}},"components":{"schemas":{"CountCategoryPreview":{"properties":{"category":{"type":"string","title":"Category","description":"raw_material, packaging, finished_good or uncategorized"},"ledger_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Ledger Id","description":"Ledger the variance posts to (category ledger or inventory)"},"book_cents":{"type":"integer","title":"Book Cents","description":"Expected quantity x unit cost"},"counted_cents":{"type":"integer","title":"Counted Cents","description":"Counted quantity x unit cost"},"delta_cents":{"type":"integer","title":"Delta Cents","description":"counted_cents - book_cents"},"line_count":{"type":"integer","title":"Line Count","default":0}},"type":"object","required":["category","book_cents","counted_cents","delta_cents"],"title":"CountCategoryPreview","description":"Book vs counted for one inventory category on a count."},"CountPostPreviewResponse":{"properties":{"count_id":{"type":"string","title":"Count Id"},"status":{"type":"string","title":"Status"},"valuation":{"type":"string","title":"Valuation","description":"book/counted are valued at the catalog unit cost; je_lines value a shortfall at the oldest cost lots first, as posting does under FIFO","default":"unit_cost"},"categories":{"items":{"$ref":"#/components/schemas/CountCategoryPreview"},"type":"array","title":"Categories"},"je_lines":{"items":{"$ref":"#/components/schemas/JournalLinePlan"},"type":"array","title":"Je Lines"},"plan_hash":{"type":"string","title":"Plan Hash","description":"Pass to POST /counts/{id}/post to apply exactly this plan"}},"type":"object","required":["count_id","status","plan_hash"],"title":"CountPostPreviewResponse","description":"What ``POST /counts/{id}/post`` would write, without writing it."},"JournalLinePlan":{"properties":{"ledger_id":{"type":"string","title":"Ledger Id"},"debit_credit":{"type":"string","enum":["debit","credit"],"title":"Debit Credit"},"amount":{"type":"integer","title":"Amount","description":"Cents"},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description"}},"type":"object","required":["ledger_id","debit_credit","amount"],"title":"JournalLinePlan","description":"One line a production transfer or count posting writes (or would)."},"SuccessEnvelope_CountPostPreviewResponse_":{"properties":{"success":{"type":"boolean","title":"Success","default":true},"message":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Message"},"code":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Code"},"data":{"anyOf":[{"$ref":"#/components/schemas/CountPostPreviewResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[CountPostPreviewResponse]"},"ErrorResponse":{"title":"ErrorResponse","type":"object","description":"Envelope returned by every non-2xx response. Branch on `code` (stable) rather than `message` (human-readable, may change).","required":["error","message","code"],"properties":{"error":{"type":"string","description":"Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`."},"message":{"type":"string","description":"Human-readable explanation, safe to show to end users."},"code":{"type":"string","description":"Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`)."},"request_id":{"type":"string","description":"Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied."},"errors":{"type":"object","additionalProperties":{"type":"string"},"description":"Field-level validation messages keyed by field name. Present on 400/422 validation failures only."}}}},"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Token","description":"API token authentication. Format: `Bearer dz_...`"}}},"security":[{"BearerAuth":[]}]}