{"openapi":"3.1.0","info":{"title":"DELETE /api/v1/businesses/{business_id}","version":"1.0.0","description":"Delete business"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/businesses/{business_id}":{"delete":{"tags":["businesses"],"summary":"Delete business","description":"Schedule the deletion of a business after the grace period.\n\n**Safety:** requires a JSON body with ``confirm_name`` matching the\nbusiness's name (case-insensitive, trimmed) and a recent Clerk\nre-verification of the caller (step-up).\n\n**Effect:** nothing is deleted now. The business is scheduled for\npermanent deletion ``BUSINESS_DELETION_GRACE_DAYS`` (default 30) days\nfrom now, as the privacy page promises, and the owners are emailed.\nUntil then the business stays readable, owners and admins can export\neverything (``POST /businesses/{business_id}/data-exports``) or cancel\n(``POST /businesses/{business_id}/deletion/cancel``), and background\nsyncs and scheduled jobs stop. Asking again keeps the original date.\n\n**After the grace period** the nightly sweep runs the hard delete:\nthird-party grants are revoked (Plaid, QuickBooks, Xero, Shopify,\nSquare...), every business row, S3 object version and AI memory\nis deleted. That part is irreversible.\n\n**Returns:** 202 with ``deletion_scheduled_for`` in ``data``.","operationId":"delete_business","parameters":[{"name":"business_id","in":"path","required":true,"schema":{"type":"string","title":"Business 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/BusinessDeleteRequest"}}}},"responses":{"202":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/app__core__success__MessageResponse"}}}},"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"}}}},"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":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"error":"unauthorized","message":"Authentication required","code":"AUTH_001","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"}}}},"403":{"description":"Forbidden - Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"error":"forbidden","message":"You don't have permission to access this resource","code":"AUTH_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"}}}}},"x-fastapi-operation-id":"delete_business_api_v1_businesses__business_id__delete"}}},"components":{"schemas":{"BusinessDeleteRequest":{"properties":{"confirm_password":{"anyOf":[{"type":"string","format":"password","writeOnly":true},{"type":"null"}],"title":"Confirm Password","description":"Deprecated and ignored. Retained so clients sending the old body keep working during rollout. Step-up is now proven by Clerk re-verification (an emailed code, or the account's own factor), which works for SSO accounts that have no password.","deprecated":true},"business_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Business Id"},"confirm_name":{"type":"string","minLength":1,"title":"Confirm Name","description":"Exact business name as a typed confirmation. Must match the persisted business name (case-insensitive, trimmed). Required."},"preserve_dz_users":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Preserve Dz Users"}},"type":"object","required":["confirm_name"],"title":"BusinessDeleteRequest","description":"Request body for irreversible business deletion.\n\nTwo gates, both required:\n\n- ``confirm_name`` MUST echo the business's name (case-insensitive,\n  trimmed). The backend rejects any delete whose ``confirm_name`` doesn't\n  match, which prevents single-click muscle-memory mistakes from wiping a\n  business and ~80 tables of dependent data.\n- ``confirm_password`` MUST be the caller's own account password,\n  re-verified against Clerk so an unattended session can't do this."},"app__core__success__MessageResponse":{"properties":{"success":{"type":"boolean","title":"Success","default":true},"message":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Message"},"code":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Code"}},"additionalProperties":true,"type":"object","title":"MessageResponse","description":"Envelope for data-less mutations: ``{success, message, code}``, no ``data``.\n\nCanonical ``response_model`` for deletes and other message-only mutations so\nthe generated TypeScript client gets a single, named ``MessageResponse`` type\ninstead of dozens of empty per-route stubs. Pairs with the\n``SuccessResponse.*`` builders (which already emit this exact shape)."},"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":[]}]}