Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(data-warehouse): add resend usage table (#126972)

Tom Owers0af498b61fa9
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
index 23e81aa1487a..298f8645b77a 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
@@ -10220,13 +10220,14 @@ Diffed against: <https://docs.reply.io/llms.txt>
## Resend — gaps
-Today (8): `audiences`, `broadcast_clicked_links`, `broadcasts`, `contacts`, `domains`, `email_metrics`, `emails`, `suppressions`
+Today (9): `audiences`, `broadcast_clicked_links`, `broadcasts`, `contacts`, `domains`, `email_metrics`, `emails`, `suppressions`, `usage`
Diffed against: <https://resend.com/docs/llms.txt>
- [x] `/suppressions` — suppressed recipients with their origin (bounce, complaint, manual), which explain delivery gaps (medium) — synced as `suppressions`
- [x] `/emails/metrics` — the account's delivery and engagement metrics per day, the headline numbers for sending health (high) — synced as `email_metrics`
- [x] `/broadcasts/{broadcast_id}/clicked-links` — per-link click counts for each broadcast (medium) — synced as `broadcast_clicked_links`
+- [x] `/usage` — the account's current usage against its plan limits for emails, contacts, segments, broadcasts, domains, and the API rate limit (medium) — synced as `usage`
## Retell AI — gaps
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/resend/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/resend/canonical_descriptions.py
index 9adcbf461046..7718f1223d7a 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/resend/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/resend/canonical_descriptions.py
@@ -129,4 +129,26 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"_broadcast_id": "ID of the broadcast the link belongs to.",
},
},
+ "usage": {
+ "description": "A snapshot of the account's current usage and plan limits. The table holds one row.",
+ "docs_url": "https://resend.com/docs/api-reference/usage/retrieve-usage",
+ "columns": {
+ "object": "Always `usage`.",
+ "emails": (
+ "Email sending and receiving quota. `daily` is a rolling 24-hour quota and `monthly` a "
+ "calendar-month quota, each with used, limit, sent, received, and resets_at. The daily "
+ "limit is null on paid sending plans."
+ ),
+ "contacts": "Contacts used and the plan limit.",
+ "segments": "Segments used and the plan limit. The limit is null on paid contacts plans.",
+ "broadcasts": "Broadcasts used. The limit is always null because broadcasts have no cap.",
+ "ai_credits": (
+ "AI credits used, the limit, and next_increase_at: when the oldest use leaves the rolling "
+ "window and frees quota."
+ ),
+ "automation_runs": "Automation runs used, the limit, and when the count resets.",
+ "domains": "Domains used and the plan limit. The limit is null when the plan has no domain cap.",
+ "rate_limit": "The account's API rate limit: the request limit and its window duration, such as 1000ms.",
+ },
+ },
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/resend/resend.py b/products/warehouse_sources/backend/temporal/data_imports/sources/resend/resend.py
index 74b981db3785..e44b8cebb099 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/resend/resend.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/resend/resend.py
@@ -131,7 +131,7 @@ def _simple_resource(
"paginator": _paginator(config),
# A missing `data` key yields a zero-row page (the API returns {"data": [...]}); tolerant,
# matching the previous implementation's `data.get("data") or []`.
- "data_selector": "data",
+ "data_selector": config.data_selector,
}
rest_config: RESTAPIConfig = {
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/resend/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/resend/settings.py
index eeacf071bfab..782dab98c2b4 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/resend/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/resend/settings.py
@@ -15,6 +15,8 @@ class ResendEndpointConfig:
page_size: Optional[int] = None
# Static query params sent on every request.
params: dict[str, Any] = field(default_factory=dict)
+ # Path to the rows in the response body. `$` takes the whole body as one row.
+ data_selector: str = "data"
# For fan-out endpoints like `contacts`, names the parent endpoint we iterate to
# resolve the path parameter, and the path parameter the parent id fills.
parent: Optional[str] = None
@@ -77,6 +79,14 @@ RESEND_ENDPOINTS: dict[str, ResendEndpointConfig] = {
resolve_param="broadcast_id",
ignore_child_404=True,
),
+ # A single snapshot of the account's current usage and plan limits. The body has no id, and
+ # `object` is always "usage", so it keys the one row.
+ "usage": ResendEndpointConfig(
+ name="usage",
+ path="/usage",
+ primary_keys=["object"],
+ data_selector="$",
+ ),
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/resend/tests/test_resend.py b/products/warehouse_sources/backend/temporal/data_imports/sources/resend/tests/test_resend.py
index c893c9749a4a..76ce75b7edf9 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/resend/tests/test_resend.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/resend/tests/test_resend.py
@@ -159,6 +159,20 @@ class TestEmailMetrics:
}
+class TestUsage:
+ def test_yields_the_snapshot_object_as_one_row(self) -> None:
+ body = {
+ "object": "usage",
+ "emails": {"daily": {"used": 10, "limit": None}, "monthly": {"used": 100, "limit": 3000}},
+ "domains": {"used": 1, "limit": 1},
+ "rate_limit": {"limit": 1000, "duration": "1000ms"},
+ }
+ result = _driver().run("usage", [_page(body)])
+
+ assert result.rows == [body]
+ assert result.paths == ["/usage"]
+
+
class TestRetryable:
def test_401_does_not_retry_and_raises(self) -> None:
result = _driver().run("audiences", [_page({"message": "unauthorized"}, status_code=401)])