{"openapi":"3.1.0","info":{"title":"PATCH /api/v1/o2c/deals/{deal_id}","version":"1.0.0","description":"Edit deal"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/o2c/deals/{deal_id}":{"patch":{"tags":["deals"],"summary":"Edit deal","description":"Edit a deal's stage, notes, and expected-commercials estimates. Blocked once the deal has converted to an order (`order_id` set) -- manage it from Orders instead. Stage changes are validated against the model's allowed transitions.","operationId":"update_deal_api_v1_o2c_deals__deal_id__patch","parameters":[{"name":"deal_id","in":"path","required":true,"schema":{"type":"string","title":"Deal 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"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DealUpdate"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessEnvelope_DealResponse_"}}}},"400":{"description":"Bad Request - Invalid input","content":{"application/json":{"example":{"detail":"Invalid request parameters"}}}},"401":{"description":"Unauthorized - Authentication required","content":{"application/json":{"example":{"detail":"Not authenticated"}}}},"403":{"description":"Forbidden - Insufficient permissions","content":{"application/json":{"example":{"detail":"Not enough permissions"}}}},"404":{"description":"Not Found - Resource does not exist","content":{"application/json":{"example":{"detail":"Resource not found"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"DealResponse":{"properties":{"id":{"type":"string","title":"Id"},"business_id":{"type":"string","title":"Business Id"},"number":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Number"},"name":{"type":"string","title":"Name"},"stage":{"type":"string","title":"Stage"},"effective_stage":{"type":"string","title":"Effective Stage","description":"The stage the deal should be treated as: deal.stage, or the linked order's status once order_id is set."},"prospect_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Prospect Name"},"customer_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Customer Id"},"customer_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Customer Name"},"project_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Project Id"},"project_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Project Name"},"contact_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Contact Name"},"contact_email":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Contact Email"},"source":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source"},"is_expansion":{"type":"boolean","title":"Is Expansion","default":false},"expected_value_cents":{"type":"integer","title":"Expected Value Cents","default":0},"expected_hours":{"anyOf":[{"type":"string","pattern":"^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$"},{"type":"null"}],"title":"Expected Hours"},"expected_term_months":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Expected Term Months"},"expected_start_date":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Expected Start Date"},"expected_close_date":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Expected Close Date"},"order_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Order Id"},"lost_reason":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Lost Reason"},"notes":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Notes"},"stage_changed_at":{"type":"string","format":"date-time","title":"Stage Changed At"},"days_in_stage":{"type":"integer","title":"Days In Stage","default":0},"is_stalled":{"type":"boolean","title":"Is Stalled","default":false},"is_open":{"type":"boolean","title":"Is Open","default":false},"is_closed":{"type":"boolean","title":"Is Closed","default":false},"is_won":{"type":"boolean","title":"Is Won","default":false},"is_lost":{"type":"boolean","title":"Is Lost","default":false},"is_converted":{"type":"boolean","title":"Is Converted","default":false},"created_at":{"type":"string","format":"date-time","title":"Created At"},"updated_at":{"type":"string","format":"date-time","title":"Updated At"}},"type":"object","required":["id","business_id","name","stage","effective_stage","stage_changed_at","created_at","updated_at"],"title":"DealResponse","description":"Response schema for a deal."},"DealUpdate":{"properties":{"stage":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Stage","description":"One of ['closed_lost', 'closed_won', 'negotiation', 'proposal', 'prospecting', 'qualified'] (open stages only)."},"notes":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Notes","description":"Free-text notes."},"expected_value_cents":{"anyOf":[{"type":"integer","minimum":0.0},{"type":"null"}],"title":"Expected Value Cents","description":"Estimated deal value in cents."},"expected_hours":{"anyOf":[{"type":"number","minimum":0.0},{"type":"string","pattern":"^(?!^[-+.]*$)[+-]?0*(?:\\d{0,14}|(?=[\\d.]{1,17}0*$)\\d{0,14}\\.\\d{0,2}0*$)"},{"type":"null"}],"title":"Expected Hours","description":"Estimated hours."},"expected_term_months":{"anyOf":[{"type":"integer","minimum":1.0},{"type":"null"}],"title":"Expected Term Months","description":"Estimated contract term in months."},"expected_start_date":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Expected Start Date","description":"Estimated start date."},"expected_close_date":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Expected Close Date","description":"Estimated close date."}},"type":"object","title":"DealUpdate","description":"Request schema for editing a deal.\n\nOnly ``stage``, ``notes``, and the ``expected_*`` estimate fields are\neditable here -- blocked entirely once ``order_id`` is set (the deal has\nconverted to an order and is read-only; manage it from Orders instead).\nOmitted fields are left untouched; nullable fields (``notes``,\n``expected_hours``, ``expected_term_months``, ``expected_start_date``,\n``expected_close_date``) are cleared by sending an explicit ``null``."},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"SuccessEnvelope_DealResponse_":{"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/DealResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[DealResponse]"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}},"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Token","description":"API token authentication. Format: `Bearer dz_...`"}}},"security":[{"BearerAuth":[]}]}