Skip to content

docs: add Credits API endpoint and documentation#152

Open
ahmednahima0-beep wants to merge 2 commits intorecoupable:mainfrom
ahmednahima0-beep:feat/migrate-get-credits
Open

docs: add Credits API endpoint and documentation#152
ahmednahima0-beep wants to merge 2 commits intorecoupable:mainfrom
ahmednahima0-beep:feat/migrate-get-credits

Conversation

@ahmednahima0-beep
Copy link
Copy Markdown
Collaborator

@ahmednahima0-beep ahmednahima0-beep commented Apr 21, 2026

  • Introduced a new API endpoint to retrieve the current credit balance for an account at /api/credits.
  • Updated the OpenAPI specification to include detailed descriptions, parameters, and response schemas for the new endpoint.
  • Added corresponding documentation in MDX format for the Credits API, enhancing the overall API reference.

Summary by cubic

Adds the Credits API to fetch an account’s current credit balance at /api/credits. Updates OpenAPI and docs with auth, parameters, responses, and clarified errors.

  • New Features
    • OpenAPI: GET /api/credits with optional accountId, apiKeyAuth/bearerAuth, and 200/400/401/403/404; 400 now explicitly covers invalid accountId; includes monthly reset rules and free/pro allowances.
    • Adds CreditsResponse schema (id, account_id, remaining_credits, timestamp), with timestamp allowed as string or null.
    • New docs page api-reference/credits/get.mdx and navigation entry in docs.json.

Written for commit 9d18760. Summary will update on new commits.

Summary by CodeRabbit

  • New Features

    • New API endpoint to retrieve your account's current credit balance, with optional override parameters for organization members
  • Documentation

    • Added API reference documentation for the new credits endpoint

- Introduced a new API endpoint to retrieve the current credit balance for an account at `/api/credits`.
- Updated the OpenAPI specification to include detailed descriptions, parameters, and response schemas for the new endpoint.
- Added corresponding documentation in MDX format for the Credits API, enhancing the overall API reference.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 14f0eff6-d1f2-4a60-883a-45d641826fee

📥 Commits

Reviewing files that changed from the base of the PR and between ea3c08a and 9d18760.

📒 Files selected for processing (3)
  • api-reference/credits/get.mdx
  • api-reference/openapi/accounts.json
  • docs.json

📝 Walkthrough

Walkthrough

This PR introduces a new "Get Credits" API endpoint to retrieve account credit balances. Changes include the OpenAPI endpoint definition with query parameters and response schemas, accompanying API reference documentation, and navigation structure updates.

Changes

Cohort / File(s) Summary
OpenAPI Endpoint Definition
api-reference/openapi/accounts.json
Added authenticated GET /api/credits endpoint with optional accountId query parameter. Defines CreditsResponse schema with fields: id, account_id, remaining_credits (required), and timestamp (optional, nullable). Includes error responses for 400/401/403/404.
Documentation and Navigation
api-reference/credits/get.mdx, docs.json
Added MDX page for API reference documentation and registered new "Credits" navigation group under Accounts tab.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A new endpoint hops into view,
Credits counted, fresh and true,
The API docs now shiny new,
Balance queries just for you! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding a Credits API endpoint and corresponding documentation across OpenAPI spec, MDX documentation page, and navigation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="api-reference/openapi/accounts.json">

<violation number="1" location="api-reference/openapi/accounts.json:441">
P2: `CreditsResponse.timestamp` uses `nullable: true` in an OpenAPI 3.1 spec; use JSON Schema null type union to ensure nullability is honored by 3.1 tooling.</violation>

<violation number="2" location="api-reference/openapi/accounts.json:458">
P2: `/api/credits` documents `accountId` as optional but its 400 description says missing `accountId` is an error, creating a contradictory API contract.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread api-reference/openapi/accounts.json Outdated
Comment thread api-reference/openapi/accounts.json
- Modified the error description for the 400 response to clarify that it refers to an invalid `accountId`.
- Changed the `timestamp` field type to allow for both string and null values, enhancing flexibility in the API response.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant