Skip to content

feat(usage): add GET /usage endpoint for account-level usage data - #146

Merged
kewynakshlley merged 2 commits into
mainfrom
feat/usage-endpoint
Sep 27, 2026
Merged

kewynakshlley merged 2 commits into
mainfrom
feat/usage-endpoint

Conversation

@dielduarte

@dielduarte dielduarte commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Adds a Usage service exposing resend.usage().get(), for account-level usage/quotas (emails, contacts, segments, broadcasts, AI credits, automation runs, domains, rate limit).
  • Live-tested against two real accounts — correct, distinct data returned for each, matching the spec exactly.

Part of the /usage GA rollout (DEV-2183). Reference implementation: resend-node#1111.


Summary by cubic

Adds a Usage service exposing resend.usage().get() so callers can retrieve account-level usage and quota data as part of the /usage GA rollout (DEV-2183).

  • Returns email, contacts, segments, broadcasts, AI credits, automation runs, domains, and rate limit usage in dedicated model classes.
  • Adds unit tests covering a successful response and API error handling, including reset timestamps and monthly sent/received counts.

Written for commit 48e3cb9. Summary will update on new commits.

Review in cubic

Adds Usage service exposing resend.usage().get(), returning email,
contacts, segments, broadcasts, AI credits, automation runs, domains
and rate limit quotas.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 10 files

Confidence score: 4/5

  • In src/main/java/com/resend/services/usage/Usage.java, Usage.get() may fail for production keys if they lack permission to access /usage; verify existing key permissions before relying on this SDK method.
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="src/main/java/com/resend/services/usage/Usage.java">

<violation number="1" location="src/main/java/com/resend/services/usage/Usage.java:36">
P2: Custom agent: **API Key Permission Check SDK Methods**

`Usage.get()` adds a new account-level operation, but the change does not confirm that production keys can access `/usage`; verify existing keys have the required permission or Full access before release to avoid authorization failures.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread src/main/java/com/resend/services/usage/model/UsageResponse.java
Comment thread src/main/java/com/resend/services/usage/Usage.java
Comment thread src/test/java/com/resend/services/usage/UsageTest.java
…xture typo

- Fixes a used/sent+received mismatch in the monthly fixture (5422 -> 5442).
- Adds assertions for daily/monthly/automation_runs resets_at and
  monthly sent/received, which were previously unasserted.

@klotty klotty left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

0 issues found across 1 file (changes from recent commits).

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: Adds a read-only GET /usage client method and its response models for account usage/quota data, with unit tests covering success and API-error paths. The change is purely additive and bounded.

Re-trigger cubic

@dielduarte
dielduarte marked this pull request as ready for review September 25, 2026 18:11
@github-actions github-actions Bot added the linear-synced PR has been synced to Linear label Sep 26, 2026
@kewynakshlley
kewynakshlley merged commit b661d7a into main Sep 27, 2026
4 checks passed
@kewynakshlley
kewynakshlley deleted the feat/usage-endpoint branch September 27, 2026 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

linear-synced PR has been synced to Linear

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants