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

# Connected accounts

> Find the socialAccountId that every posting call needs.

Every posting, scheduling and analytics call is addressed to one connected
social account. This is where you get its id.

## List the accounts

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.sapt.ai/socials/accounts/$PROJECT_ID \
    -H "Authorization: ApiKey $SAPT_API_KEY"
  ```

  ```typescript TypeScript theme={null}
  const res = await fetch(
    `https://api.sapt.ai/socials/accounts/${projectId}`,
    { headers: { Authorization: `ApiKey ${process.env.SAPT_API_KEY}` } }
  )
  const { data } = await res.json()
  ```

  ```python Python theme={null}
  import os, requests

  res = requests.get(
      f"https://api.sapt.ai/socials/accounts/{project_id}",
      headers={"Authorization": f"ApiKey {os.environ['SAPT_API_KEY']}"},
  )
  accounts = res.json()["data"]["accounts"]
  ```
</CodeGroup>

```json Response theme={null}
{
  "success": true,
  "data": {
    "accounts": [
      {
        "id": "9f1c2f7a-4c9e-4a1d-9d0e-8a5b6c7d8e9f",
        "platform": "instagram",
        "platformAccountId": "17841400000000000",
        "username": "yarimonter0",
        "displayName": "Yari Montero",
        "profilePictureUrl": "https://…/pic.jpg",
        "profileUrl": "https://instagram.com/yarimonter0",
        "followersCount": 12840,
        "isActive": true,
        "tokenExpiresAt": "2026-11-04T09:12:00Z",
        "createdAt": "2026-03-11T18:22:41Z"
      }
    ]
  }
}
```

## The fields that matter

| Field               | Why you care                                                                                                                                         |
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`                | **This is the `socialAccountId`** every posting and analytics endpoint takes. A Sapt UUID, not a platform id.                                        |
| `platform`          | Which platform this account posts to. Pass the same value as `platform` when creating a post.                                                        |
| `platformAccountId` | The platform's own id — an Instagram Business Account id, a Facebook Page id. Used by comment and analytics endpoints that address platform objects. |
| `isActive`          | `false` means the connection is disabled. Posting to it will fail.                                                                                   |
| `tokenExpiresAt`    | When the stored credential lapses. Past this, publishing fails until the account is reconnected in the dashboard.                                    |

<Warning>
  `id` and `platformAccountId` are different values and are not interchangeable.
  Posting endpoints take `id`; comment and engagement endpoints that address a
  platform object (a post, a media item, a comment) take platform-native ids.
</Warning>

## Before you publish

Two fields decide whether a publish will succeed. Check them first:

```typescript theme={null}
const usable = accounts.filter(
  (a) =>
    a.isActive &&
    (a.tokenExpiresAt === null || new Date(a.tokenExpiresAt) > new Date())
)
```

An account that fails either check needs to be reconnected from the Sapt
dashboard — the API cannot refresh a lapsed grant on its own.
