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 OAuth support to Resend source (#73107)

Tom Owers308167d47c36
diff --git a/posthog/migrations/1263_alter_integration_kind.py b/posthog/migrations/1263_alter_integration_kind.py
new file mode 100644
index 000000000000..5b667ce56509
--- /dev/null
+++ b/posthog/migrations/1263_alter_integration_kind.py
@@ -0,0 +1,62 @@
+# Generated by Django 5.2.14 on 2026-07-23 09:19
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("posthog", "1262_organization_members_can_see_org_members"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="integration",
+ name="kind",
+ field=models.CharField(
+ choices=[
+ ("anthropic", "Anthropic"),
+ ("apns", "Apple Push"),
+ ("aws-s3", "Aws S3"),
+ ("azure-blob", "Azure Blob"),
+ ("bing-ads", "Bing Ads"),
+ ("clickup", "Clickup"),
+ ("customerio-app", "Customerio App"),
+ ("customerio-track", "Customerio Track"),
+ ("customerio-webhook", "Customerio Webhook"),
+ ("databricks", "Databricks"),
+ ("email", "Email"),
+ ("firebase", "Firebase"),
+ ("github", "Github"),
+ ("gitlab", "Gitlab"),
+ ("google-ads", "Google Ads"),
+ ("google-analytics", "Google Analytics"),
+ ("google-cloud-service-account", "Google Cloud Service Account"),
+ ("google-cloud-storage", "Google Cloud Storage"),
+ ("google-pubsub", "Google Pubsub"),
+ ("google-search-console", "Google Search Console"),
+ ("google-sheets", "Google Sheets"),
+ ("hubspot", "Hubspot"),
+ ("intercom", "Intercom"),
+ ("jira", "Jira"),
+ ("linear", "Linear"),
+ ("linkedin-ads", "Linkedin Ads"),
+ ("meta-ads", "Meta Ads"),
+ ("pinterest-ads", "Pinterest Ads"),
+ ("postgresql", "Postgresql"),
+ ("reddit-ads", "Reddit Ads"),
+ ("resend", "Resend"),
+ ("s3-compatible", "S3 Compatible"),
+ ("salesforce", "Salesforce"),
+ ("slack", "Slack"),
+ ("slack-posthog-code", "Slack Posthog Code"),
+ ("snapchat", "Snapchat"),
+ ("snowflake", "Snowflake"),
+ ("stripe", "Stripe"),
+ ("tiktok-ads", "Tiktok Ads"),
+ ("twilio", "Twilio"),
+ ("vercel", "Vercel"),
+ ],
+ max_length=32,
+ ),
+ ),
+ ]
diff --git a/posthog/migrations/max_migration.txt b/posthog/migrations/max_migration.txt
index c648fb0c5913..169d768696cd 100644
--- a/posthog/migrations/max_migration.txt
+++ b/posthog/migrations/max_migration.txt
@@ -1 +1 @@
-1262_organization_members_can_see_org_members
+1263_alter_integration_kind
diff --git a/posthog/models/integration.py b/posthog/models/integration.py
index d93a5c860fae..727855d6cc6e 100644
--- a/posthog/models/integration.py
+++ b/posthog/models/integration.py
@@ -347,6 +347,7 @@ class Integration(models.Model):
PINTEREST_ADS = "pinterest-ads"
POSTGRESQL = "postgresql"
REDDIT_ADS = "reddit-ads"
+ RESEND = "resend"
S3_COMPATIBLE = "s3-compatible"
SALESFORCE = "salesforce"
SLACK = "slack"
@@ -550,6 +551,7 @@ class OauthIntegration:
"jira",
"pinterest-ads",
"stripe",
+ "resend",
]
integration: Integration
@@ -900,6 +902,28 @@ class OauthIntegration:
id_path="stripe_user_id",
name_path="account_name",
)
+ elif kind == "resend":
+ if not settings.RESEND_APP_CLIENT_ID or not settings.RESEND_APP_CLIENT_SECRET:
+ raise NotImplementedError("Resend app not configured")
+
+ # Resend implements OAuth 2.1: PKCE is required, and access tokens are short-lived
+ # (~15m) JWTs while refresh tokens rotate on every use. We register as a confidential
+ # client (token_endpoint_auth_method=client_secret_post), so the standard client_secret
+ # token-exchange/refresh path applies on top of PKCE. `full_access` is the scope needed
+ # to read the warehouse resources (emails/audiences/contacts/domains/broadcasts).
+ # The token response carries no account identifier, so id/name are derived from the
+ # access-token JWT below (see the resend branch in integration_from_oauth_response).
+ return OauthConfig(
+ authorize_url="https://resend.com/oauth/authorize",
+ token_url="https://api.resend.com/oauth/token",
+ token_revoke_url="https://api.resend.com/oauth/revoke",
+ client_id=settings.RESEND_APP_CLIENT_ID,
+ client_secret=settings.RESEND_APP_CLIENT_SECRET,
+ scope="full_access",
+ pkce=True,
+ id_path="resend_account_id",
+ name_path="resend_account_name",
+ )
raise NotImplementedError(f"Oauth config for kind {kind} not implemented")
@@ -1027,6 +1051,9 @@ class OauthIntegration:
**({"code_verifier": code_verifier} if code_verifier else {}),
},
timeout=10,
+ # allow_redirects=False so a misconfigured/compromised token endpoint can't 30x us
+ # into resending client_secret + authorization code to another origin.
+ allow_redirects=False,
)
try:
@@ -1165,6 +1192,29 @@ class OauthIntegration:
except Exception as e:
logger.exception("Failed to decode Reddit JWT", error=str(e))
+ # Resend's token response carries no account identifier, but the access token is a JWT.
+ # Derive the integration id/name from its claims (`sub` is the account subject; email/name
+ # are used for a human-readable label when present). Assumes the standard `sub` claim — if
+ # Resend uses a different claim, the missing-id guard below raises and the user sees a clear
+ # reconnect error rather than a silently mislabeled integration.
+ if kind == "resend" and not integration_id:
+ try:
+ access_token = config.get("access_token")
+ if access_token:
+ jwt_data = _decode_jwt_payload(access_token)
+ if jwt_data:
+ resend_account_id = jwt_data.get("sub")
+ if resend_account_id:
+ config["resend_account_id"] = resend_account_id
+ config["resend_account_name"] = (
+ jwt_data.get("email") or jwt_data.get("name") or f"Resend account {resend_account_id}"
+ )
+ integration_id = resend_account_id
+ else:
+ logger.error("Resend OAuth response missing access_token", config_keys=list(config.keys()))
+ except Exception:
+ logger.exception("Failed to decode Resend JWT")
+
# LinkedIn id_token is a JWT, extract user ID and email from it
# This avoids calling /v2/userinfo which has intermittent REVOKED_ACCESS_TOKEN errors
if kind == "linkedin-ads" and not integration_id:
@@ -1301,9 +1351,10 @@ class OauthIntegration:
if not oauth_config.token_revoke_url:
return
- token = self.integration.sensitive_config.get("refresh_token") or self.integration.sensitive_config.get(
- "access_token"
- )
+ # Prefer the refresh token: revoking it invalidates the whole grant (and its access
+ # tokens), so an attacker holding it can't keep minting access tokens after disconnect.
+ refresh_token = self.integration.sensitive_config.get("refresh_token")
+ token = refresh_token or self.integration.sensitive_config.get("access_token")
if not token:
return
@@ -1317,12 +1368,22 @@ class OauthIntegration:
if allowed_host:
revoke_url = f"{allowed_host}/services/oauth2/revoke"
+ data = {"token": token}
+ if self.integration.kind == "resend":
+ # Resend registers PostHog as a confidential client (token_endpoint_auth_method=
+ # client_secret_post) and requires client authentication on revocation. Without it
+ # the endpoint rejects the request and the grant survives the disconnect. The hint
+ # tells the provider which token type it received (RFC 7009).
+ data["client_id"] = oauth_config.client_id
+ data["client_secret"] = oauth_config.client_secret
+ data["token_type_hint"] = "refresh_token" if refresh_token else "access_token"
+
# allow_redirects=False so a misconfigured/compromised provider can't 30x us into
# resending the token to another host. raise_for_status surfaces a provider rejection
# to the caller's capture_exception instead of it passing silently as a revoke.
response = requests.post(
revoke_url,
- data={"token": token},
+ data=data,
timeout=10,
allow_redirects=False,
)
diff --git a/posthog/models/test/test_integration_model.py b/posthog/models/test/test_integration_model.py
index 9f111cc5928e..1cab61dc2902 100644
--- a/posthog/models/test/test_integration_model.py
+++ b/posthog/models/test/test_integration_model.py
@@ -1,3 +1,4 @@
+import json
import time
import base64
import hashlib
@@ -3866,3 +3867,129 @@ class TestPostgreSQLIntegrationModel(BaseTest):
assert "password" not in integration.config
assert integration.sensitive_config["password"] == "super-secret"
+
+
+def _make_resend_jwt(payload: dict) -> str:
+ body = base64.urlsafe_b64encode(json.dumps(payload).encode()).rstrip(b"=").decode()
+ return f"header.{body}.signature"
+
+
+@override_settings(RESEND_APP_CLIENT_ID="resend-client-id", RESEND_APP_CLIENT_SECRET="resend-client-secret")
+class TestResendIntegrationModel(BaseTest):
+ def test_oauth_config(self):
+ config = OauthIntegration.oauth_config_for_kind("resend")
+ assert config.authorize_url == "https://resend.com/oauth/authorize"
+ assert config.token_url == "https://api.resend.com/oauth/token"
+ assert config.token_revoke_url == "https://api.resend.com/oauth/revoke"
+ assert config.client_id == "resend-client-id"
+ assert config.client_secret == "resend-client-secret"
+ assert config.scope == "full_access"
+ assert config.pkce is True
+ assert config.id_path == "resend_account_id"
+
+ @override_settings(RESEND_APP_CLIENT_ID="", RESEND_APP_CLIENT_SECRET="")
+ def test_oauth_config_unconfigured_raises(self):
+ with pytest.raises(NotImplementedError, match="Resend app not configured"):
+ OauthIntegration.oauth_config_for_kind("resend")
+
+ @patch("posthog.models.integration.requests.post")
+ def test_integration_from_oauth_response_extracts_account_from_jwt(self, mock_post):
+ access_token = _make_resend_jwt({"sub": "acct_123", "email": "[email protected]"})
+ mock_post.return_value.status_code = 200
+ mock_post.return_value.json.return_value = {
+ "access_token": access_token,
+ "refresh_token": "rt_1",
+ "expires_in": 900,
+ "token_type": "Bearer",
+ }
+
+ with freeze_time("2024-01-01T12:00:00Z"):
+ integration = OauthIntegration.integration_from_oauth_response(
+ "resend",
+ self.team.id,
+ self.user,
+ {"code": "code", "state": "token=state_token"},
+ )
+
+ assert integration.kind == "resend"
+ assert integration.integration_id == "acct_123"
+ assert integration.config["resend_account_id"] == "acct_123"
+ assert integration.config["resend_account_name"] == "[email protected]"
+ assert integration.config["expires_in"] == 900
+ assert integration.sensitive_config["access_token"] == access_token
+ assert integration.sensitive_config["refresh_token"] == "rt_1"
+
+ @patch("posthog.models.integration.requests.post")
+ def test_integration_from_oauth_response_name_falls_back_without_email(self, mock_post):
+ access_token = _make_resend_jwt({"sub": "acct_xyz"})
+ mock_post.return_value.status_code = 200
+ mock_post.return_value.json.return_value = {
+ "access_token": access_token,
+ "refresh_token": "rt",
+ "expires_in": 900,
+ }
+
+ integration = OauthIntegration.integration_from_oauth_response(
+ "resend",
+ self.team.id,
+ self.user,
+ {"code": "code", "state": "token=state_token"},
+ )
+
+ assert integration.integration_id == "acct_xyz"
+ assert integration.config["resend_account_name"] == "Resend account acct_xyz"
+
+ @patch("posthog.models.integration.requests.post")
+ def test_integration_from_oauth_response_without_sub_raises(self, mock_post):
+ access_token = _make_resend_jwt({"email": "[email protected]"})
+ mock_post.return_value.status_code = 200
+ mock_post.return_value.json.return_value = {
+ "access_token": access_token,
+ "refresh_token": "rt",
+ "expires_in": 900,
+ }
+
+ with pytest.raises(Exception, match="failed to extract integration ID"):
+ OauthIntegration.integration_from_oauth_response(
+ "resend",
+ self.team.id,
+ self.user,
+ {"code": "code", "state": "token=state_token"},
+ )
+
+ @patch("posthog.models.integration.requests.post")
+ def test_authorization_code_exchange_does_not_follow_redirects(self, mock_post):
+ # A 307/308 from the token endpoint must not forward client_secret + code to its Location.
+ access_token = _make_resend_jwt({"sub": "acct_1"})
+ mock_post.return_value.status_code = 200
+ mock_post.return_value.json.return_value = {
+ "access_token": access_token,
+ "refresh_token": "rt",
+ "expires_in": 900,
+ }
+
+ OauthIntegration.integration_from_oauth_response(
+ "resend",
+ self.team.id,
+ self.user,
+ {"code": "code", "state": "token=state_token"},
+ )
+
+ assert mock_post.call_args.kwargs["allow_redirects"] is False
+
+ @patch("posthog.models.integration.requests.post")
+ def test_revoke_token_authenticates_with_client_credentials(self, mock_post):
+ integration = Integration.objects.create(
+ team=self.team,
+ kind="resend",
+ config={"resend_account_id": "acct_1"},
+ sensitive_config={"refresh_token": "rt_secret", "access_token": "at_secret"},
+ )
+
+ OauthIntegration(integration).revoke_token()
+
+ sent = mock_post.call_args.kwargs["data"]
+ assert sent["token"] == "rt_secret"
+ assert sent["client_id"] == "resend-client-id"
+ assert sent["client_secret"] == "resend-client-secret"
+ assert sent["token_type_hint"] == "refresh_token"
diff --git a/posthog/settings/integrations.py b/posthog/settings/integrations.py
index 7f9b042b5dff..457caa991a62 100644
--- a/posthog/settings/integrations.py
+++ b/posthog/settings/integrations.py
@@ -9,6 +9,12 @@ SNAPCHAT_APP_CLIENT_SECRET = get_from_env("SNAPCHAT_APP_CLIENT_SECRET", "")
INTERCOM_APP_CLIENT_ID = get_from_env("INTERCOM_APP_CLIENT_ID", "")
INTERCOM_APP_CLIENT_SECRET = get_from_env("INTERCOM_APP_CLIENT_SECRET", "")
+# Resend registers a confidential OAuth client (token_endpoint_auth_method=client_secret_post) via
+# its dynamic client registration API (POST https://api.resend.com/oauth/register). Empty defaults
+# keep the app importable and the OAuth auth method dormant until the client is provisioned.
+RESEND_APP_CLIENT_ID = get_from_env("RESEND_APP_CLIENT_ID", "")
+RESEND_APP_CLIENT_SECRET = get_from_env("RESEND_APP_CLIENT_SECRET", "")
+
SALESFORCE_CONSUMER_KEY = get_from_env("SALESFORCE_CONSUMER_KEY", "")
SALESFORCE_CONSUMER_SECRET = get_from_env("SALESFORCE_CONSUMER_SECRET", "")
diff --git a/posthog/tasks/integrations.py b/posthog/tasks/integrations.py
index c5e861485d05..fbcc6062d551 100644
--- a/posthog/tasks/integrations.py
+++ b/posthog/tasks/integrations.py
@@ -18,8 +18,15 @@ from products.workflows.backend.providers import SESProvider
def refresh_integrations() -> int:
from posthog.models.integration import Integration, OauthIntegration
+ # Resend is excluded: its refresh token is single-use and rotates on every refresh, with
+ # reuse-detection that revokes the whole grant if a rotated token is spent twice. Resend
+ # refreshes are minted on demand under a Postgres row lock by the sync path
+ # (resolve_resend_oauth_token). This unlocked periodic sweep would race that path and
+ # double-spend the rotating token, so it must not refresh Resend.
oauth_integrations = defer_repository_cache_fields(
- Integration.objects.filter(kind__in=OauthIntegration.supported_kinds).exclude(kind="meta-ads").all()
+ Integration.objects.filter(kind__in=OauthIntegration.supported_kinds)
+ .exclude(kind__in=["meta-ads", "resend"])
+ .all()
)
for integration in oauth_integrations:
@@ -72,6 +79,12 @@ def refresh_integration(id: int) -> int:
# Re-check freshness against the just-loaded row before minting. Under an INTEGRATIONS queue
# backlog several duplicate refreshes can pile up for the same row; the first mints a fresh token
# and this keeps the rest from re-minting one that's already valid.
+ # Resend is deliberately not refreshed here (see refresh_integrations): its rotating single-use
+ # refresh token must only ever be spent under the sync path's row lock. Skip it even if an
+ # in-flight task from before this guard was deployed still targets a Resend row.
+ if integration.kind == "resend":
+ return 0
+
if integration.kind in OauthIntegration.supported_kinds:
oauth_integration = OauthIntegration(integration)
if oauth_integration.access_token_expired():
diff --git a/posthog/tasks/test/test_integrations.py b/posthog/tasks/test/test_integrations.py
index f3fe8e4346c0..487df83eefbe 100644
--- a/posthog/tasks/test/test_integrations.py
+++ b/posthog/tasks/test/test_integrations.py
@@ -39,6 +39,28 @@ class TestIntegrationsTasks(APIBaseTest):
# Both 3 and 4 should be refreshed
assert refresh_integration_mock.call_args_list == [((integration_3.id,),), ((integration_4.id,),)]
+ def test_refresh_integrations_excludes_resend(self) -> None:
+ # Resend's refresh token is single-use and rotates on every refresh; the periodic sweep is
+ # unlocked and would race the row-locked sync-path refresh, double-spending the token and
+ # revoking the grant. An expired Resend row must never be enqueued here.
+ self.create_integration("resend", config={"refreshed_at": time.time() - 3600})
+ eligible = self.create_integration("slack", config={"refreshed_at": time.time() - 3600})
+
+ with patch("posthog.tasks.integrations.refresh_integration.delay") as refresh_integration_mock:
+ refresh_integrations()
+
+ assert refresh_integration_mock.call_args_list == [((eligible.id,),)]
+
+ def test_refresh_integration_skips_resend(self) -> None:
+ # Defense in depth for a task enqueued before the sweep exclusion shipped: even if a Resend
+ # id reaches refresh_integration, it must not spend the rotating token via the unlocked path.
+ integration = self.create_integration("resend", config={"refreshed_at": time.time() - 3600})
+
+ with patch("posthog.models.integration.OauthIntegration.refresh_access_token") as refresh_mock:
+ refresh_integration(integration.id)
+
+ assert refresh_mock.called is False
+
def test_refresh_integrations_skips_backed_off_and_terminal(self) -> None:
expired = {"refreshed_at": time.time() - 3600}
eligible = self.create_integration("slack", config=expired)
diff --git a/products/integrations/frontend/generated/api.schemas.ts b/products/integrations/frontend/generated/api.schemas.ts
index a3ef263f2ec8..a1befda4eb29 100644
--- a/products/integrations/frontend/generated/api.schemas.ts
+++ b/products/integrations/frontend/generated/api.schemas.ts
@@ -179,6 +179,7 @@ export interface RoleLookupResponseApi {
* * `pinterest-ads` - Pinterest Ads
* * `postgresql` - Postgresql
* * `reddit-ads` - Reddit Ads
+ * * `resend` - Resend
* * `s3-compatible` - S3 Compatible
* * `salesforce` - Salesforce
* * `slack` - Slack
@@ -223,6 +224,7 @@ export const IntegrationKindEnumApi = {
PinterestAds: 'pinterest-ads',
Postgresql: 'postgresql',
RedditAds: 'reddit-ads',
+ Resend: 'resend',
S3Compatible: 's3-compatible',
Salesforce: 'salesforce',
Slack: 'slack',
@@ -458,6 +460,7 @@ export interface IntegrationAccessRequestApi {
* * `pinterest-ads` - Pinterest Ads
* * `postgresql` - Postgresql
* * `reddit-ads` - Reddit Ads
+ * * `resend` - Resend
* * `s3-compatible` - S3 Compatible
* * `salesforce` - Salesforce
* * `slack` - Slack
@@ -547,6 +550,7 @@ export type IntegrationsListParams = {
* * `pinterest-ads` - Pinterest Ads
* * `postgresql` - Postgresql
* * `reddit-ads` - Reddit Ads
+ * * `resend` - Resend
* * `s3-compatible` - S3 Compatible
* * `salesforce` - Salesforce
* * `slack` - Slack
@@ -602,6 +606,7 @@ export const IntegrationsListKind = {
PinterestAds: 'pinterest-ads',
Postgresql: 'postgresql',
RedditAds: 'reddit-ads',
+ Resend: 'resend',
S3Compatible: 's3-compatible',
Salesforce: 'salesforce',
Slack: 'slack',
diff --git a/products/integrations/frontend/generated/api.zod.ts b/products/integrations/frontend/generated/api.zod.ts
index fedc8ca2457b..4176f6844d2d 100644
--- a/products/integrations/frontend/generated/api.zod.ts
+++ b/products/integrations/frontend/generated/api.zod.ts
@@ -92,6 +92,7 @@ export const IntegrationsCreateBody = /* @__PURE__ */ zod
'pinterest-ads',
'postgresql',
'reddit-ads',
+ 'resend',
's3-compatible',
'salesforce',
'slack',
@@ -104,7 +105,7 @@ export const IntegrationsCreateBody = /* @__PURE__ */ zod
'vercel',
])
.describe(
- '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `reddit-ads` - Reddit Ads\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel'
+ '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel'
),
config: zod.unknown().optional(),
})
@@ -144,6 +145,7 @@ export const IntegrationsEmailPartialUpdateBody = /* @__PURE__ */ zod
'pinterest-ads',
'postgresql',
'reddit-ads',
+ 'resend',
's3-compatible',
'salesforce',
'slack',
@@ -157,7 +159,7 @@ export const IntegrationsEmailPartialUpdateBody = /* @__PURE__ */ zod
])
.optional()
.describe(
- '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `reddit-ads` - Reddit Ads\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel'
+ '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel'
),
config: zod.unknown().optional(),
})
@@ -197,6 +199,7 @@ export const IntegrationsEmailVerifyCreateBody = /* @__PURE__ */ zod
'pinterest-ads',
'postgresql',
'reddit-ads',
+ 'resend',
's3-compatible',
'salesforce',
'slack',
@@ -209,7 +212,7 @@ export const IntegrationsEmailVerifyCreateBody = /* @__PURE__ */ zod
'vercel',
])
.describe(
- '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `reddit-ads` - Reddit Ads\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel'
+ '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel'
),
config: zod.unknown().optional(),
})
@@ -256,6 +259,7 @@ export const IntegrationsDomainConnectApplyUrlCreateBody = /* @__PURE__ */ zod
'pinterest-ads',
'postgresql',
'reddit-ads',
+ 'resend',
's3-compatible',
'salesforce',
'slack',
@@ -268,7 +272,7 @@ export const IntegrationsDomainConnectApplyUrlCreateBody = /* @__PURE__ */ zod
'vercel',
])
.describe(
- '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `reddit-ads` - Reddit Ads\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel'
+ '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel'
),
config: zod.unknown().optional(),
})
@@ -362,6 +366,7 @@ export const IntegrationsRequestAccessCreateBody = /* @__PURE__ */ zod.object({
'pinterest-ads',
'postgresql',
'reddit-ads',
+ 'resend',
's3-compatible',
'salesforce',
'slack',
@@ -374,10 +379,10 @@ export const IntegrationsRequestAccessCreateBody = /* @__PURE__ */ zod.object({
'vercel',
])
.describe(
- '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `reddit-ads` - Reddit Ads\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel'
+ '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel'
)
.describe(
- "The kind of integration the member is requesting be connected (e.g. 'slack', 'github').\n\n\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `reddit-ads` - Reddit Ads\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel"
+ "The kind of integration the member is requesting be connected (e.g. 'slack', 'github').\n\n\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel"
),
reason: zod
.string()
diff --git a/products/warehouse_sources/backend/migrations/0095_migrate_resend_job_inputs_to_auth_method.py b/products/warehouse_sources/backend/migrations/0095_migrate_resend_job_inputs_to_auth_method.py
new file mode 100644
index 000000000000..6ef90edf0a49
--- /dev/null
+++ b/products/warehouse_sources/backend/migrations/0095_migrate_resend_job_inputs_to_auth_method.py
@@ -0,0 +1,54 @@
+from django.db import migrations
+
+
+def migrate_resend_job_inputs(apps, schema_editor):
+ ExternalDataSource = apps.get_model("warehouse_sources", "ExternalDataSource")
+
+ for source in ExternalDataSource.objects.filter(source_type="Resend"):
+ job_inputs = source.job_inputs
+ if not isinstance(job_inputs, dict):
+ continue
+
+ # Already migrated
+ if "auth_method" in job_inputs:
+ continue
+
+ if "api_key" in job_inputs:
+ api_key = job_inputs.pop("api_key")
+ job_inputs["auth_method"] = {
+ "selection": "api_key",
+ "api_key": api_key,
+ }
+
+ source.job_inputs = job_inputs
+ source.save(update_fields=["job_inputs"])
+
+
+def reverse_migrate_resend_job_inputs(apps, schema_editor):
+ ExternalDataSource = apps.get_model("warehouse_sources", "ExternalDataSource")
+
+ for source in ExternalDataSource.objects.filter(source_type="Resend"):
+ job_inputs = source.job_inputs
+ if not isinstance(job_inputs, dict):
+ continue
+
+ auth_method = job_inputs.get("auth_method")
+ if not isinstance(auth_method, dict):
+ continue
+
+ if auth_method.get("selection") == "api_key":
+ job_inputs["api_key"] = auth_method.get("api_key", "")
+
+ job_inputs.pop("auth_method", None)
+ source.job_inputs = job_inputs
+ source.save(update_fields=["job_inputs"])
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("warehouse_sources", "0094_externaldatajob_updated_at_idx"),
+ ]
+
+ operations = [
+ migrations.RunPython(migrate_resend_job_inputs, reverse_migrate_resend_job_inputs),
+ ]
diff --git a/products/warehouse_sources/backend/migrations/max_migration.txt b/products/warehouse_sources/backend/migrations/max_migration.txt
index fb006ad127d9..a7a734370a13 100644
--- a/products/warehouse_sources/backend/migrations/max_migration.txt
+++ b/products/warehouse_sources/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0094_externaldatajob_updated_at_idx
+0095_migrate_resend_job_inputs_to_auth_method
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/resend.py b/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/resend.py
index effb96b0ba5a..470c0836e55a 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/resend.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/resend.py
@@ -1,9 +1,18 @@
# This file is automatically generated from `SourceRegistry.get_all_sources()`
# Do not edit manually - run `pnpm generate:source-configs` to regenerate.
+from typing import Literal
+
from products.warehouse_sources.backend.temporal.data_imports.sources.common import config
+class ResendAuthMethodConfig(config.Config):
+ resend_integration_id: int | None = config.value(converter=config.str_to_optional_int, default_factory=lambda: None)
+ selection: Literal["api_key", "oauth"] = "api_key"
+ api_key: str | None = None
+
+
@config.config
class ResendSourceConfig(config.Config):
- api_key: str
+ auth_method: ResendAuthMethodConfig
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/resend/oauth.py b/products/warehouse_sources/backend/temporal/data_imports/sources/resend/oauth.py
new file mode 100644
index 000000000000..b8c0d7501bc4
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/resend/oauth.py
@@ -0,0 +1,67 @@
+from datetime import UTC, datetime, timedelta
+
+from django.db import transaction
+
+from requests import PreparedRequest
+
+from posthog.models.integration import Integration, OauthIntegration
+
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.auth import AuthConfigBase
+
+# Resend access tokens live ~15m. Re-mint through the DB a few minutes before that so a token never
+# expires mid-request; the DB refresh only actually spends the refresh token once it's past its own
+# half-life threshold, so this cadence just decides how often we re-check the row.
+_RESEND_TOKEN_REFRESH_AFTER = timedelta(minutes=10)
+
+
+def resolve_resend_oauth_token(integration_id: int, team_id: int, current_token: str | None = None) -> str:
+ """Return a valid Resend OAuth access token, refreshing under a row lock when needed.
+
+ Resend access tokens are short-lived (~15m) and its refresh tokens rotate on every use, with
+ reuse-detection that revokes the whole grant if a rotated token is dropped or spent twice. So a
+ refresh MUST (a) persist the newly rotated refresh token — ``refresh_access_token`` does — and
+ (b) be serialized against the parallel schema syncs that share one integration. ``select_for_update``
+ gives us that Postgres row lock, and we reload inside it so a sync that lost the race picks up the
+ token another already rotated instead of re-spending the old one.
+
+ ``current_token`` is the token the caller just refreshed from; when it still matches the row
+ (nobody else rotated past it) we refresh, otherwise we hand back the fresher token already on the row.
+ """
+ with transaction.atomic():
+ integration = Integration.objects.select_for_update().get(id=integration_id, team_id=team_id, kind="resend")
+ oauth = OauthIntegration(integration)
+ if oauth.access_token_expired() or (current_token is not None and integration.access_token == current_token):
+ oauth.refresh_access_token()
+ token = integration.access_token
+
+ if not token:
+ raise ValueError("Resend access token not found")
+ return token
+
+
+class ResendIntegrationAuth(AuthConfigBase):
+ """Bearer auth for the Resend OAuth path that proactively re-mints through the integration row.
+
+ Resend rotates its single-use refresh token on every refresh, so the token can only be re-minted
+ where the rotation is persisted — the DB row, under a lock (see :func:`resolve_resend_oauth_token`).
+ The framework's in-process :class:`OAuth2Auth` mint can't persist that rotation, so this auth does
+ the refresh through the row instead: it caches a token for ~10m, then re-resolves. Because it
+ refreshes *before* the ~15m expiry, a sync never sees a mid-flight 401 from an expired token — so
+ the source can keep treating 401 as a non-retryable bad-credential signal for both auth methods.
+ """
+
+ def __init__(self, integration_id: int, team_id: int, access_token: str) -> None:
+ self._integration_id = integration_id
+ self._team_id = team_id
+ self.token: str = access_token
+ self._refresh_after: datetime = datetime.now(UTC) + _RESEND_TOKEN_REFRESH_AFTER
+
+ def __call__(self, request: PreparedRequest) -> PreparedRequest:
+ if datetime.now(UTC) >= self._refresh_after:
+ self.token = resolve_resend_oauth_token(self._integration_id, self._team_id, self.token)
+ self._refresh_after = datetime.now(UTC) + _RESEND_TOKEN_REFRESH_AFTER
+ request.headers["Authorization"] = f"Bearer {self.token}"
+ return request
+
+ def secret_values(self) -> tuple[str, ...]:
+ return (self.token,) if self.token else ()
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 6e7c8d4ca334..f0357fc88637 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
@@ -10,6 +10,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.res
rest_api_resource,
rest_api_resources,
)
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.auth import AuthConfigBase
from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.paginators import (
BasePaginator,
SinglePagePaginator,
@@ -93,18 +94,20 @@ class ResendEmailsPaginator(BasePaginator):
self._has_next_page = True
-def _client_config(api_key: str) -> ClientConfig:
- # Framework Bearer auth (not a hand-built header) so the key is redacted from logged URLs/headers.
+def _client_config(auth: AuthConfigBase) -> ClientConfig:
+ # Framework auth object (not a hand-built header) so the credential is redacted from logged
+ # URLs/headers. Both auth methods pass a bearer here: a static API key, or the Resend OAuth
+ # access token wrapped in an auth that re-mints it through the integration row (see oauth.py).
return {
"base_url": RESEND_BASE_URL,
"headers": {"Accept": "application/json"},
- "auth": {"type": "bearer", "token": api_key},
+ "auth": auth,
}
def _simple_resource(
config: ResendEndpointConfig,
- api_key: str,
+ auth: AuthConfigBase,
team_id: int,
job_id: str,
manager: ResumableSourceManager[ResendResumeConfig],
@@ -130,7 +133,7 @@ def _simple_resource(
}
rest_config: RESTAPIConfig = {
- "client": _client_config(api_key),
+ "client": _client_config(auth),
"resources": [{"name": config.name, "endpoint": endpoint}],
}
@@ -167,7 +170,7 @@ def _inject_audience_id(row: dict[str, Any]) -> dict[str, Any]:
def _fan_out_resource(
config: ResendEndpointConfig,
- api_key: str,
+ auth: AuthConfigBase,
team_id: int,
job_id: str,
manager: ResumableSourceManager[ResendResumeConfig],
@@ -184,7 +187,7 @@ def _fan_out_resource(
}
rest_config: RESTAPIConfig = {
- "client": _client_config(api_key),
+ "client": _client_config(auth),
"resources": [
{
"name": config.parent,
@@ -233,7 +236,7 @@ def _fan_out_resource(
def resend_source(
- api_key: str,
+ auth: AuthConfigBase,
endpoint: str,
team_id: int,
job_id: str,
@@ -242,9 +245,9 @@ def resend_source(
config = RESEND_ENDPOINTS[endpoint]
if config.parent is not None:
- resource = _fan_out_resource(config, api_key, team_id, job_id, resumable_source_manager)
+ resource = _fan_out_resource(config, auth, team_id, job_id, resumable_source_manager)
else:
- resource = _simple_resource(config, api_key, team_id, job_id, resumable_source_manager)
+ resource = _simple_resource(config, auth, team_id, job_id, resumable_source_manager)
return SourceResponse(
name=endpoint,
@@ -259,12 +262,13 @@ def resend_source(
)
-def validate_credentials(api_key: str) -> bool:
- # /domains is a cheap read-only call that requires a valid API key with at least read scope —
- # Resend returns 401 for bad keys and 200 for good ones.
+def validate_credentials(token: str) -> bool:
+ # /domains is a cheap read-only call that requires a valid credential with at least read scope —
+ # Resend returns 401 for bad tokens and 200 for good ones. Works for a static API key or an OAuth
+ # access token (both are sent as bearer tokens).
ok, _status = validate_via_probe(
- lambda: make_tracked_session(redact_values=(api_key,)),
+ lambda: make_tracked_session(redact_values=(token,)),
f"{RESEND_BASE_URL}/domains",
- headers={"Authorization": f"Bearer {api_key}", "Accept": "application/json"},
+ headers={"Authorization": f"Bearer {token}", "Accept": "application/json"},
)
return ok
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/resend/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/resend/source.py
index de079e0ea4ca..5bf70419dd6c 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/resend/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/resend/source.py
@@ -7,6 +7,9 @@ from posthog.schema import (
SourceConfig,
SourceFieldInputConfig,
SourceFieldInputConfigType,
+ SourceFieldOauthConfig,
+ SourceFieldSelectConfig,
+ SourceFieldSelectConfigOption,
)
from products.warehouse_sources.backend.temporal.data_imports.pipelines.pipeline.typings import (
@@ -17,10 +20,19 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.bas
from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (
CanonicalDescriptions,
)
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.mixins import OAuthMixin
from products.warehouse_sources.backend.temporal.data_imports.sources.common.registry import SourceRegistry
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.auth import (
+ AuthConfigBase,
+ BearerTokenAuth,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager
from products.warehouse_sources.backend.temporal.data_imports.sources.common.schema import SourceSchema
from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.resend import ResendSourceConfig
+from products.warehouse_sources.backend.temporal.data_imports.sources.resend.oauth import (
+ ResendIntegrationAuth,
+ resolve_resend_oauth_token,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.resend.resend import (
ResendResumeConfig,
resend_source,
@@ -31,7 +43,7 @@ from products.warehouse_sources.backend.types import ExternalDataSourceType
@SourceRegistry.register
-class ResendSource(ResumableSource[ResendSourceConfig, ResendResumeConfig]):
+class ResendSource(ResumableSource[ResendSourceConfig, ResendResumeConfig], OAuthMixin):
lists_tables_without_credentials = True # static endpoint catalog — safe for public docs
api_docs_url = "https://resend.com/docs/api-reference/introduction"
@@ -46,11 +58,9 @@ class ResendSource(ResumableSource[ResendSourceConfig, ResendResumeConfig]):
category=DataWarehouseSourceCategory.MARKETING___EMAIL,
label="Resend",
releaseStatus=ReleaseStatus.GA,
- caption="""Enter your Resend API key to pull your Resend data into the PostHog Data warehouse.
-
-You can create an API key in your [Resend API keys settings](https://resend.com/api-keys).
+ caption="""Connect Resend to pull your Resend data into the PostHog Data warehouse. Connect with OAuth, or paste a Resend API key.
-Grant the key **full access** or a read-enabled access token so the following resources can be read:
+Either way, the connection needs **full access** so the following resources can be read:
- Audiences
- Broadcasts
- Contacts
@@ -62,13 +72,47 @@ Grant the key **full access** or a read-enabled access token so the following re
fields=cast(
list[FieldType],
[
- SourceFieldInputConfig(
- name="api_key",
- label="API key",
- type=SourceFieldInputConfigType.PASSWORD,
+ SourceFieldSelectConfig(
+ name="auth_method",
+ label="Authentication type",
required=True,
- placeholder="re_...",
- secret=True,
+ defaultValue="api_key",
+ options=[
+ SourceFieldSelectConfigOption(
+ label="API key",
+ value="api_key",
+ fields=cast(
+ list[FieldType],
+ [
+ SourceFieldInputConfig(
+ name="api_key",
+ label="API key",
+ type=SourceFieldInputConfigType.PASSWORD,
+ required=False,
+ placeholder="re_...",
+ caption="Create a full-access API key in your [Resend API keys settings](https://resend.com/api-keys).",
+ secret=True,
+ ),
+ ],
+ ),
+ ),
+ SourceFieldSelectConfigOption(
+ label="OAuth",
+ value="oauth",
+ fields=cast(
+ list[FieldType],
+ [
+ SourceFieldOauthConfig(
+ name="resend_integration_id",
+ label="Resend account",
+ required=False,
+ kind="resend",
+ requiredScopes="full_access",
+ ),
+ ],
+ ),
+ ),
+ ],
),
],
),
@@ -101,6 +145,34 @@ Grant the key **full access** or a read-enabled access token so the following re
schemas = [s for s in schemas if s.name in names_set]
return schemas
+ def _probe_token(self, config: ResendSourceConfig, team_id: int) -> str:
+ """Resolve the current bearer token for the selected auth method, used for validation."""
+ if config.auth_method.selection == "api_key":
+ if not config.auth_method.api_key:
+ raise ValueError("Missing Resend API key")
+ return config.auth_method.api_key
+
+ integration_id = config.auth_method.resend_integration_id
+ if not integration_id:
+ raise ValueError("Missing Resend integration ID")
+ self.get_oauth_integration(integration_id, team_id) # ownership check → non-retryable ValueError
+ return resolve_resend_oauth_token(integration_id, team_id)
+
+ def _build_auth(self, config: ResendSourceConfig, team_id: int) -> AuthConfigBase:
+ """Build the transport auth. API key → static bearer; OAuth → an auth that re-mints the
+ access token through the integration row (rotation-safe) so long syncs never see a 401."""
+ if config.auth_method.selection == "api_key":
+ if not config.auth_method.api_key:
+ raise ValueError("Missing Resend API key")
+ return BearerTokenAuth(config.auth_method.api_key)
+
+ integration_id = config.auth_method.resend_integration_id
+ if not integration_id:
+ raise ValueError("Missing Resend integration ID")
+ self.get_oauth_integration(integration_id, team_id) # ownership check → non-retryable ValueError
+ token = resolve_resend_oauth_token(integration_id, team_id)
+ return ResendIntegrationAuth(integration_id, team_id, token)
+
def validate_credentials(
self,
config: ResendSourceConfig,
@@ -108,19 +180,32 @@ Grant the key **full access** or a read-enabled access token so the following re
schema_name: Optional[str] = None,
api_version: str | None = None,
) -> tuple[bool, str | None]:
- if validate_resend_credentials(config.api_key):
+ try:
+ token = self._probe_token(config, team_id)
+ except ValueError as e:
+ return False, str(e)
+
+ if validate_resend_credentials(token):
return True, None
+ if config.auth_method.selection == "oauth":
+ return False, "Your Resend connection is invalid or expired. Please reconnect it."
return False, "Invalid Resend API key"
def get_non_retryable_errors(self) -> dict[str, str | None]:
return {
"401 Client Error: Unauthorized for url: https://api.resend.com": (
- "Your Resend API key is invalid or expired. Please generate a new key and reconnect."
+ "Your Resend credentials are invalid or expired. Please reconnect the source or generate a new API key."
),
"403 Client Error: Forbidden for url: https://api.resend.com": (
- "Your Resend API key does not have the required permissions. Please check the key permissions and try again."
+ "Your Resend connection does not have the required permissions. Grant full access and reconnect."
),
+ # Deterministic credential/config errors from OAuthMixin and the auth builders — the
+ # integration row is gone or unconfigured, so retrying can never succeed. Match on the
+ # stable prefix so the volatile integration ID is ignored.
+ "Missing Resend integration ID": "Resend integration is not configured. Please reconnect your Resend account.",
+ "Integration not found": "The linked Resend integration no longer exists. Please reconnect your Resend account.",
+ "Resend access token not found": "Resend OAuth access token is missing. Please reconnect your Resend account.",
# Resend rejects the well-formed list request with a 400 when the connected account
# can't access the Audiences/Contacts API (the Marketing/Audiences feature isn't enabled,
# or the key lacks full access). Retrying the identical request can't fix an account-level
@@ -153,7 +238,7 @@ Grant the key **full access** or a read-enabled access token so the following re
inputs: SourceInputs,
) -> SourceResponse:
return resend_source(
- api_key=config.api_key,
+ auth=self._build_auth(config, inputs.team_id),
endpoint=inputs.schema_name,
team_id=inputs.team_id,
job_id=inputs.job_id,
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 842a13fe9c18..baa460c4c6b0 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
@@ -8,6 +8,7 @@ from unittest import mock
from requests import Response
from products.warehouse_sources.backend.temporal.data_imports.pipelines.pipeline.typings import SourceResponse
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.auth import BearerTokenAuth
from products.warehouse_sources.backend.temporal.data_imports.sources.resend.resend import (
RESEND_BASE_URL,
ResendResumeConfig,
@@ -61,7 +62,7 @@ def _wire(session: mock.MagicMock, responses: list[Response]) -> list[tuple[str,
def _source(endpoint: str, manager: mock.MagicMock | None = None) -> SourceResponse:
return resend_source(
- api_key="re_test",
+ auth=BearerTokenAuth("re_test"),
endpoint=endpoint,
team_id=1,
job_id="job-1",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/resend/tests/test_resend_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/resend/tests/test_resend_source.py
index ae063fa652bb..f3d2bcf7c167 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/resend/tests/test_resend_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/resend/tests/test_resend_source.py
@@ -2,45 +2,76 @@ from unittest import mock
from parameterized import parameterized
-from posthog.schema import SourceFieldInputConfig, SourceFieldInputConfigType
+from posthog.schema import SourceFieldInputConfig, SourceFieldOauthConfig, SourceFieldSelectConfig
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.auth import BearerTokenAuth
from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager
-from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.resend import ResendSourceConfig
+from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.resend import (
+ ResendAuthMethodConfig,
+ ResendSourceConfig,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.resend.oauth import ResendIntegrationAuth
from products.warehouse_sources.backend.temporal.data_imports.sources.resend.resend import ResendResumeConfig
from products.warehouse_sources.backend.temporal.data_imports.sources.resend.settings import ENDPOINTS
from products.warehouse_sources.backend.temporal.data_imports.sources.resend.source import ResendSource
from products.warehouse_sources.backend.types import ExternalDataSourceType
+def _api_key_config(api_key: str = "re_test_key") -> ResendSourceConfig:
+ return ResendSourceConfig(auth_method=ResendAuthMethodConfig(selection="api_key", api_key=api_key))
+
+
+def _oauth_config(integration_id: int = 42) -> ResendSourceConfig:
+ return ResendSourceConfig(
+ auth_method=ResendAuthMethodConfig(selection="oauth", resend_integration_id=integration_id)
+ )
+
+
class TestResendSource:
def setup_method(self):
self.source = ResendSource()
self.team_id = 123
- self.config = ResendSourceConfig(api_key="re_test_key")
+ self.config = _api_key_config()
def test_source_type(self):
assert self.source.source_type == ExternalDataSourceType.RESEND
- def test_get_source_config(self):
+ def test_get_source_config_offers_both_auth_methods(self):
config = self.source.get_source_config
assert config.name.value == "Resend"
- assert config.label == "Resend"
assert config.releaseStatus == "ga"
- assert config.iconPath == "/static/services/resend.png"
assert len(config.fields) == 1
- api_key_field = config.fields[0]
+ auth_field = config.fields[0]
+ assert isinstance(auth_field, SourceFieldSelectConfig)
+ assert auth_field.name == "auth_method"
+ assert auth_field.defaultValue == "api_key"
+
+ options = {option.value: option for option in auth_field.options}
+ assert set(options) == {"api_key", "oauth"}
+
+ api_key_fields = options["api_key"].fields
+ assert api_key_fields is not None
+ api_key_field = api_key_fields[0]
assert isinstance(api_key_field, SourceFieldInputConfig)
assert api_key_field.name == "api_key"
- assert api_key_field.type == SourceFieldInputConfigType.PASSWORD
assert api_key_field.secret is True
- assert api_key_field.required is True
+
+ oauth_fields = options["oauth"].fields
+ assert oauth_fields is not None
+ oauth_field = oauth_fields[0]
+ assert isinstance(oauth_field, SourceFieldOauthConfig)
+ assert oauth_field.name == "resend_integration_id"
+ assert oauth_field.kind == "resend"
+ assert oauth_field.requiredScopes == "full_access"
def test_non_retryable_errors(self):
errors = self.source.get_non_retryable_errors()
assert any("401" in key for key in errors)
assert any("403" in key for key in errors)
+ # OAuth reconnect signals must be non-retryable too.
+ assert any("Integration not found" in key for key in errors)
def test_audiences_bad_request_is_non_retryable(self):
errors = self.source.get_non_retryable_errors()
@@ -92,19 +123,19 @@ class TestResendSource:
@mock.patch(
"products.warehouse_sources.backend.temporal.data_imports.sources.resend.source.validate_resend_credentials"
)
- def test_validate_credentials_success(self, mock_validate):
+ def test_validate_credentials_api_key_success(self, mock_validate):
mock_validate.return_value = True
is_valid, error_message = self.source.validate_credentials(self.config, self.team_id)
assert is_valid is True
assert error_message is None
- mock_validate.assert_called_once_with(self.config.api_key)
+ mock_validate.assert_called_once_with("re_test_key")
@mock.patch(
"products.warehouse_sources.backend.temporal.data_imports.sources.resend.source.validate_resend_credentials"
)
- def test_validate_credentials_failure(self, mock_validate):
+ def test_validate_credentials_api_key_failure(self, mock_validate):
mock_validate.return_value = False
is_valid, error_message = self.source.validate_credentials(self.config, self.team_id)
@@ -112,6 +143,56 @@ class TestResendSource:
assert is_valid is False
assert error_message == "Invalid Resend API key"
+ def test_validate_credentials_api_key_missing(self):
+ config = ResendSourceConfig(auth_method=ResendAuthMethodConfig(selection="api_key", api_key=None))
+
+ is_valid, error_message = self.source.validate_credentials(config, self.team_id)
+
+ assert is_valid is False
+ assert error_message is not None and "Missing Resend API key" in error_message
+
+ @mock.patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.resend.source.validate_resend_credentials"
+ )
+ @mock.patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.resend.source.resolve_resend_oauth_token"
+ )
+ @mock.patch.object(ResendSource, "get_oauth_integration")
+ def test_validate_credentials_oauth_success(self, mock_get_integration, mock_resolve, mock_validate):
+ mock_resolve.return_value = "oauth_access_token"
+ mock_validate.return_value = True
+
+ is_valid, error_message = self.source.validate_credentials(_oauth_config(), self.team_id)
+
+ assert is_valid is True
+ assert error_message is None
+ mock_get_integration.assert_called_once_with(42, self.team_id)
+ mock_resolve.assert_called_once_with(42, self.team_id)
+ mock_validate.assert_called_once_with("oauth_access_token")
+
+ @mock.patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.resend.source.validate_resend_credentials"
+ )
+ @mock.patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.resend.source.resolve_resend_oauth_token"
+ )
+ @mock.patch.object(ResendSource, "get_oauth_integration")
+ def test_validate_credentials_oauth_failure(self, mock_get_integration, mock_resolve, mock_validate):
+ mock_resolve.return_value = "oauth_access_token"
+ mock_validate.return_value = False
+
+ is_valid, error_message = self.source.validate_credentials(_oauth_config(), self.team_id)
+
+ assert is_valid is False
+ assert error_message is not None and "reconnect" in error_message.lower()
+
+ @mock.patch.object(ResendSource, "get_oauth_integration", side_effect=ValueError("Integration not found: 42"))
+ def test_validate_credentials_oauth_missing_integration(self, _mock_get_integration):
+ is_valid, error_message = self.source.validate_credentials(_oauth_config(), self.team_id)
+
+ assert is_valid is False
+ assert error_message == "Integration not found: 42"
+
def test_get_resumable_source_manager(self):
inputs = mock.MagicMock()
manager = self.source.get_resumable_source_manager(inputs)
@@ -119,7 +200,7 @@ class TestResendSource:
assert manager._data_class is ResendResumeConfig
@mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.resend.source.resend_source")
- def test_source_for_pipeline(self, mock_resend_source):
+ def test_source_for_pipeline_api_key_passes_bearer_auth(self, mock_resend_source):
mock_resend_source.return_value = mock.MagicMock()
inputs = mock.MagicMock()
@@ -130,10 +211,34 @@ class TestResendSource:
self.source.source_for_pipeline(self.config, manager, inputs)
- mock_resend_source.assert_called_once_with(
- api_key=self.config.api_key,
- endpoint="audiences",
- team_id=123,
- job_id="job-1",
- resumable_source_manager=manager,
- )
+ kwargs = mock_resend_source.call_args.kwargs
+ assert kwargs["endpoint"] == "audiences"
+ assert kwargs["team_id"] == 123
+ assert kwargs["job_id"] == "job-1"
+ assert kwargs["resumable_source_manager"] is manager
+ assert isinstance(kwargs["auth"], BearerTokenAuth)
+ assert kwargs["auth"].token == "re_test_key"
+
+ @mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.resend.source.resend_source")
+ @mock.patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.resend.source.resolve_resend_oauth_token"
+ )
+ @mock.patch.object(ResendSource, "get_oauth_integration")
+ def test_source_for_pipeline_oauth_passes_integration_auth(
+ self, mock_get_integration, mock_resolve, mock_resend_source
+ ):
+ mock_resolve.return_value = "oauth_access_token"
+ mock_resend_source.return_value = mock.MagicMock()
+
+ inputs = mock.MagicMock()
+ inputs.schema_name = "emails"
+ inputs.team_id = 123
+ inputs.job_id = "job-1"
+ manager = mock.MagicMock()
+
+ self.source.source_for_pipeline(_oauth_config(), manager, inputs)
+
+ auth = mock_resend_source.call_args.kwargs["auth"]
+ assert isinstance(auth, ResendIntegrationAuth)
+ assert auth.token == "oauth_access_token"
+ mock_resolve.assert_called_once_with(42, 123)
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index c36f45d98b0a..27378d8d262d 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -36056,6 +36056,7 @@ export namespace Schemas {
* * `pinterest-ads` - Pinterest Ads
* * `postgresql` - Postgresql
* * `reddit-ads` - Reddit Ads
+ * * `resend` - Resend
* * `s3-compatible` - S3 Compatible
* * `salesforce` - Salesforce
* * `slack` - Slack
@@ -36101,6 +36102,7 @@ export namespace Schemas {
PinterestAds: 'pinterest-ads',
Postgresql: 'postgresql',
RedditAds: 'reddit-ads',
+ Resend: 'resend',
S3Compatible: 's3-compatible',
Salesforce: 'salesforce',
Slack: 'slack',
@@ -36146,6 +36148,7 @@ export namespace Schemas {
* * `pinterest-ads` - Pinterest Ads
* * `postgresql` - Postgresql
* * `reddit-ads` - Reddit Ads
+ * * `resend` - Resend
* * `s3-compatible` - S3 Compatible
* * `salesforce` - Salesforce
* * `slack` - Slack
@@ -77252,6 +77255,7 @@ export namespace Schemas {
* * `pinterest-ads` - Pinterest Ads
* * `postgresql` - Postgresql
* * `reddit-ads` - Reddit Ads
+ * * `resend` - Resend
* * `s3-compatible` - S3 Compatible
* * `salesforce` - Salesforce
* * `slack` - Slack
@@ -77308,6 +77312,7 @@ export namespace Schemas {
PinterestAds: 'pinterest-ads',
Postgresql: 'postgresql',
RedditAds: 'reddit-ads',
+ Resend: 'resend',
S3Compatible: 's3-compatible',
Salesforce: 'salesforce',
Slack: 'slack',
diff --git a/services/mcp/src/generated/integrations/api.ts b/services/mcp/src/generated/integrations/api.ts
index 7afa3849c6b7..0633b9faf730 100644
--- a/services/mcp/src/generated/integrations/api.ts
+++ b/services/mcp/src/generated/integrations/api.ts
@@ -49,6 +49,7 @@ export const IntegrationsListQueryParams = /* @__PURE__ */ zod.object({
'pinterest-ads',
'postgresql',
'reddit-ads',
+ 'resend',
's3-compatible',
'salesforce',
'slack',
@@ -62,7 +63,7 @@ export const IntegrationsListQueryParams = /* @__PURE__ */ zod.object({
])
.optional()
.describe(
- '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `reddit-ads` - Reddit Ads\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel'
+ '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel'
),
limit: zod.number().optional().describe('Number of results to return per page.'),
offset: zod.number().optional().describe('The initial index from which to return the results.'),
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/integrations-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/integrations-list.json
index 8db00935f477..d3bdc2fb7248 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/integrations-list.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/integrations-list.json
@@ -2,7 +2,7 @@
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"kind": {
- "description": "* `anthropic` - Anthropic\n* `apns` - Apple Push\n* `aws-s3` - Aws S3\n* `azure-blob` - Azure Blob\n* `bing-ads` - Bing Ads\n* `clickup` - Clickup\n* `customerio-app` - Customerio App\n* `customerio-track` - Customerio Track\n* `customerio-webhook` - Customerio Webhook\n* `databricks` - Databricks\n* `email` - Email\n* `firebase` - Firebase\n* `github` - Github\n* `gitlab` - Gitlab\n* `google-ads` - Google Ads\n* `google-analytics` - Google Analytics\n* `google-cloud-service-account` - Google Cloud Service Account\n* `google-cloud-storage` - Google Cloud Storage\n* `google-pubsub` - Google Pubsub\n* `google-search-console` - Google Search Console\n* `google-sheets` - Google Sheets\n* `hubspot` - Hubspot\n* `intercom` - Intercom\n* `jira` - Jira\n* `linear` - Linear\n* `linkedin-ads` - Linkedin Ads\n* `meta-ads` - Meta Ads\n* `pinterest-ads` - Pinterest Ads\n* `postgresql` - Postgresql\n* `reddit-ads` - Reddit Ads\n* `s3-compatible` - S3 Compatible\n* `salesforce` - Salesforce\n* `slack` - Slack\n* `slack-posthog-code` - Slack Posthog Code\n* `snapchat` - Snapchat\n* `snowflake` - Snowflake\n* `stripe` - Stripe\n* `tiktok-ads` - Tiktok Ads\n* `twilio` - Twilio\n* `vercel` - Vercel",
+ "description": "* `anthropic` - Anthropic\n* `apns` - Apple Push\n* `aws-s3` - Aws S3\n* `azure-blob` - Azure Blob\n* `bing-ads` - Bing Ads\n* `clickup` - Clickup\n* `customerio-app` - Customerio App\n* `customerio-track` - Customerio Track\n* `customerio-webhook` - Customerio Webhook\n* `databricks` - Databricks\n* `email` - Email\n* `firebase` - Firebase\n* `github` - Github\n* `gitlab` - Gitlab\n* `google-ads` - Google Ads\n* `google-analytics` - Google Analytics\n* `google-cloud-service-account` - Google Cloud Service Account\n* `google-cloud-storage` - Google Cloud Storage\n* `google-pubsub` - Google Pubsub\n* `google-search-console` - Google Search Console\n* `google-sheets` - Google Sheets\n* `hubspot` - Hubspot\n* `intercom` - Intercom\n* `jira` - Jira\n* `linear` - Linear\n* `linkedin-ads` - Linkedin Ads\n* `meta-ads` - Meta Ads\n* `pinterest-ads` - Pinterest Ads\n* `postgresql` - Postgresql\n* `reddit-ads` - Reddit Ads\n* `resend` - Resend\n* `s3-compatible` - S3 Compatible\n* `salesforce` - Salesforce\n* `slack` - Slack\n* `slack-posthog-code` - Slack Posthog Code\n* `snapchat` - Snapchat\n* `snowflake` - Snowflake\n* `stripe` - Stripe\n* `tiktok-ads` - Tiktok Ads\n* `twilio` - Twilio\n* `vercel` - Vercel",
"enum": [
"anthropic",
"apns",
@@ -34,6 +34,7 @@
"pinterest-ads",
"postgresql",
"reddit-ads",
+ "resend",
"s3-compatible",
"salesforce",
"slack",