---
title: "Upsert discovered platform accounts for a connection"
method: POST
path: "/connections/{connection_id}/accounts"
---

# Upsert discovered platform accounts for a connection

`POST /connections/{connection_id}/accounts`

## Request

- Base URL: `https://api.gravityads.dev` (the document declares no server; this is the origin it was published from)
- URL: `https://api.gravityads.dev/connections/{connection_id}/accounts`
- Auth: HTTP bearer

## Request body

- object
  - `customer_group_id` string
  - `accounts` object[]
    - `id` string
    - `customer_group_id` string
    - `customer_name` string
    - `platform` 'google' | 'meta' | 'microsoft' | 'bing' | 'tiktok' | 'criteo' | 'media_go' | 'pinterest' | 'linkedin' | 'amazon'
    - `account_id` string, required
    - `account_number` string
    - `account_name` string
    - `manager_account_id` string
    - `account_type` 'client' | 'manager' | 'unknown'
    - `billing_transfer_status` string
    - `status` string
    - `latest_metric_date` string
    - `latest_etl_run_id` string
    - `provider_account_status` string
    - `provider_account_status_raw` string
    - `provider_account_status_reason` string
    - `provider_account_status_checked_at` string
  - `provider_accounts` object[]: Raw provider account discovery records from a supported ad platform. They are normalized server-side before control-plane upsert.
  - `queue_day1_backfill` boolean: When true, queues readonly day-1 ETL runs immediately after the discovered accounts are upserted.
  - `backfill_date_range_start` string, date
  - `backfill_date_range_end` string, date
  - `backfill_run_type` string

## Response `200`

Connection accounts upserted

- object
  - `status` 'connection_accounts_upserted' | 'connection_accounts_upsert_unconfigured' | 'connection_accounts_upsert_failed' | 'connection_accounts_upsert_degraded', required
  - `tenant_id` string, required
  - `connection_id` string, required
  - `platform_account_count` integer
  - `platform_accounts` object[]
  - `customer_group_count` integer
  - `account_scope_count` integer
  - `day1_backfill` object
  - `provider_accounts_normalized` boolean
  - `database_url_configured` boolean
  - `hosted_auth_context` object
  - `raw_secrets_returned` false, required

---

[API](https://skmtc.dev/gravityads/apis/gravityads-api.md) · [All operations](https://skmtc.dev/gravityads/apis/gravityads-api/llms.txt) · [OpenAPI document](https://skmtc.dev/gravityads/apis/gravityads-api/revisions/124cd07d534d?raw)
