---
title: "Start an ad account OAuth connection"
description: "PubNio API ads.connectAccount: start an ad account OAuth connection. Request fields, examples in five clients, errors, and idempotency."
---

> Documentation Index
> Fetch the complete documentation index at: https://pubnio.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Start an ad account OAuth connection

Start an ad account OAuth connection with [`POST /api/v1/ads/accounts/connect`](https://pubnio.com/api/v1/docs#tag/ads/POST/api/v1/ads/accounts/connect). Requires a signed-in workspace owner, in the web app or the CLI; API keys are not accepted and MCP cannot call it.

## Request

Open the returned URL as the same PubNio user. Check the shared attempt route for the result, then select discovered accounts explicitly.

| Body field    | Type             | Required |
| ------------- | ---------------- | -------- |
| `workspaceId` | UUID             | Yes      |
| `provider`    | one of 9 strings | Yes      |
| `accountId`   | UUID             | No       |

## Response

- HTTP 200: `AdConnectLaunch` with `attemptId`, `provider`, `url`, `status`.
  - `provider`: `meta_ads`, `google_ads`, `reddit_ads`, `pinterest_ads`, `tiktok_ads`, `linkedin_ads`, `snapchat_ads`, `amazon_ads`, `openai_ads`

The [OpenAPI document](https://pubnio.com/api/v1/openapi) has each field's type.

## Examples

### TypeScript

```ts
const launch = await workspace.ads.connect({
  workspaceId: workspace.workspaceId,
  provider: "meta_ads",
});
```

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

### Python

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

### cURL

```sh
curl -X POST "https://pubnio.com/api/v1/ads/accounts/connect" \
  -H "Authorization: Bearer $PUBNIO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"workspaceId":"'"$WORKSPACE_ID"'","provider":"meta_ads"}'
```

### CLI

```sh
pnio ads connect-account --workspace-id "$WORKSPACE_ID" --provider meta_ads
```

### MCP execute

```js
async () => {
  const response = await codemode.request({
    method: "POST",
    path: "/api/v1/ads/accounts/connect",
    body: { workspaceId: codemode.workspaceId, provider: "meta_ads" },
  });
  return response.data;
};
```

## Errors

It declares no problem of its own.

It declares the problems [every Ads operation](https://pubnio.com/docs/reference/#ads) and [most operations](https://pubnio.com/docs/reference/#shared-problems) 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.

## Related

- [Ads operations](https://pubnio.com/docs/reference/#ads)

Source: https://pubnio.com/docs/reference/ads-connect-account/index.mdx
