# Select Facebook page

Selects a Facebook page. Works with Facebook accounts.

```http
POST https://api.pozy.ai/v1/connect/facebook/select-page
```

- Area: Accounts & connections / Connect
- Auth: API key plus X-Connect-Token header

## Request body

Content type: `application/json`


## Example request

```bash
curl -X POST "https://api.pozy.ai/v1/connect/facebook/select-page" \
  -H "X-Connect-Token: $CONNECT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "profileId": "6a0b6573846efc28aaa9a3ff",
  "userProfile": {
    "id": "6bfebd43ddc270f6d2c56fc5",
    "name": "Acme",
    "profilePicture": "string"
  }
}'
```

```ts
const res = await fetch("https://api.pozy.ai/v1/connect/facebook/select-page", {
  method: "POST",
  headers: {
    "X-Connect-Token": process.env.CONNECT_TOKEN!,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    profileId: "6a0b6573846efc28aaa9a3ff",
    userProfile: {
      id: "6bfebd43ddc270f6d2c56fc5",
      name: "Acme",
      profilePicture: "string"
    }
  }),
});
const data = await res.json();
if (!res.ok) throw new Error(data?.error ?? `Request failed with status ${res.status}`);
console.log(data);
```

```python
import os
import requests

resp = requests.post(
    "https://api.pozy.ai/v1/connect/facebook/select-page",
    headers={"X-Connect-Token": os.environ["CONNECT_TOKEN"]},
    json={
        "profileId": "6a0b6573846efc28aaa9a3ff",
        "userProfile": {
            "id": "6bfebd43ddc270f6d2c56fc5",
            "name": "Acme",
            "profilePicture": "string",
        },
    },
    timeout=30,
)
resp.raise_for_status()
print(resp.json())
```

## Response 200

- `message`, string
- `redirect_url`, string
- `adsAccountId`, string
- `account`, object
  - `accountId`, string
  - `platform`, string: One of `facebook`
  - `username`, string
  - `displayName`, string
  - `profilePicture`, string
  - `isActive`, boolean
  - `selectedPageName`, string
- `accounts`, array of object
- `failed`, array of object
  - `id`, string
  - `code`, string
  - `message`, string

```json
{
  "message": "Hello from Pozy",
  "redirect_url": "https://pozy.ai/media/example-1.jpg",
  "adsAccountId": "689782c4c50e3b783a5acd69",
  "account": {
    "accountId": "696e0b682d0a31188e7a2ba9",
    "platform": "facebook",
    "username": "acme",
    "displayName": "Acme",
    "profilePicture": "string",
    "isActive": true,
    "selectedPageName": "Acme"
  },
  "accounts": [
    {}
  ],
  "failed": [
    {
      "id": "6bfebd43ddc270f6d2c56fc5",
      "code": "string",
      "message": "Hello from Pozy"
    }
  ]
}
```
