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.

fix(warehouse): correct Apple Ads source setup instructions (#87555)

posthog[bot]51b2ac6a86e4
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/apple_search_ads/apple_search_ads.py b/products/warehouse_sources/backend/temporal/data_imports/sources/apple_search_ads/apple_search_ads.py
index c03bc512f15e..28ebe864904d 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/apple_search_ads/apple_search_ads.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/apple_search_ads/apple_search_ads.py
@@ -325,7 +325,7 @@ def validate_credentials(
if schema_name is None:
return True, None
return False, (
- "These Apple Ads credentials cannot read this table. Give the API client the API "
+ "These Apple Ads credentials cannot read this table. Give the API user the API "
"Account Read Only role for this ad account in Apple Ads."
)
return False, f"The Apple Ads API returned an unexpected status code: {status}"
@@ -358,8 +358,8 @@ def _readable_ad_accounts(client: AppleSearchAdsClient, api_version: str) -> str
named.append(f"{account_id} ({name})" if name else str(account_id))
if not named:
- return " This API client cannot read any ad account yet. Check its role in Apple Ads."
- return " This API client can read: " + ", ".join(named) + "."
+ return " These credentials cannot read any ad account yet. Check the API user's role in Apple Ads."
+ return " These credentials can read: " + ", ".join(named) + "."
def _today() -> date:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/apple_search_ads/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/apple_search_ads/canonical_descriptions.py
index f55d668cab0d..84f7e5a3ed11 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/apple_search_ads/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/apple_search_ads/canonical_descriptions.py
@@ -49,7 +49,7 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"columns": {
"id": "Identifier of the ad account, used as the `adAccountId` in the API context header.",
"name": "Display name of the ad account.",
- "roles": "Roles the API client holds on the ad account, such as API Account Read Only.",
+ "roles": "Roles the API user holds on the ad account, such as API Account Read Only.",
"orgId": "Identifier of the organization the ad account belongs to.",
"orgName": "Display name of the organization.",
"currency": "Three-letter ISO currency code the organization is billed in.",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/apple_search_ads/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/apple_search_ads/source.py
index 9d0e3a31a3a2..1471c9d1ecea 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/apple_search_ads/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/apple_search_ads/source.py
@@ -75,7 +75,7 @@ class AppleSearchAdsSource(ResumableSource[AppleSearchAdsSourceConfig, AppleSear
"400 Client Error: Bad Request for url: https://appleid.apple.com/auth/oauth2/token": "Apple rejected the signed client secret. Check your client ID, team ID, key ID and private key.",
"401 Client Error: Unauthorized for url: https://appleid.apple.com/auth/oauth2/token": "Apple rejected the signed client secret. Check your client ID, team ID, key ID and private key.",
"401 Client Error: Unauthorized for url: https://api.ads.apple.com": "Apple rejected the access token. Your API client may have been removed. Create a new one in Apple Ads and reconnect this source.",
- "403 Client Error: Forbidden for url: https://api.ads.apple.com": "Apple denied access to this ad account. Check that the API client has the API Account Read Only role for the ad account ID you entered.",
+ "403 Client Error: Forbidden for url: https://api.ads.apple.com": "Apple denied access to this ad account. Check that the API user has the API Account Read Only role for the ad account ID you entered.",
"404 Client Error: Not Found for url: https://api.ads.apple.com": "Apple could not find this ad account. Check the ad account ID, which you can read from `adAccount.id` in Apple's Get User ACL endpoint.",
"400 Client Error: Bad Request for url: https://api.searchads.apple.com": "Apple rejected a reporting request. Some campaign types don't support keyword reporting. If the error persists, remove the keyword_report table or check your campaign types in Apple Ads.",
# Apple occasionally returns an empty HTTP reason phrase for the same 400 condition.
@@ -110,19 +110,24 @@ class AppleSearchAdsSource(ResumableSource[AppleSearchAdsSourceConfig, AppleSear
name=SchemaExternalDataSourceType.APPLE_SEARCH_ADS,
category=DataWarehouseSourceCategory.ADVERTISING,
label="Apple Ads",
+ # Two actors, in this order, because Apple splits the job: an account admin grants the
+ # API role in User Management, and only the user holding that role sees the public key
+ # field on the API tab. Collapsing this into one "an admin creates a client" step reads
+ # tidier and strands every reader who is an admin without an API role.
caption="""Connect your Apple Ads account, formerly Apple Search Ads, to pull campaigns, ad groups, keywords and daily performance into the PostHog Data warehouse.
-Apple does not generate an API key for you. An account admin creates an API client, and you supply your own key pair:
+Apple does not generate an API key for you. You supply your own key pair, and only a user with an API role can register it. An account admin who holds no API role will not see the public key field.
-1. Generate an EC P-256 key pair. On macOS or Linux, run `openssl ecparam -genkey -name prime256v1 -noout -out private-key.pem` and then `openssl ec -in private-key.pem -pubout -out public-key.pem`.
-2. In [Apple Ads](https://ads.apple.com), open **Account settings > API** and add an API client. Paste the contents of `public-key.pem` into the public key field and save it.
-3. Apple then shows the client ID, team ID and key ID. Enter those below, along with the contents of `private-key.pem`.
-4. Read your ad account ID from Apple's Get User ACL endpoint, `GET https://api.ads.apple.com/v1/acls`, under `adAccount.id`. This is not the same value as your organization ID.
+1. In [Apple Ads](https://ads.apple.com), an account admin opens **Account settings > User management** and gives the person setting this up the **API Account Read Only** role.
+2. Generate an EC P-256 key pair. On macOS or Linux, run `openssl ecparam -genkey -name prime256v1 -noout -out private-key.pem` and then `openssl ec -in private-key.pem -pubout -out public-key.pem`.
+3. Signed in as that user, open **Account settings > API**, paste the contents of `public-key.pem` into the public key field and save. Saving the key creates the client.
+4. Apple then shows the client ID, team ID and key ID above the field. Enter those below, along with the contents of `private-key.pem`.
+5. Leave **Ad account ID** blank and connect. The connection won't complete, but PostHog reads Apple's ACL for you and the message names the ad account IDs your credentials can read. Paste one in and connect again. To look it up yourself, read `adAccount.id` from Apple's Get User ACL endpoint, `GET https://api.ads.apple.com/v1/acls`. That call needs an access token, so follow [Apple's OAuth guide](https://developer.apple.com/documentation/apple_ads/implementing-oauth-for-the-apple-search-ads-api) to exchange the credentials from step 4 for one. The ad account ID is not the same value as your organization ID.
PostHog stores the private key encrypted and uses it to sign a short-lived token on every sync. The token itself is never stored.
Reporting tables use daily granularity, which Apple serves for the last 90 days only.""",
- permissionsCaption="""Give the API client the **API Account Read Only** role, which grants read access to the campaign data these tables are built from. The **API Account Manager** role also works if you already use it.""",
+ permissionsCaption="""Assign the **API Account Read Only** role to the user who sets up the connection, under **Account settings > User management**. Apple attaches API roles to users, not to clients. That role grants read access to the campaign data these tables are built from. Pick it rather than the campaign group **API Read Only**, which covers a single campaign group. The **API Account Manager** role also works if you already use it.""",
iconPath="/static/services/apple_search_ads.png",
docsUrl="https://posthog.com/docs/cdp/sources/apple-search-ads",
releaseStatus=ReleaseStatus.ALPHA,
@@ -141,7 +146,7 @@ Reporting tables use daily granularity, which Apple serves for the last 90 days
# requires whichever one the source's API version uses.
required=False,
placeholder="123456789",
- caption="Read this from `adAccount.id` in the response from Apple's Get User ACL endpoint, `GET https://api.ads.apple.com/v1/acls`.",
+ caption="Leave this blank and connect, and PostHog lists the ad account IDs your credentials can read. To look it up yourself, read `adAccount.id` from Apple's Get User ACL endpoint, `GET https://api.ads.apple.com/v1/acls`. That call needs an access token signed with the credentials above, not the credentials themselves.",
secret=False,
),
SourceFieldInputConfig(