{"openapi":"3.1.0","info":{"title":"POST /api/v1/credit/programs/{program_id}/mcc-allowlist/preview","version":"1.0.0","description":"Preview an MCC allow list"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/credit/programs/{program_id}/mcc-allowlist/preview":{"post":{"tags":["credit"],"summary":"Preview an MCC allow list","description":"Builds the allow-list table from one source: an uploaded card export (`multipart/form-data` with a `file` part, CSV or JSON), the program's own settlements over `window_days` (`source: settlements`), or a curated list (`source: preset`, `preset: ad_spend`). Every source returns the same table: per MCC its description, transactions, spend, the Ramp category it reaches the issuer as or `unmapped`, and whether it is suggested. Changes nothing. Operator action.","operationId":"credit_mcc_allowlist_preview","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"}}],"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessEnvelope_MccAllowlistPreviewResponse_"}}}},"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"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"additionalProperties":false,"description":"The JSON body of a preview: learn from settlements, or start from a preset.\n\nAn upload is sent as ``multipart/form-data`` instead, with the export as\nthe ``file`` part and optional ``amounts_in`` and ``min_count`` fields.","properties":{"source":{"description":"`settlements` builds the table from this program's own posted settlements; `preset` from a curated list.","enum":["settlements","preset"],"title":"Source","type":"string"},"window_days":{"default":90,"description":"For `settlements`: how many days back from today to read. Ignored for a preset.","maximum":365,"minimum":1,"title":"Window Days","type":"integer"},"preset":{"anyOf":[{"const":"ad_spend","type":"string"},{"type":"null"}],"description":"For `preset`: which curated list. Required with `preset`.","title":"Preset"},"min_count":{"default":1,"description":"An MCC is suggested only when it was seen at least this many times (and maps to a Ramp category). Every preset code is suggested.","maximum":100000,"minimum":1,"title":"Min Count","type":"integer"}},"required":["source"],"title":"MccAllowlistPreviewRequest","type":"object"}},"multipart/form-data":{"schema":{"title":"MccAllowlistUploadForm","type":"object","required":["file"],"properties":{"file":{"type":"string","format":"binary","description":"The card transaction export, CSV or JSON, at most 10 MB."},"amounts_in":{"type":"string","enum":["dollars","cents"],"default":"dollars","description":"Unit of the export's amount column."},"min_count":{"type":"integer","minimum":1,"default":1,"description":"Suggest an MCC only when it appears at least this often."}}}}}},"x-fastapi-operation-id":"credit_mcc_allowlist_preview_api_v1_credit_programs__program_id__mcc_allowlist_preview_post"}}},"components":{"schemas":{"MccAllowlistPreviewResponse":{"properties":{"program_id":{"type":"string","title":"Program Id","description":"The program previewed."},"source":{"type":"string","enum":["upload","settlements","preset"],"title":"Source","description":"Where the table came from."},"file_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"File Name","description":"For an upload: the file's name as sent."},"file_sha256":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"File Sha256","description":"For an upload: the SHA-256 of the file as received. Send it back on apply so the audit entry names the exact file."},"preset":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Preset","description":"For a preset: its key."},"preset_label":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Preset Label","description":"For a preset: its name."},"window_days":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Window Days","description":"For settlements: the window read, in days."},"window_start":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Window Start","description":"For settlements: the first settlement date read (UTC)."},"rows_read":{"type":"integer","title":"Rows Read","description":"Transactions considered: rows in the file, or settlements in the window (spend only; refunds and voided ones are left out).","default":0},"rows_without_mcc":{"type":"integer","title":"Rows Without Mcc","description":"Of those, how many carried no usable MCC.","default":0},"min_count":{"type":"integer","title":"Min Count","description":"The suggestion floor applied.","default":1},"rows":{"items":{"$ref":"#/components/schemas/MccAllowlistRow"},"type":"array","title":"Rows","description":"One row per MCC, highest spend first; then any MCC on the current list the source did not contain."},"suggested_codes":{"items":{"type":"string"},"type":"array","title":"Suggested Codes","description":"The suggested MCCs, sorted."},"suggested_ramp_categories":{"items":{"$ref":"#/components/schemas/RampCategoryRef"},"type":"array","title":"Suggested Ramp Categories","description":"The Ramp categories the suggested MCCs span at the issuer."},"unmapped_codes":{"items":{"type":"string"},"type":"array","title":"Unmapped Codes","description":"Every MCC in the table with no known Ramp category, sorted."},"current_codes":{"items":{"type":"string"},"type":"array","title":"Current Codes","description":"The program's allow list as it stands."}},"type":"object","required":["program_id","source"],"title":"MccAllowlistPreviewResponse","description":"The table every source produces."},"MccAllowlistRow":{"properties":{"mcc":{"type":"string","title":"Mcc","description":"The four-digit merchant category code."},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description","description":"What the networks call this MCC; null when it is not known."},"transactions":{"type":"integer","title":"Transactions","description":"How many transactions in the source carried this MCC."},"spend_cents":{"type":"integer","title":"Spend Cents","description":"Their total spend, in cents."},"merchants":{"items":{"type":"string"},"type":"array","title":"Merchants","description":"Up to five merchant names seen under this MCC, sorted."},"merchant_count":{"type":"integer","title":"Merchant Count","description":"How many distinct merchant names were seen.","default":0},"ramp_category_code":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Ramp Category Code","description":"The Ramp category this MCC reaches the issuer as; null when unmapped."},"ramp_category_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Ramp Category Name","description":"Ramp's name for that category; null when no Ramp category is known for the MCC (`unmapped`)."},"unmapped":{"type":"boolean","title":"Unmapped","description":"True when no Ramp category is known for this MCC: it cannot be allowed at the issuer and would be left out of the push."},"suggested":{"type":"boolean","title":"Suggested","description":"Whether the preview suggests including it: mapped to a Ramp category and seen at least `min_count` times (every preset code)."},"currently_allowed":{"type":"boolean","title":"Currently Allowed","description":"Whether the program's current allow list already has it."},"in_source":{"type":"boolean","title":"In Source","description":"False for a row added only because the current allow list has it and the source does not.","default":true}},"type":"object","required":["mcc","transactions","spend_cents","unmapped","suggested","currently_allowed"],"title":"MccAllowlistRow","description":"One MCC in a preview."},"RampCategoryRef":{"properties":{"code":{"type":"integer","title":"Code","description":"Ramp's own category code (1–44)."},"name":{"type":"string","title":"Name","description":"Ramp's name for the category."}},"type":"object","required":["code","name"],"title":"RampCategoryRef","description":"A Ramp spending category: what an allowed MCC is pushed to the issuer as."},"SuccessEnvelope_MccAllowlistPreviewResponse_":{"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/MccAllowlistPreviewResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[MccAllowlistPreviewResponse]"},"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":[]}]}