{"openapi":"3.1.0","info":{"title":"GET /api/v1/tokens/{token_id}/credit-check","version":"1.0.0","description":"Test a credit key"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/tokens/{token_id}/credit-check":{"get":{"tags":["api-tokens"],"summary":"Test a credit key","description":"What `GET /credit/me` would answer for one of your API keys: the business, program, scopes, `credit_api_enabled` with `disabled_reasons` and `shopify_transport`, or the exact error (`409` `CREDIT_TOKEN_BUSINESS_AMBIGUOUS`, `403` scope, `401` revoked or expired). Worked out from the key's record with the same code; the key's secret is never used or shown. Browser sessions only.","operationId":"check_credit_key","parameters":[{"name":"token_id","in":"path","required":true,"schema":{"type":"string","description":"The key's id, from `GET /tokens`.","title":"Token Id"},"description":"The key's id, from `GET /tokens`."},{"name":"authorization","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessEnvelope_CreditKeyCheckResponse_"}}}},"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":"check_credit_key_api_v1_tokens__token_id__credit_check_get"}}},"components":{"schemas":{"CreditKeyCheckResponse":{"properties":{"token_id":{"type":"string","title":"Token Id","description":"The key checked."},"request":{"type":"string","const":"GET /api/v1/credit/me","title":"Request","description":"The call the check stands in for, sent without x-business-id.","default":"GET /api/v1/credit/me"},"ok":{"type":"boolean","title":"Ok","description":"The call would succeed (`me` is set)."},"status_code":{"type":"integer","title":"Status Code","description":"The HTTP status the call would get."},"error_code":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Error Code","description":"The error `code` the call would get, e.g. `CREDIT_TOKEN_BUSINESS_AMBIGUOUS`, `INSUFFICIENT_PERMISSIONS`."},"message":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Message","description":"The error message the call would get."},"error_data":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Error Data","description":"The error body's `data`, e.g. `{business_count: 3}`."},"me":{"anyOf":[{"$ref":"#/components/schemas/CreditMeResponse"},{"type":"null"}],"description":"The `/credit/me` body the call would get."}},"type":"object","required":["token_id","ok","status_code"],"title":"CreditKeyCheckResponse","description":"What ``GET /credit/me`` would answer for one of your API keys.\n\nWorked out from the key's record with the same code ``/credit/me`` runs,\nwithout the key's secret and without calling the API with it. The IP\nallowlist is not checked: the partner's servers call from their own\naddresses."},"CreditMeBusiness":{"properties":{"id":{"type":"string","title":"Id","description":"The business id; send it as `x-business-id`."},"name":{"type":"string","title":"Name","description":"The business's name."},"is_sandbox":{"type":"boolean","title":"Is Sandbox","description":"A sandbox (rehearsal) business: nothing on it moves real money."},"paired_sandbox_business_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Paired Sandbox Business Id","description":"On a live business, its paired sandbox. A token limited to the live business reaches it with `x-business-id` on the other credit endpoints."},"paired_live_business_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Paired Live Business Id","description":"On a sandbox, the live business it rehearses."}},"type":"object","required":["id","name","is_sandbox"],"title":"CreditMeBusiness","description":"The business the token acts on."},"CreditMeLineCounts":{"properties":{"active":{"type":"integer","title":"Active","description":"Lines that can spend.","default":0},"suspended":{"type":"integer","title":"Suspended","description":"Suspended lines.","default":0},"closed":{"type":"integer","title":"Closed","description":"Closed lines.","default":0}},"type":"object","title":"CreditMeLineCounts","description":"How many of the program's lines are in each status."},"CreditMeProgram":{"properties":{"id":{"type":"string","title":"Id","description":"The program id (`program_id` elsewhere)."},"slug":{"type":"string","title":"Slug","description":"The program's slug."},"display_name":{"type":"string","title":"Display Name","description":"The name borrowers see."},"status":{"type":"string","title":"Status","description":"`draft`, `active`, `paused` or `retired`."},"lending_model":{"$ref":"#/components/schemas/LendingModel","description":"`per_transaction` or `cycle_draw`."},"event_delivery_mode":{"$ref":"#/components/schemas/EventDeliveryMode","description":"How events reach you: `webhook`, `polling` or `both`."},"event_delivery_locked":{"type":"boolean","title":"Event Delivery Locked","description":"An operator fixed `event_delivery_mode`; an API token cannot change it."},"bank_link_redirect_uris":{"items":{"type":"string"},"type":"array","title":"Bank Link Redirect Uris","description":"Where a merchant's bank connection may return to."},"has_active_scorecard":{"type":"boolean","title":"Has Active Scorecard","description":"An underwriting scorecard on the program has an active version."},"measurement_source_mode":{"type":"string","enum":["ledger","aggregate_sources"],"title":"Measurement Source Mode","description":"What to send as `measurement_source_mode` on an assessment: `aggregate_sources` when the program's `bank_feed_config` says so, or DayZero holds an aggregate-source binding for one of its merchants; else `ledger`."},"bank_feed_provider":{"anyOf":[{"type":"string","enum":["direct_push","stripe_fc_bigquery"]},{"type":"null"}],"title":"Bank Feed Provider","description":"How a merchant's bank data reaches DayZero: the program's `bank_feed_config.provider` when an operator set one. null: not set by DayZero; the partner keeps its own default (send `provider` when registering a feed)."},"payment_iframe_enabled":{"type":"boolean","title":"Payment Iframe Enabled","description":"True when borrowers on this program can pay through DayZero's embeddable payment iframe (`/p/credit/{token}/pay?embed=1`). Always true on a sandbox business (sandbox payment simulator).","default":false},"payment_rails":{"items":{"type":"string"},"type":"array","title":"Payment Rails","description":"Payment rails active in the embeddable payment iframe: `[\"sandbox\"]` on a sandbox business, or the configured live rails (`stripe_ach`, `stripe_card`, `payliance_card`)."},"line_counts":{"$ref":"#/components/schemas/CreditMeLineCounts","description":"The program's lines by status (pending lines are not counted)."}},"type":"object","required":["id","slug","display_name","status","lending_model","event_delivery_mode","event_delivery_locked","has_active_scorecard","measurement_source_mode","line_counts"],"title":"CreditMeProgram","description":"A lending program the business operates."},"CreditMeResponse":{"properties":{"business":{"$ref":"#/components/schemas/CreditMeBusiness","description":"The business described: the token's one business, or `x-business-id`."},"token":{"$ref":"#/components/schemas/CreditMeToken","description":"The calling token."},"credit_api_enabled":{"type":"boolean","title":"Credit Api Enabled","description":"Every other `/credit` endpoint will answer this token on this business. When false, `disabled_reasons` says why."},"disabled_reasons":{"items":{"type":"string","enum":["addon_missing","billing_inactive","archived"]},"type":"array","title":"Disabled Reasons","description":"`addon_missing`: the business lacks CFO Suite (`403` `BILLING_003` elsewhere). `billing_inactive`: its trial or subscription has lapsed (`403` `AUTH_072`). `archived`: the business is archived (`AUTH_073`)."},"programs":{"items":{"$ref":"#/components/schemas/CreditMeProgram"},"type":"array","title":"Programs","description":"Every lending program the business operates, oldest first."},"shopify_transport":{"anyOf":[{"$ref":"#/components/schemas/CreditMeShopifyTransport"},{"type":"null"}],"description":"The key to seal Shopify tokens with. Null while DayZero has none configured; the shared-secret envelope is then the only one."},"api_version":{"type":"string","title":"Api Version","description":"The credit API contract version."}},"type":"object","required":["business","token","credit_api_enabled","api_version"],"title":"CreditMeResponse","description":"The token, its business, and whether the credit API is open to it."},"CreditMeShopifyTransport":{"properties":{"algorithm":{"type":"string","const":"RSA-OAEP-256+A256GCM","title":"Algorithm","description":"AES-256-GCM under a random 32-byte content key (the shop domain as additional authenticated data), the content key wrapped with RSA-OAEP, SHA-256 and MGF1-SHA-256."},"public_key":{"type":"string","title":"Public Key","description":"The RSA public key, PEM (SPKI)."},"key_id":{"type":"string","title":"Key Id","description":"Send as `key_id` on `POST /credit/shopify/pull`: 16 hex characters of the SHA-256 of the key's DER SPKI."}},"type":"object","required":["algorithm","public_key","key_id"],"title":"CreditMeShopifyTransport","description":"DayZero's public key for sealing a merchant's Shopify token."},"CreditMeToken":{"properties":{"scopes":{"items":{"type":"string"},"type":"array","title":"Scopes","description":"The token's scopes, as minted."},"business_limited":{"type":"boolean","title":"Business Limited","description":"The token is limited to named businesses."},"expires_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Expires At","description":"When the token stops working (UTC)."},"fingerprint":{"type":"string","title":"Fingerprint","description":"12 hex characters identifying the token (a hash of its id, not of the secret), stable for the token's life."},"program_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Program Id","description":"The one credit program the token is limited to; `programs` then lists only it. Null when the token is not limited to a program."}},"type":"object","required":["scopes","business_limited","fingerprint"],"title":"CreditMeToken","description":"The calling API token, without the token itself."},"EventDeliveryMode":{"type":"string","enum":["webhook","polling","both"],"title":"EventDeliveryMode","description":"How a partner learns that something happened.\n\nThe FRD lists this twice as an open joint decision (§13.3 items 2 and\n6). Making it per-program means the decision never blocks the build:\na partner that wants webhooks registers an endpoint, one that wants to\npoll simply does not."},"LendingModel":{"type":"string","enum":["per_transaction","cycle_draw"],"title":"LendingModel","description":"What the unit of borrowing is.\n\n* ``per_transaction`` — every posted card transaction originates its\n  own loan with its own term, due date, fee, and daily accrual after\n  the due date. The monthly statement is a presentation wrapper and\n  the moment accrued interest is applied. This is the Tie model\n  (FRD v2 §10.5, D-01).\n* ``cycle_draw`` — settlements accumulate into a monthly cycle that\n  resolves into one draw at close, carrying one term, one due date,\n  and one interest figure. The credit-card model FRD v1 specified.\n\nA program picks one. Lines inherit it, and every engine branch keys\non it, so a second partner on the other model is a row, not a build."},"SuccessEnvelope_CreditKeyCheckResponse_":{"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/CreditKeyCheckResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[CreditKeyCheckResponse]"},"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":[]}]}