# Turn X analytics on or off

Source: https://ampost.io/docs/api/accounts-set-analytics · Full reference: https://ampost.io/llms-full.txt

`PATCH /api/accounts/{accountId}/analytics` · MCP tool `accounts_set_analytics` · scope `accounts:write` · rate limit `connectPlatform` · success `200`

Opt an X account in to analytics, or out again. Every X read is billed, so X analytics are off until the account opts in, and the reads count against the plan's 30-day X units like publishing (Max and Scale). When on, Ampost reads the metrics of the posts it published to the account during their first 29 days (daily for 3 days, then weekly) and the follower count once a day; three post reads or one follower read cost one X unit. The sync pauses when the units run out and resumes when they reset. Other platforms need no opt-in (`analytics.optInRequired` is false) and return 400. A plan without X returns 403 UPGRADE_REQUIRED. Returns the account with its `analytics` state.

| Field | In | Type | Required | Description |
|---|---|---|---|---|
| `accountId` | path | string | yes | Account id (UUID): `id` from accounts_list |
| `enabled` | body | boolean | yes | `true` starts the metered X analytics sync for the account; `false` stops it |

Example request:

```json
{
  "enabled": true
}
```

Example response:

```json
{
  "id": "9a4e2c7b-3d1f-4b8a-9c6e-5f2a8d1b7c40",
  "platform": "twitter",
  "platformSetId": "0b6e4d2a-9c3f-4e1b-8a7d-5f2c1e9b3d40",
  "platformAccountId": "1580000000000000000",
  "username": "ampost_io",
  "avatarUrl": null,
  "status": "active",
  "scopes": [
    "tweet.read",
    "tweet.write",
    "users.read",
    "media.write",
    "offline.access"
  ],
  "tokenExpiresAt": "2026-10-07T11:00:00.000Z",
  "tokenHealth": "healthy",
  "health": {
    "canPost": true,
    "needsReconnect": false,
    "issues": []
  },
  "platformMetadata": {},
  "analytics": {
    "available": true,
    "optInRequired": true,
    "enabled": true
  },
  "createdAt": "2026-10-06T09:00:00.000Z",
  "updatedAt": "2026-10-07T10:00:00.000Z",
  "lastUsedAt": "2026-10-06T09:00:04.000Z"
}
```
