{"openapi":"3.1.0","info":{"title":"POST /api/v1/credit/programs/{program_id}/card-management","version":"1.0.0","description":"Switch who manages a program's cards"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/credit/programs/{program_id}/card-management":{"post":{"tags":["credit"],"summary":"Switch who manages a program's cards","description":"Plans moving the program's `card_management` to `target`, per line and per card: `keep`, `adopt` (a registered card whose fund the program's issuer connection can see), `leave_with_partner` (with the reason), or `stays_with_dayzero` (a DayZero card on a program moving to the partner; it stays DayZero-managed and is still pushed). `dry_run` defaults to true and changes nothing. With `dry_run: false` the field is written, adoptable cards are adopted and their limit pushed once, and one `credit.line.limit_changed` is emitted per line whose managers changed. Applying the same target again changes nothing. Operator action.","operationId":"credit_switch_card_management","parameters":[{"name":"program_id","in":"path","required":true,"schema":{"type":"string","title":"Program 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/CardManagementSwitchRequest"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessEnvelope_CardManagementSwitchResponse_"}}}},"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"}}}},"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":{"example":{"error":"unauthorized","message":"Authentication required","code":"AUTH_001","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden - Insufficient permissions","content":{"application/json":{"example":{"error":"forbidden","message":"You don't have permission to access this resource","code":"AUTH_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not Found - Resource does not exist","content":{"application/json":{"example":{"error":"not_found","message":"Resource not found","code":"NOT_FOUND_001","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":"credit_switch_card_management_api_v1_credit_programs__program_id__card_management_post"}}},"components":{"schemas":{"CardManagementCardPlan":{"properties":{"card_id":{"type":"string","title":"Card Id","description":"The card."},"last_four":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last Four","description":"Its last four."},"provider_card_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Provider Card Id","description":"Issuer card id."},"provider_fund_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Provider Fund Id","description":"Issuer fund id."},"status":{"type":"string","title":"Status","description":"`active` or `suspended`."},"managed_by":{"type":"string","enum":["dayzero","partner"],"title":"Managed By","description":"Who manages it now."},"action":{"type":"string","enum":["keep","adopt","leave_with_partner","stays_with_dayzero"],"title":"Action","description":"`keep`: nothing changes for this card. `adopt`: a registered card DayZero takes over (its fund is visible to the program's issuer connection); its limit is pushed once. `leave_with_partner`: a registered card DayZero cannot take over; `reason` says why, and it keeps getting `credit.line.limit_changed`. `stays_with_dayzero`: the program moves from DayZero to the partner; this DayZero-issued card stays `managed_by: dayzero` and DayZero still pushes its limit until it is terminated."},"managed_by_after":{"type":"string","enum":["dayzero","partner"],"title":"Managed By After","description":"Who manages it once the switch is applied."},"limit_set_by_after":{"type":"string","enum":["dayzero","partner"],"title":"Limit Set By After","description":"Who sets its spend limit at the issuer afterwards: `dayzero` by pushing, `partner` from `credit.line.limit_changed`."},"reason":{"type":"string","title":"Reason","description":"Why, in a sentence."},"push_status":{"anyOf":[{"type":"string","enum":["pushed","unchanged","skipped","failed"]},{"type":"null"}],"title":"Push Status","description":"Applied switches only: the outcome of the one limit push made for this card's line after adoption. Null when nothing was pushed."},"push_detail":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Push Detail","description":"The issuer's reason when the push failed or skipped."}},"type":"object","required":["card_id","status","managed_by","action","managed_by_after","limit_set_by_after","reason"],"title":"CardManagementCardPlan","description":"What the switch does to one live card."},"CardManagementCounts":{"properties":{"keep":{"type":"integer","title":"Keep","description":"Cards left as they are.","default":0},"adopt":{"type":"integer","title":"Adopt","description":"Registered cards DayZero takes over.","default":0},"leave_with_partner":{"type":"integer","title":"Leave With Partner","description":"Registered cards that stay with the partner.","default":0},"stays_with_dayzero":{"type":"integer","title":"Stays With Dayzero","description":"DayZero cards on a program moving to the partner (still pushed).","default":0}},"type":"object","title":"CardManagementCounts","description":"Cards per action."},"CardManagementLinePlan":{"properties":{"credit_line_id":{"type":"string","title":"Credit Line Id","description":"The line."},"external_line_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"External Line Id","description":"Your id for it."},"status":{"type":"string","title":"Status","description":"The line's status (closed lines are left out)."},"managers_before":{"items":{"type":"string","enum":["dayzero","partner"]},"type":"array","title":"Managers Before","description":"Who the line's limit goes to now: `dayzero` (pushed to the cards DayZero manages) and/or `partner` (`credit.line.limit_changed`)."},"managers_after":{"items":{"type":"string","enum":["dayzero","partner"]},"type":"array","title":"Managers After","description":"The same, once the switch is applied."},"limit_changed_event":{"type":"boolean","title":"Limit Changed Event","description":"True when the set changes, so one `credit.line.limit_changed` (`reason: card_management_changed`) is emitted for the line on apply (or would be, on a dry run)."},"cards":{"items":{"$ref":"#/components/schemas/CardManagementCardPlan"},"type":"array","title":"Cards","description":"Every live card on the line."}},"type":"object","required":["credit_line_id","status","limit_changed_event"],"title":"CardManagementLinePlan","description":"What the switch does on one line."},"CardManagementSwitchRequest":{"properties":{"target":{"type":"string","enum":["dayzero","partner"],"title":"Target","description":"`dayzero`: DayZero manages the program's cards and adopts every registered card whose fund the program's issuer connection can see. `partner`: the partner manages them; DayZero stops pushing by default and announces limits as `credit.line.limit_changed`."},"dry_run":{"type":"boolean","title":"Dry Run","description":"Report the plan and change nothing. Send `false` to apply it.","default":true}},"additionalProperties":false,"type":"object","required":["target"],"title":"CardManagementSwitchRequest","description":"Move a program's card management to ``target``."},"CardManagementSwitchResponse":{"properties":{"program_id":{"type":"string","title":"Program Id","description":"The program."},"previous":{"type":"string","enum":["dayzero","partner"],"title":"Previous","description":"The program's `card_management` before this call."},"target":{"type":"string","enum":["dayzero","partner"],"title":"Target","description":"As sent."},"dry_run":{"type":"boolean","title":"Dry Run","description":"As sent. True means nothing was written."},"applied":{"type":"boolean","title":"Applied","description":"True when this call changed something: the program's field, a card adopted, or an event emitted. Applying the same target again changes nothing and is false."},"program_changed":{"type":"boolean","title":"Program Changed","description":"Whether `card_management` moves (or would move) to `target`."},"counts":{"$ref":"#/components/schemas/CardManagementCounts"},"limit_changed_events":{"type":"integer","title":"Limit Changed Events","description":"`credit.line.limit_changed` events emitted (or that would be).","default":0},"lines":{"items":{"$ref":"#/components/schemas/CardManagementLinePlan"},"type":"array","title":"Lines","description":"Every line on the program that is not closed."},"notes":{"items":{"type":"string"},"type":"array","title":"Notes","description":"What the switch means, in plain words."}},"type":"object","required":["program_id","previous","target","dry_run","applied","program_changed","counts"],"title":"CardManagementSwitchResponse","description":"The plan, and on apply what was done."},"SuccessEnvelope_CardManagementSwitchResponse_":{"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/CardManagementSwitchResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[CardManagementSwitchResponse]"},"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":[]}]}