{"openapi":"3.1.0","info":{"title":"POST /api/v1/advisory-firms/{firm_id}/cleanup-sessions","version":"1.0.0","description":"Start a historical cleanup session"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/advisory-firms/{firm_id}/cleanup-sessions":{"post":{"tags":["intercompany-cleanup"],"summary":"Start a historical cleanup session","description":"Creates a cleanup session over the given entities and date window, then kicks off the matching workflow. Poll the session for status and counters.","operationId":"create_cleanup_session_api_v1_advisory_firms__firm_id__cleanup_sessions_post","parameters":[{"name":"firm_id","in":"path","required":true,"schema":{"type":"string","title":"Firm Id"}},{"name":"authorization","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CleanupSessionCreate"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessEnvelope_CleanupRunResponse_"}}}},"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 - Invalid data format","content":{"application/json":{"example":{"detail":[{"loc":["body","field"],"msg":"field required","type":"value_error.missing"}]}}}}}}}},"components":{"schemas":{"CleanupRunResponse":{"properties":{"session_id":{"type":"string","title":"Session Id"},"status":{"type":"string","title":"Status"},"workflow_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Workflow Id"},"summary":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Summary"}},"type":"object","required":["session_id","status"],"title":"CleanupRunResponse","description":"Acknowledgement that a matching run was started/completed."},"CleanupSessionCreate":{"properties":{"date_start":{"type":"string","format":"date","title":"Date Start"},"date_end":{"type":"string","format":"date","title":"Date End"},"business_ids":{"items":{"type":"string"},"type":"array","title":"Business Ids","description":"Entities in scope; empty = every active firm business"},"date_tolerance_days":{"type":"integer","maximum":14.0,"minimum":0.0,"title":"Date Tolerance Days","default":3}},"type":"object","required":["date_start","date_end"],"title":"CleanupSessionCreate","description":"Start a historical cleanup sweep."},"SuccessEnvelope_CleanupRunResponse_":{"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/CleanupRunResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[CleanupRunResponse]"}},"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Token","description":"API token authentication. Format: `Bearer dz_...`"}}},"security":[{"BearerAuth":[]}]}