{"openapi":"3.1.0","info":{"title":"POST /api/v1/api-clients","version":"1.0.0","description":"Create API client"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/api-clients":{"post":{"tags":["api-clients"],"summary":"Create API client","description":"Register a partner API client with its public keys (JWK set). Requires the two-factor step-up; refused for API tokens.","operationId":"create_api_client","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiClientCreate"},"example":{"allowed_ips":["203.0.113.10"],"description":"Tie's payment job","jwks":{"keys":[{"alg":"ES256","crv":"P-256","kid":"tie-2026-10","kty":"EC","use":"sig","x":"f83OJ3D2xF1Bg8vub9tLe1gHMzV76e8Tus9uPHvRVEU","y":"x_FEzRu9m36HLN_tue659LNpXW6pCyStikYjKIWI5a0"}]},"name":"Tie production","rate_limit_per_minute":600,"require_mtls":false,"require_signed_requests":true,"scopes":["credit:payments"],"token_ttl_seconds":900}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessEnvelope_ApiClientResponse_"}}}},"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"}}}},"429":{"description":"Too Many Requests - Rate limit exceeded; back off and retry","content":{"application/json":{"example":{"error":"rate_limited","message":"Too many requests. Please slow down.","code":"GEN_005","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":"create_api_client_api_v1_api_clients_post"}}},"components":{"schemas":{"ApiClientCreate":{"properties":{"name":{"type":"string","maxLength":255,"minLength":1,"title":"Name","description":"Client name"},"description":{"anyOf":[{"type":"string","maxLength":2000},{"type":"null"}],"title":"Description"},"scopes":{"items":{"type":"string","enum":["api","read_only","credit","credit:read","credit:payments"]},"type":"array","minItems":1,"title":"Scopes","description":"What every token issued to this client may do. Same vocabulary as API tokens: `credit`, `credit:read`, `credit:payments`, `read_only`, `api` (full access)."},"allowed_ips":{"anyOf":[{"items":{"type":"string"},"type":"array","maxItems":32},{"type":"null"}],"title":"Allowed Ips","description":"IPv4/IPv6 addresses or CIDR ranges the client may request tokens from and use them from. Omit for any IP."},"rate_limit_per_minute":{"anyOf":[{"type":"integer","maximum":6000.0,"minimum":10.0},{"type":"null"}],"title":"Rate Limit Per Minute","description":"Requests per minute each issued token may make; omit for the platform default."},"token_ttl_seconds":{"type":"integer","maximum":3600.0,"minimum":60.0,"title":"Token Ttl Seconds","description":"Lifetime of each access token, in seconds (60-3600).","default":900},"jwks":{"additionalProperties":true,"type":"object","title":"Jwks","description":"JWK set (`{\"keys\": [...]}`) with the public keys the client signs its assertions with: RS256 (RSA >= 2048 bits), ES256 (P-256) or EdDSA (Ed25519). Public members only; every key needs a `kid` when there is more than one."},"require_mtls":{"type":"boolean","title":"Require Mtls","description":"Bind every token to the client certificate presented at the token endpoint (RFC 8705). Only available where the load balancer forwards client certificates (`mtls_available`).","default":false},"mtls_cert_thumbprints":{"anyOf":[{"items":{"type":"string"},"type":"array","maxItems":20},{"type":"null"}],"title":"Mtls Cert Thumbprints","description":"Optional pin list of SHA-256 certificate thumbprints (hex or base64url). Empty: any certificate the load balancer accepted."},"require_signed_requests":{"type":"boolean","title":"Require Signed Requests","description":"Payment requests must also carry a signature from a signing key.","default":false}},"type":"object","required":["name","jwks"],"title":"ApiClientCreate","description":"Register a partner API client.","example":{"allowed_ips":["203.0.113.10"],"description":"Tie's payment job","jwks":{"keys":[{"alg":"ES256","crv":"P-256","kid":"tie-2026-10","kty":"EC","use":"sig","x":"f83OJ3D2xF1Bg8vub9tLe1gHMzV76e8Tus9uPHvRVEU","y":"x_FEzRu9m36HLN_tue659LNpXW6pCyStikYjKIWI5a0"}]},"name":"Tie production","rate_limit_per_minute":600,"require_mtls":false,"require_signed_requests":true,"scopes":["credit:payments"],"token_ttl_seconds":900},"examples":[{"allowed_ips":["203.0.113.10"],"description":"Tie's payment job","jwks":{"keys":[{"alg":"ES256","crv":"P-256","kid":"tie-2026-10","kty":"EC","use":"sig","x":"f83OJ3D2xF1Bg8vub9tLe1gHMzV76e8Tus9uPHvRVEU","y":"x_FEzRu9m36HLN_tue659LNpXW6pCyStikYjKIWI5a0"}]},"name":"Tie production","rate_limit_per_minute":600,"require_mtls":false,"require_signed_requests":true,"scopes":["credit:payments"],"token_ttl_seconds":900}]},"ApiClientResponse":{"properties":{"id":{"type":"string","title":"Id"},"client_id":{"type":"string","title":"Client Id","description":"Put this in iss and sub of assertions"},"name":{"type":"string","title":"Name"},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description"},"status":{"type":"string","enum":["active","disabled"],"title":"Status"},"scopes":{"items":{"type":"string"},"type":"array","title":"Scopes"},"allowed_ips":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Allowed Ips"},"rate_limit_per_minute":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Rate Limit Per Minute"},"token_ttl_seconds":{"type":"integer","title":"Token Ttl Seconds"},"jwks":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Jwks","description":"Registered public keys"},"key_ids":{"items":{"type":"string"},"type":"array","title":"Key Ids"},"require_mtls":{"type":"boolean","title":"Require Mtls"},"mtls_cert_thumbprints":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Mtls Cert Thumbprints"},"require_signed_requests":{"type":"boolean","title":"Require Signed Requests"},"signing_keys":{"items":{"$ref":"#/components/schemas/ApiClientSigningKeyResponse"},"type":"array","title":"Signing Keys"},"active_token_count":{"type":"integer","title":"Active Token Count","description":"Unexpired, unrevoked access tokens issued to the client","default":0},"last_token_issued_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Last Token Issued At"},"disabled_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Disabled At"},"created_at":{"type":"string","format":"date-time","title":"Created At"},"updated_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Updated At"},"mtls_available":{"type":"boolean","title":"Mtls Available","description":"Whether this environment forwards client certificates. When false, require_mtls cannot be turned on."}},"type":"object","required":["id","client_id","name","status","scopes","token_ttl_seconds","require_mtls","require_signed_requests","created_at","mtls_available"],"title":"ApiClientResponse","description":"An API client's settings. Contains no secrets."},"ApiClientSigningKeyResponse":{"properties":{"kid":{"type":"string","title":"Kid"},"alg":{"type":"string","title":"Alg"},"public_key":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Public Key","description":"Ed25519 public key (base64); null for HMAC keys"},"created_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Created At"},"retired_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Retired At","description":"When the key stops verifying requests"},"status":{"type":"string","enum":["active","retiring","retired"],"title":"Status"}},"type":"object","required":["kid","alg","status"],"title":"ApiClientSigningKeyResponse","description":"A signing key as the owner sees it: never the secret."},"SuccessEnvelope_ApiClientResponse_":{"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/ApiClientResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[ApiClientResponse]"},"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":[]}]}