{"openapi":"3.1.0","info":{"title":"POST /api/v1/onboarding/prepare-checkout","version":"1.0.0","description":"Create Stripe Checkout session for onboarding"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/onboarding/prepare-checkout":{"post":{"tags":["onboarding"],"summary":"Create Stripe Checkout session for onboarding","description":"Collects plan and add-on selections, creates a Stripe Checkout session with a 30-day free trial. Business is NOT created until /complete is called. Fully Managed (dz-managed) and Firm Enterprise start with a free pilot and are refused with 400 VALIDATION_912.","operationId":"prepare_checkout","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PrepareCheckoutRequest"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessEnvelope_PrepareCheckoutResponse_"}}}},"400":{"description":"Bad Request - Invalid input","content":{"application/json":{"example":{"error":"validation_error","message":"Validation failed: due_date: Input should be a valid date","errors":{"due_date":"Input should be a valid date"},"code":"GEN_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Conflict - Resource already exists or is in an incompatible state","content":{"application/json":{"example":{"error":"conflict","message":"Resource already exists","code":"CONFLICT_001","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Too Many Requests - Rate limit exceeded; back off and retry","content":{"application/json":{"example":{"error":"rate_limited","message":"Too many requests. Please slow down.","code":"GEN_005","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Service Unavailable","content":{"application/json":{"example":{"error":"service_unavailable","message":"The service is temporarily unavailable. Please try again later.","code":"GEN_004","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":"prepare_checkout_api_v1_onboarding_prepare_checkout_post"}}},"components":{"schemas":{"PrepareCheckoutRequest":{"properties":{"account_type":{"type":"string","pattern":"^(self-managed|dz-managed|advisory-firm|personal)$","title":"Account Type","description":"'self-managed', 'dz-managed', 'advisory-firm', or 'personal'. 'dz-managed' (Fully Managed) starts with a free pilot and is refused here with VALIDATION_912."},"business_name":{"type":"string","maxLength":255,"minLength":1,"title":"Business Name"},"mailbox":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Mailbox"},"personal_plan_tier":{"anyOf":[{"type":"string","enum":["personal_core","personal_plus"]},{"type":"null"}],"title":"Personal Plan Tier","description":"Personal Finance plan tier when account_type is 'personal' ('personal_core' or 'personal_plus', defaults to 'personal_core')."},"monthly_income_target_cents":{"anyOf":[{"type":"integer","maximum":10000000000.0,"minimum":0.0},{"type":"null"}],"title":"Monthly Income Target Cents","description":"Optional monthly take-home income target in cents for personal finance workspaces."},"default_currency":{"type":"string","maxLength":3,"title":"Default Currency","description":"Default business currency. Supported out of the box: USD, CAD, AUD, EUR, GBP.","default":"USD"},"tax_year_end_month":{"type":"integer","maximum":12.0,"minimum":1.0,"title":"Tax Year End Month","default":12},"selected_addons":{"anyOf":[{"items":{"type":"string"},"type":"array","maxItems":50},{"type":"null"}],"title":"Selected Addons","description":"Optional list of addon slugs to include on the Stripe Checkout. Capped at 50 entries."},"trial_agreed":{"type":"boolean","const":true,"title":"Trial Agreed","description":"User has agreed to the 30-day free trial terms"},"billing_interval":{"type":"string","enum":["month","year"],"title":"Billing Interval","description":"Billing cadence for the subscription. 'year' resolves the discounted annual catalog prices; defaults to 'month'.","default":"month"},"hidden_nav_ids":{"anyOf":[{"items":{"type":"string"},"type":"array","maxItems":200},{"type":"null"}],"title":"Hidden Nav Ids","description":"Optional nav catalog ids to hide on initial workspace creation (e.g. 'workspace:inventory', 'books-section:Projects & Time')."},"nav_focus_preset":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Nav Focus Preset","description":"Optional focus preset chosen during onboarding: essentials, services, ecommerce, saas_b2b, full, or custom."},"nav_focus_summary":{"anyOf":[{"type":"string","maxLength":280},{"type":"null"}],"title":"Nav Focus Summary","description":"Optional short description of the chosen workspace focus."},"firm_name":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Firm Name"},"firm_plan_tier":{"anyOf":[{"type":"string","pattern":"^(firm_starter|firm_professional|firm_enterprise)$"},{"type":"null"}],"title":"Firm Plan Tier","description":"Graduated firm plan tier (defaults to firm_starter). firm_enterprise starts with a free pilot and is refused here with VALIDATION_912."},"ein":{"anyOf":[{"type":"string","maxLength":20},{"type":"null"}],"title":"Ein"},"logo_url":{"anyOf":[{"type":"string","maxLength":1024},{"type":"null"}],"title":"Logo Url","description":"Either the S3 key returned by /onboarding/upload-url (onboarding/{user_id}/{uuid}.{ext}) or a public https URL."},"address":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Address"},"num_full_time_accountants":{"anyOf":[{"type":"integer","minimum":0.0},{"type":"null"}],"title":"Num Full Time Accountants"},"num_part_time_accountants":{"anyOf":[{"type":"integer","minimum":0.0},{"type":"null"}],"title":"Num Part Time Accountants"},"current_tools":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Current Tools"},"referral_source":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Referral Source","description":"Self-reported acquisition channel: referral, accountant, search, social, ads, event, marketplace, other."},"referred_by_email":{"anyOf":[{"type":"string","maxLength":320},{"type":"null"}],"title":"Referred By Email","description":"Email of whoever referred this user. Free text — not resolved against existing accounts."},"utm_source":{"anyOf":[{"type":"string","maxLength":512},{"type":"null"}],"title":"Utm Source"},"utm_medium":{"anyOf":[{"type":"string","maxLength":512},{"type":"null"}],"title":"Utm Medium"},"utm_campaign":{"anyOf":[{"type":"string","maxLength":512},{"type":"null"}],"title":"Utm Campaign"},"utm_term":{"anyOf":[{"type":"string","maxLength":512},{"type":"null"}],"title":"Utm Term"},"utm_content":{"anyOf":[{"type":"string","maxLength":512},{"type":"null"}],"title":"Utm Content"},"gclid":{"anyOf":[{"type":"string","maxLength":512},{"type":"null"}],"title":"Gclid"},"fbclid":{"anyOf":[{"type":"string","maxLength":512},{"type":"null"}],"title":"Fbclid"},"li_fat_id":{"anyOf":[{"type":"string","maxLength":512},{"type":"null"}],"title":"Li Fat Id"},"msclkid":{"anyOf":[{"type":"string","maxLength":512},{"type":"null"}],"title":"Msclkid"},"ga_client_id":{"anyOf":[{"type":"string","maxLength":120},{"type":"null"}],"title":"Ga Client Id"},"referral_code":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"title":"Referral Code"},"promo_code":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"title":"Promo Code"},"landing_page":{"anyOf":[{"type":"string","maxLength":512},{"type":"null"}],"title":"Landing Page"},"referrer":{"anyOf":[{"type":"string","maxLength":512},{"type":"null"}],"title":"Referrer"},"success_path":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Success Path","description":"Optional path-only override (no host) to land on after Stripe Checkout. Defaults to /onboarding/complete."},"cancel_path":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Cancel Path","description":"Optional path-only override (no host) for cancelled checkout. Defaults to /welcome."}},"type":"object","required":["account_type","business_name","trial_agreed"],"title":"PrepareCheckoutRequest","description":"Prepare a Stripe Checkout session for onboarding.\n\nCollects all onboarding data upfront. The business is NOT created yet --\nit will be created after the user completes Stripe Checkout."},"PrepareCheckoutResponse":{"properties":{"checkout_url":{"type":"string","title":"Checkout Url"},"session_id":{"type":"string","title":"Session Id"},"reused":{"type":"boolean","title":"Reused","default":false}},"type":"object","required":["checkout_url","session_id"],"title":"PrepareCheckoutResponse","description":"Response with Stripe Checkout URL.\n\n``reused`` is True when no new Checkout session was created: either an\nearlier session for this user had already completed (it was provisioned\nand ``checkout_url`` points at ``/onboarding/complete``) or an open one\nwas still valid (``checkout_url`` is its Stripe URL)."},"SuccessEnvelope_PrepareCheckoutResponse_":{"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/PrepareCheckoutResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[PrepareCheckoutResponse]"},"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":[]}]}