{"openapi":"3.1.0","info":{"title":"POST /api/v1/o2c/deals","version":"1.0.0","description":"Create a deal"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/o2c/deals":{"post":{"tags":["deals"],"summary":"Create a deal","description":"Create a pipeline deal. Provide either `prospect_name` (before a real customer record exists) or `customer_id` (an expansion deal on an existing customer). `stage` defaults to `prospecting`.","operationId":"create_deal_api_v1_o2c_deals_post","parameters":[{"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/DealCreate"}}}},"responses":{"201":{"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":{"DealCreate":{"properties":{"prospect_name":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Prospect Name","description":"Free-text prospect/company name, used before a real customer record exists. Required unless customer_id is set."},"customer_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Customer Id","description":"Existing customer this deal is for (expansion deal). Required unless prospect_name is set."},"name":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Name","description":"Deal name. Defaults to the prospect/customer name."},"contact_name":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Contact Name","description":"Sales contact."},"contact_email":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Contact Email","description":"Sales contact email. Never written to the customer record -- may later become the order signer."},"source":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source","description":"One of ['event', 'expansion', 'inbound', 'other', 'outbound', 'partner', 'referral']."},"stage":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Stage","description":"One of ['closed_lost', 'closed_won', 'negotiation', 'proposal', 'prospecting', 'qualified']. Defaults to 'prospecting'."},"is_expansion":{"type":"boolean","title":"Is Expansion","description":"True if this is expansion revenue on an existing customer.","default":false},"expected_value_cents":{"type":"integer","minimum":0.0,"title":"Expected Value Cents","description":"Estimated deal value in cents.","default":0},"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."},"notes":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Notes","description":"Free-text notes."}},"type":"object","title":"DealCreate","description":"Request schema for creating a pipeline deal.\n\nEither ``prospect_name`` or ``customer_id`` is required (mirrors the\n``deals`` table: early-stage deals track a free-text prospect until a\nreal ``customers`` row exists). ``stage`` defaults to ``prospecting``\nwhen omitted."},"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."},"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":[]}]}