Skip to content

Connect an ad account with an API key

PubNio API ads.connectApiKeyAccount: connect an ad account with an API key. Request fields, examples in five clients, errors, and idempotency.

Connect an ad account with an API key with POST /api/v1/ads/accounts/connect/api-key. Requires a signed-in workspace owner, in the web app or the CLI; API keys are not accepted and MCP cannot call it.

Request

Verifies the provider API key, seals it, and creates the ad account in one call. Select the returned account explicitly before syncing or spending.

Body field Type Required
workspaceId UUID Yes
provider "openai_ads" Yes
apiKey string Yes
accountId UUID No
profileId UUID No

Response

  • HTTP 200: AdApiKeyConnectResult with provider, accountId, status.

The OpenAPI document has each field’s type.

Examples

const connected = await workspace.ads.connectApiKey({
  provider: "openai_ads",
  apiKey: process.env.OPENAI_ADS_KEY ?? "",
});

Create this client with a signed-in person’s accessToken, not an apiKey.

The Python SDK authenticates with a workspace API key, which this operation does not accept, so it has no method for it.

curl -X POST "https://pubnio.com/api/v1/ads/accounts/connect/api-key" \
  -H "Authorization: Bearer $PUBNIO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"workspaceId":"'"$WORKSPACE_ID"'","provider":"openai_ads","apiKey":"YOUR_OPENAI_ADS_KEY"}'
pnio ads connect-api-key-account --workspace-id "$WORKSPACE_ID" --provider openai_ads --api-key "$OPENAI_ADS_KEY"
async () => {
  const response = await codemode.request({
    method: "POST",
    path: "/api/v1/ads/accounts/connect/api-key",
    body: {
      workspaceId: codemode.workspaceId,
      provider: "openai_ads",
      apiKey: "YOUR_OPENAI_ADS_KEY",
    },
  });
  return response.data;
};

Errors

It declares no problem of its own.

It declares the problems every Ads operation and most operations declare.

Idempotency

No key, so a retried POST is not deduplicated. Read the current state before you retry.

Limits

  • API keys and MCP cannot call it. A signed-in person runs it from the CLI after pnio auth login or in the web app.

Type to search…

↑↓ navigate↵ selectEsc close