docs(subscriptions): POST /api/subscriptions/card-on-file ($0 setup-mode session) - #280
Conversation
…ode session) Documents the card-on-file endpoint that exposes the existing createCardOnFileSession helper over HTTP: a Stripe `mode: "setup"` checkout session that saves a payment method for the authenticated account without charging anything or starting a subscription. - adds the `/api/subscriptions/card-on-file` path to the accounts OpenAPI spec, mirroring `/api/subscriptions/sessions` and reusing its CreateSubscriptionSessionResponse and SubscriptionSessionErrorResponse schemas - adds a CreateCardOnFileSessionRequest schema: `successUrl` only, since the route resolves the account from the credentials and never accepts `accountId` from the caller - adds the frontmatter-only reference page and registers it in the Billing group of docs.json so it lands in llms.txt Part of recoupable/chat#1910 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
📝 WalkthroughWalkthroughThe API documentation adds a card-on-file session endpoint, its required success URL request schema, a dedicated reference page, and a Billing navigation entry. ChangesCard-on-file API
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@api-reference/openapi/accounts.json`:
- Around line 816-825: Update the description of the shared
CreateSubscriptionSessionResponse.url field to use payment-neutral wording,
replacing language that instructs callers to complete a payment with wording
that instructs them to complete Checkout. Keep the schema reference and endpoint
response structure unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 9fb01d06-9c31-4d1c-b746-ddafa1d943d8
📒 Files selected for processing (3)
api-reference/openapi/accounts.jsonapi-reference/subscriptions/card-on-file-create.mdxdocs.json
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
The card-on-file endpoint reuses CreateSubscriptionSessionResponse, whose `url` said "complete the payment" — contradictory for a $0 setup session. Generalized to "complete Checkout", which is accurate for both endpoints. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
| }, | ||
| "/api/subscriptions/card-on-file": { | ||
| "post": { | ||
| "description": "Create a $0 card-on-file checkout session for the authenticated account. The session runs in Stripe `setup` mode: it saves a payment method against the account's Stripe customer without charging anything today and without starting a subscription. Use it so an account that later runs out of credits can be auto-recharged instead of dead-ending. The account is always resolved from the credentials; `accountId` is never accepted from the caller. Returns a hosted checkout URL that the client should redirect to.", |
There was a problem hiding this comment.
KISS
- actual: 4+ sentences.
- required: 2-3 sentences. Concise.
There was a problem hiding this comment.
Fixed in 3a95ee8: cut from 5 sentences to 3 (324 chars), calibrated against the sibling subscriptions/sessions description (3 sentences / 204 chars) rather than an arbitrary target. Dropped the accountId-is-never-accepted restatement (the Authorizations section already covers it, and the sibling does not repeat it) and folded the "use it so..." sentence into the setup-mode one. Rendered result verified locally, screenshots in the verification comment.
…xamples Review feedback: the endpoint description ran to five sentences. Cut to three, matching the terseness of the sibling subscriptions/sessions entry. Also add per-response examples for 400, 401 and 500. The shared error schema carries a single field-level example, so every status tab rendered the same 400-style message; the 401 tab claimed "successUrl is required" for what is actually an auth failure. Each example is now the string the route really returns, captured from the api preview. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Local verification (Mintlify dev server)Ran Your review note: description was 5 sentencesFixed. Cut to 3, calibrated against the nearest sibling (
What was cut: the sentence restating that Found while testing: every error tab showed the same 400 messageThe shared Fixed by adding per-response examples on this endpoint's 400/401/500. Each string is what the route actually returns, captured by probing the api preview from api#797 rather than invented:
Left the shared schema untouched on purpose, so this does not change how the sibling endpoint renders. Note for a follow-up: Results
Screenshots1. Endpoint page as rendered 2. Request body and 200 response schema 3. The bug: 401 tab showing a 400 message 4. After the fix: 3-sentence description, and 401 showing the real auth error Two notes on method
Part of recoupable/chat#1910. Merge order unchanged: this PR, then api#797, then marketing#60. |




Documents
POST /api/subscriptions/card-on-fileahead of the api implementation, so the route ships against a published contract.The endpoint exposes the existing
api/lib/stripe/createCardOnFileSession.tshelper over HTTP: a Stripemode: "setup"checkout session that saves a payment method against the account's Stripe customer with no charge today and no subscription. It is what lets an account that later hits zero credits be auto-recharged instead of dead-ending.Contract
POST /api/subscriptions/card-on-filex-api-key(same asPOST /api/subscriptions/sessions){ "successUrl": "https://..." }— required, must be a valid URL{ "id": "cs_...", "url": "https://checkout.stripe.com/..." }(flat, nodatawrapper)The account is always resolved from the credentials.
accountIdis never accepted from the caller, which is why this endpoint gets its ownCreateCardOnFileSessionRequestschema (successUrlonly) rather than reusingCreateSubscriptionSessionRequest. The response and error envelopes are reused from the sessions endpoint unchanged.Changes
api-reference/openapi/accounts.json— new/api/subscriptions/card-on-filepath plus theCreateCardOnFileSessionRequestschema; additive edits only, spec re-validated as parseable JSONapi-reference/subscriptions/card-on-file-create.mdx— frontmatter-only reference pagedocs.json— registered in the Accounts > Billing group so the page lands inllms.txtMerge order
Merge this before the api PR that implements the route (linked from that PR).
Part of recoupable/chat#1910
🤖 Generated with Claude Code
Summary by cubic
Documents
POST /api/subscriptions/card-on-file, a $0 Stripe setup-mode Checkout session that saves a card for the authenticated account. Sets the public contract ahead of the API so apps can integrate; aligns withrecoupable/chat#1910.New Features
/api/subscriptions/card-on-fileandCreateCardOnFileSessionRequest(successUrlonly); reusesCreateSubscriptionSessionResponseandSubscriptionSessionErrorResponse.bearerAuth(Privy) orapiKeyAuth; account is derived from credentials (noaccountId).Bug Fixes
CreateSubscriptionSessionResponse.urldescription payment-neutral (“complete Checkout”).Written for commit 3a95ee8. Summary will update on new commits.
Summary by CodeRabbit
New Features
Documentation