{"openapi":"3.1.0","info":{"title":"GET /api/v1/deferred-revenue/matrix","version":"1.0.0","description":"Deferred revenue matrix"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/deferred-revenue/matrix":{"get":{"tags":["deferred-revenue"],"summary":"Deferred revenue matrix","description":"Deferred invoices (rows) against recognition months (columns).","operationId":"deferred_revenue_matrix","parameters":[{"name":"status","in":"query","required":false,"schema":{"anyOf":[{"$ref":"#/components/schemas/DeferralStatusEnum"},{"type":"null"}],"description":"Filter by deferral status","default":"active","title":"Status"},"description":"Filter by deferral status"},{"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":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessEnvelope_DeferredRevenueMatrixResponse_"}}}},"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"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"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"}}}}},"x-fastapi-operation-id":"deferred_revenue_matrix_api_v1_deferred_revenue_matrix_get"}}},"components":{"schemas":{"DeferralStatusEnum":{"type":"string","enum":["active","completed","cancelled"],"title":"DeferralStatusEnum","description":"Lifecycle of a deferral."},"DeferredRevenueMatrixCell":{"properties":{"period":{"type":"string","title":"Period","description":"YYYY-MM"},"amount_cents":{"type":"integer","title":"Amount Cents"},"recognized":{"type":"boolean","title":"Recognized"}},"type":"object","required":["period","amount_cents","recognized"],"title":"DeferredRevenueMatrixCell","description":"One invoice/month cell of the deferred revenue matrix."},"DeferredRevenueMatrixResponse":{"properties":{"periods":{"items":{"type":"string"},"type":"array","title":"Periods","description":"Month columns, ascending YYYY-MM"},"rows":{"items":{"$ref":"#/components/schemas/DeferredRevenueMatrixRow"},"type":"array","title":"Rows"},"period_totals":{"items":{"type":"integer"},"type":"array","title":"Period Totals","description":"Column totals, aligned with `periods`"},"customer_totals":{"additionalProperties":{"type":"integer"},"type":"object","title":"Customer Totals","description":"Remaining deferred balance grouped by customer name"},"total_deferred_cents":{"type":"integer","title":"Total Deferred Cents"},"total_recognized_cents":{"type":"integer","title":"Total Recognized Cents"},"total_remaining_cents":{"type":"integer","title":"Total Remaining Cents"}},"type":"object","required":["periods","rows","period_totals","total_deferred_cents","total_recognized_cents","total_remaining_cents"],"title":"DeferredRevenueMatrixResponse","description":"Invoices (rows) x months (columns) with column and customer roll-ups."},"DeferredRevenueMatrixRow":{"properties":{"deferral_id":{"type":"string","title":"Deferral Id"},"invoice_id":{"type":"string","title":"Invoice Id"},"invoice_number":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Invoice Number"},"customer_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Customer Id"},"customer_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Customer Name"},"deferred_amount_cents":{"type":"integer","title":"Deferred Amount Cents"},"recognized_cents":{"type":"integer","title":"Recognized Cents"},"remaining_cents":{"type":"integer","title":"Remaining Cents"},"cells":{"items":{"$ref":"#/components/schemas/DeferredRevenueMatrixCell"},"type":"array","title":"Cells"}},"type":"object","required":["deferral_id","invoice_id","deferred_amount_cents","recognized_cents","remaining_cents","cells"],"title":"DeferredRevenueMatrixRow","description":"One deferred invoice across the matrix's months."},"SuccessEnvelope_DeferredRevenueMatrixResponse_":{"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/DeferredRevenueMatrixResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[DeferredRevenueMatrixResponse]"},"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":[]}]}