Skip to main content

Accounts

The Accounts API provides access to the Meta ad accounts connected to your KlayrAI workspace.

List accounts

Retrieve all connected Meta ad accounts in your workspace.

Query parameters

ParameterTypeRequiredDefaultDescription
statusstringNoFilter by connection status: active, disconnected, token_expired
pageintegerNo1Page number
page_sizeintegerNo20Results per page (max 100)

Request

curl -X GET "https://api.klayrai.com/v1/accounts" \
  -H "x-api-key: klyr_live_abc123def456ghi789" \
  -H "klayrai-version: 2026-03-01"

Response

{
  "data": [
    {
      "id": "act_001",
      "metaAccountId": "act_123456789",
      "name": "Acme Corp - Main",
      "currency": "EUR",
      "timezone": "Europe/Amsterdam",
      "status": "active",
      "connectionStatus": "active",
      "businessName": "Acme Corporation",
      "businessId": "1234567890",
      "permissions": ["read_insights", "read_campaigns", "read_ads"],
      "lastSyncedAt": "2026-03-10T14:00:00Z",
      "campaignCount": 12,
      "activeCampaignCount": 5,
      "totalSpendLast30d": 14200.00,
      "connectedAt": "2026-02-10T08:00:00Z",
      "connectedBy": "user_abc123"
    },
    {
      "id": "act_002",
      "metaAccountId": "act_987654321",
      "name": "Acme Corp - EU Market",
      "currency": "EUR",
      "timezone": "Europe/Berlin",
      "status": "active",
      "connectionStatus": "active",
      "businessName": "Acme Corporation",
      "businessId": "1234567890",
      "permissions": ["read_insights", "read_campaigns", "read_ads"],
      "lastSyncedAt": "2026-03-10T14:00:00Z",
      "campaignCount": 8,
      "activeCampaignCount": 3,
      "totalSpendLast30d": 8750.00,
      "connectedAt": "2026-02-15T09:30:00Z",
      "connectedBy": "user_abc123"
    }
  ],
  "pagination": {
    "total": 2,
    "page": 1,
    "page_size": 20,
    "hasMore": false
  }
}

Account object fields

FieldTypeDescription
idstringKlayrAI account ID
metaAccountIdstringMeta ad account ID (format: act_XXXXXXXXX)
namestringAccount name as set in Meta Business Manager
currencystringAccount currency (ISO 4217)
timezonestringAccount timezone (IANA format)
statusstringMeta account status: active, disabled, closed
connectionStatusstringKlayrAI connection status: active, disconnected, token_expired
businessNamestringParent business name
businessIdstringMeta Business Manager ID
permissionsstring[]Granted permissions
lastSyncedAtstringISO 8601 timestamp of last data sync
campaignCountintegerTotal campaigns in the account
activeCampaignCountintegerCurrently active campaigns
totalSpendLast30dnumberTotal spend in the last 30 days (in account currency)
connectedAtstringISO 8601 timestamp when the account was connected
connectedBystringUser ID who connected the account

Connection statuses

StatusDescriptionAction required
activeAccount is connected and syncing normallyNone
disconnectedUser manually disconnected the accountReconnect via the dashboard
token_expiredMeta access token has expiredRe-authenticate via the dashboard
When a token expires, KlayrAI stops syncing data for that account. Diagnostics and reports will still be available for historical data, but new data will not be pulled until the account is re-authenticated.

Error codes

StatusCodeDescription
400invalid_requestInvalid query parameters
401authentication_errorInvalid or missing API key
403plan_insufficientAPI access requires the Agency plan
429rate_limit_errorRate limit exceeded
500api_errorInternal server error