{"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":"Delete a business and all associated resources (async via Temporal).\n\n**Safety:** requires a JSON body with ``confirm_name`` matching the\nbusiness's name (case-insensitive, trimmed). Guards against single-click\nmuscle-memory deletes — this endpoint wipes ~80 related tables via a\nTemporal workflow and is irreversible.\n\n**Cleanup Process:**\n1. For each Plaid connection:\n   - Teal API cleanup (transactions, journal entries, source accounts, ledgers)\n   - Local DB cleanup (Transactions → Line Entries → Journal Entries → Ledgers)\n   - PlaidItem deletion\n   - Plaid token revocation\n2. Teal instance deletion\n3. User associations cleanup\n4. Business record deletion\n\n**Notes:**\n- Deletion runs asynchronously via Temporal workflow\n- Returns immediately with workflow_id for status polling\n- This action is irreversible","operationId":"delete_business_api_v1_businesses__business_id__delete","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/HTTPValidationError"}}}}}}}},"components":{"schemas":{"BusinessDeleteRequest":{"properties":{"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_teal_instance":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Preserve Teal Instance"},"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\n``confirm_name`` MUST echo the business's name (case-insensitive, trimmed).\nThe backend rejects any delete whose ``confirm_name`` doesn't match, which\nprevents single-click muscle-memory mistakes from wiping a business and\n~80 tables of dependent data."},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"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"},"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)."}},"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Token","description":"API token authentication. Format: `Bearer dz_...`"}}},"security":[{"BearerAuth":[]}]}