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

# Get ad-server connection

> Read the connection state for an ad-server-backed inventory source

`GET /api/v2/storefront/inventory-sources/{sourceId}/esa`

Returns the connection state for an ad-server-backed (`MANAGED_SALES_AGENT`) source: enabled/disabled state (`deactivatedAt`), upstream endpoints, the non-secret ad-server config view, the most recent failure (`lastErrorCode`/`lastError`), and cached inventory-sync state.

## Request

<CodeGroup>
  ```bash curl theme={null}
  curl https://api.interchange.io/api/v2/storefront/inventory-sources/retail-gam/esa \
    -H "Authorization: Bearer $SCOPE3_API_KEY"
  ```
</CodeGroup>

## Parameters

| Field      | Type          | Required | Notes                                 |
| ---------- | ------------- | -------- | ------------------------------------- |
| `sourceId` | string (path) | Yes      | Storefront-scoped inventory source ID |

## Response

```json theme={null}
{
  "id": "550199",
  "customerId": 4210,
  "tenantId": "tnt_retail_gam",
  "mcpUrl": "/mcp/",
  "a2aUrl": "/a2a",
  "adServer": { "type": "google_ad_manager", "networkCode": "12345678" },
  "serviceAccountEmail": "retail-gam-4210@scope3-esa.iam.gserviceaccount.com",
  "lastError": null,
  "lastErrorCode": null,
  "lastTestedAt": "2026-05-02T09:14:00Z",
  "provisionedAt": "2026-04-25T12:10:00Z",
  "deactivatedAt": null,
  "createdAt": "2026-04-25T12:05:00Z",
  "updatedAt": "2026-05-02T09:14:00Z",
  "inventorySync": {
    "status": "success",
    "lastRunAt": "2026-05-02T08:00:00Z",
    "completedAt": "2026-05-02T08:03:00Z",
    "itemCount": 1840,
    "error": null,
    "updatedAt": "2026-05-02T08:03:00Z"
  }
}
```

The connection is enabled unless `deactivatedAt` is set (`null` means enabled); whether it is live and sellable is derived from the [status endpoint](/v2/storefront/inventory-sources/tasks/get-status) (`operational.isLive`), not from a field on this response. `adServer` is the non-secret config view and never contains credentials. `lastErrorCode` classifies the most recent failure (`ADAPTER_NETWORK_NOT_FOUND`, `ADAPTER_PERMISSION_DENIED`, `ADAPTER_INVALID_CREDENTIALS`, `ADAPTER_INVALID_CONFIG`, `ADAPTER_CONNECTION_FAILED`, or `INTERNAL_ERROR`), with the human-readable detail in `lastError`. `inventorySync` is null until the first sync signal lands.

## Errors

* `401 UNAUTHORIZED` — missing or invalid API key.
* `404 NOT_FOUND` — no ad-server-backed source with this `sourceId`.

See [Errors](/v2/reference/errors) for the full error contract.

## Related

<CardGroup cols={2}>
  <Card title="Inventory source tasks" href="/v2/storefront/inventory-sources/tasks" icon="list-check">
    All operations
  </Card>

  <Card title="Get status" href="/v2/storefront/inventory-sources/tasks/get-status" icon="heart-pulse">
    Operational snapshot
  </Card>

  <Card title="Replace ad-server config" href="/v2/storefront/inventory-sources/tasks/replace-ad-server-config" icon="gear">
    Set the ad-server config
  </Card>

  <Card title="Test connection" href="/v2/storefront/inventory-sources/tasks/test-connection" icon="plug-circle-check">
    Probe upstream reachability
  </Card>
</CardGroup>
