> ## 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.

# Replace ad-server source config

> Set the ad-server configuration on an ad-server-backed inventory source. The body is a full replacement (PUT semantics); PATCH is accepted as an alias for backwards compatibility with the legacy /esa/ad-server route.



## OpenAPI

````yaml /v2/storefront-api-v2.yaml put /inventory-sources/{sourceId}/ad-server
openapi: 3.0.0
info:
  title: Scope3 Storefront API
  version: 2.0.0
  description: |-
    REST API for partners to manage storefronts, inventory sources, and billing.

    ## Authentication

    All endpoints require a Bearer token in the Authorization header:
    ```
    Authorization: Bearer your-api-key
    ```

    ## Base URL

    `https://api.interchange.io/api/v2/storefront`

    ## For AI Agents

    AI agents can use the MCP endpoint at `/mcp/v2/storefront` with three tools:
    - `initialize`: Start an MCP session
    - `api_call`: Make REST API calls
    - `ask_about_capability`: Learn about API features
servers:
  - url: https://api.interchange.io/api/v2/storefront
    description: Production server
security: []
tags:
  - name: Account
    description: Account management, service tokens, and preferences
  - name: Storefront
    description: Manage storefront and inventory sources
  - name: Storefront Agents
    description: List and manage registered sales, signals, and outcomes agents
  - name: Storefront Activity
    description: Audit log of configuration and inventory changes on the storefront
  - name: Storefront Billing
    description: Payout bank details and billing configuration for storefronts
  - name: AI Usage
    description: Storefront AI token usage visibility by model
  - name: MCP
    description: Model Context Protocol endpoints
paths:
  /inventory-sources/{sourceId}/ad-server:
    put:
      tags:
        - Storefront
      summary: Replace ad-server source config
      description: >-
        Set the ad-server configuration on an ad-server-backed inventory source.
        The body is a full replacement (PUT semantics); PATCH is accepted as an
        alias for backwards compatibility with the legacy /esa/ad-server route.
      operationId: putInventorySourceAdServer
      parameters:
        - in: path
          name: sourceId
          schema:
            description: Inventory source ID
            type: string
            minLength: 1
          required: true
          description: Inventory source ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AdServerConfig'
      responses:
        '200':
          description: Replace ad-server source config
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EsaConnection'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    AdServerConfig:
      description: >-
        Discriminated union of supported ad-server configurations. Includes
        credentials for adapter types that authenticate with publisher-supplied
        credentials (FreeWheel, SpringServe); those credentials are forwarded to
        the managed ad-server source and never persisted by Scope3.
      oneOf:
        - $ref: '#/components/schemas/GamAdServerConfig'
        - $ref: '#/components/schemas/FreeWheelAdServerConfig'
        - $ref: '#/components/schemas/SpringServeAdServerConfig'
        - $ref: '#/components/schemas/AdsWizzAdServerConfig'
      type: object
      discriminator:
        propertyName: type
        mapping:
          google_ad_manager:
            $ref: '#/components/schemas/GamAdServerConfig'
          freewheel:
            $ref: '#/components/schemas/FreeWheelAdServerConfig'
          springserve:
            $ref: '#/components/schemas/SpringServeAdServerConfig'
          adswizz:
            $ref: '#/components/schemas/AdsWizzAdServerConfig'
    EsaConnection:
      description: >-
        Storefront → managed ad-server source connection. A storefront can have
        multiple connections, each addressed by `id`.
      type: object
      properties:
        id:
          description: >-
            Stable id for this managed ad-server source. Use this id to address
            per-source actions (provision, deactivate, save ad-server config,
            etc.). A customer can have multiple managed sources.
          type: string
        customerId:
          description: Owning customer/storefront id.
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
        tenantId:
          description: >-
            Upstream managed-source id for the managed ad-server source. Null
            until provisioning succeeds.
          nullable: true
          type: string
        mcpUrl:
          description: >-
            MCP endpoint exposed by the provisioned managed ad-server source.
            May be a relative path (e.g. `/mcp/`) — the consumer composes the
            absolute URL using the upstream base URL.
          nullable: true
          type: string
        a2aUrl:
          description: >-
            A2A endpoint exposed by the provisioned managed ad-server source.
            May be a relative path (e.g. `/a2a`) — see `mcpUrl` for resolution.
          nullable: true
          type: string
        adServer:
          description: Publisher-supplied ad-server config. Null if not yet collected.
          nullable: true
          allOf:
            - $ref: '#/components/schemas/AdServerConfigView'
        serviceAccountEmail:
          description: >-
            Per-customer service-account email the publisher must grant access
            to in their ad server. Created when ad-server config is saved.
            Surfaced so the UI can show it during onboarding.
          nullable: true
          type: string
          format: email
          pattern: >-
            ^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$
        lastError:
          description: >-
            Failure reason from the most recent provisioning or test-connection
            attempt.
          nullable: true
          type: string
        lastErrorCode:
          description: >-
            Machine-readable classification of the most recent provisioning
            failure. `ADAPTER_NETWORK_NOT_FOUND` (typo),
            `ADAPTER_PERMISSION_DENIED` (GAM grant still propagating),
            `ADAPTER_INVALID_CREDENTIALS` (storefront service account broken),
            `ADAPTER_INVALID_CONFIG` (bad field-level config), and
            `ADAPTER_CONNECTION_FAILED` (transient blip) are the adapter probe
            failures. `INTERNAL_ERROR` indicates an upstream or platform
            problem. Null when there has been no failure or after a successful
            provision.
          nullable: true
          type: string
        lastTestedAt:
          nullable: true
          type: string
          format: date-time
          pattern: >-
            ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
        provisionedAt:
          nullable: true
          type: string
          format: date-time
          pattern: >-
            ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
        deactivatedAt:
          nullable: true
          type: string
          format: date-time
          pattern: >-
            ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
        createdAt:
          type: string
          format: date-time
          pattern: >-
            ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
        updatedAt:
          type: string
          format: date-time
          pattern: >-
            ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
        inventorySync:
          description: >-
            Cached inventory-sync state. Null when no signal has landed yet (no
            webhook delivered and no /status poll has run).
          nullable: true
          allOf:
            - $ref: '#/components/schemas/EsaInventorySync'
      required:
        - id
        - customerId
        - tenantId
        - mcpUrl
        - a2aUrl
        - adServer
        - serviceAccountEmail
        - lastError
        - lastErrorCode
        - lastTestedAt
        - provisionedAt
        - deactivatedAt
        - createdAt
        - updatedAt
        - inventorySync
      additionalProperties: false
    ErrorResponse:
      description: Standard error response
      type: object
      properties:
        data:
          type: string
          nullable: true
          enum:
            - null
        error:
          $ref: '#/components/schemas/ApiError'
      required:
        - data
        - error
      additionalProperties: false
    GamAdServerConfig:
      description: >-
        Google Ad Manager configuration. Per-customer service-account
        credentials are managed by Scope3 (publisher grants access in their GAM
        admin console).
      type: object
      properties:
        type:
          type: string
          enum:
            - google_ad_manager
        networkCode:
          description: Google Ad Manager network code.
          example: '12345678'
          type: string
          minLength: 1
          maxLength: 32
          pattern: ^[0-9]+$
      required:
        - type
        - networkCode
    FreeWheelAdServerConfig:
      description: >-
        FreeWheel Publisher API adapter configuration. Credentials are forwarded
        to the managed ad-server source at provision time and never persisted by
        Scope3.
      type: object
      properties:
        type:
          type: string
          enum:
            - freewheel
        clientId:
          description: >-
            FreeWheel Publisher API client ID for the OAuth2 client_credentials
            grant. Required with `clientSecret`; omit when using legacy
            `username`/`password` or `apiToken`.
          type: string
          minLength: 1
          maxLength: 255
        clientSecret:
          description: >-
            FreeWheel Publisher API client secret for the OAuth2
            client_credentials grant. Required with `clientId`. Write-only —
            never returned by the API or persisted by Scope3.
          type: string
          minLength: 1
        username:
          description: >-
            Legacy FreeWheel Publisher API username for password-grant
            authentication. Prefer `clientId` + `clientSecret` for
            partner-program credentials.
          type: string
          minLength: 1
          maxLength: 255
        password:
          description: >-
            Legacy FreeWheel Publisher API password for password-grant
            authentication. Write-only — never returned by the API or persisted
            by Scope3.
          type: string
          minLength: 1
        apiToken:
          description: >-
            Pre-minted FreeWheel API token (e.g. a 7-day temporary access key).
            Write-only — only used when no client ID/client secret is supplied.
            Recommended for testing only; production deployments should use the
            client ID/client secret path which auto-refreshes.
          type: string
          minLength: 1
        environment:
          description: FreeWheel environment to target.
          default: production
          type: string
          enum:
            - production
            - staging
        defaultAdvertiserId:
          description: Optional default FreeWheel advertiser id.
          type: string
          maxLength: 64
      required:
        - type
    SpringServeAdServerConfig:
      description: >-
        SpringServe (Magnite) adapter configuration. Credentials are forwarded
        to the managed ad-server source at provision time and never persisted by
        Scope3.
      type: object
      properties:
        type:
          type: string
          enum:
            - springserve
        email:
          description: >-
            SpringServe login email. Required when authenticating with password
            grant; omit when using `apiToken`.
          type: string
          maxLength: 255
          format: email
          pattern: >-
            ^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$
        password:
          description: >-
            SpringServe password. Required when authenticating with password
            grant. Write-only — never returned by the API or persisted by
            Scope3.
          type: string
          minLength: 1
        apiToken:
          description: >-
            Pre-minted SpringServe API token. Write-only — only used when no
            email/password is supplied. Recommended for testing only; production
            deployments should use the email/password grant which
            auto-refreshes.
          type: string
          minLength: 1
        environment:
          description: SpringServe environment. Only `production` is supported.
          default: production
          type: string
          enum:
            - production
        defaultDemandPartnerId:
          description: Optional default SpringServe demand partner id.
          type: integer
          maximum: 9007199254740991
          minimum: 1
      required:
        - type
    AdsWizzAdServerConfig:
      description: >-
        AdsWizz Domain API v8 (streaming audio + podcast) adapter configuration.
        The static API key is forwarded to the managed ad-server source at
        provision time and never persisted by Scope3.
      type: object
      properties:
        type:
          type: string
          enum:
            - adswizz
        apiKey:
          description: >-
            AdsWizz static API key, sent as the `x-api-key` header on every
            request. Required on write; write-only — never returned by the API
            or persisted by Scope3.
          writeOnly: true
          type: string
          minLength: 1
        agencyId:
          description: >-
            AdsWizz agency id (sent as the `agency` header; scopes the billing
            currency and CPM ceiling).
          type: integer
          maximum: 9007199254740991
          minimum: 1
        environment:
          description: >-
            AdsWizz surface. Pinned to AUDIOSERVE (direct trafficking);
            AUDIOMAX/AUDIOMATIC are SSP-only and not supported.
          default: AUDIOSERVE
          type: string
          enum:
            - AUDIOSERVE
        baseUrl:
          description: AdsWizz Domain API v8 base URL.
          default: https://api.adswizz.com/domain/v8
          type: string
          format: uri
        forecastingBaseUrl:
          description: AdsWizz Forecasting API v3 base URL (backs availability).
          default: https://api.adswizz.com/forecasting/v3
          type: string
          format: uri
        defaultCurrency:
          description: >-
            Three-letter currency code the agency bills in (e.g. ZAR). Required
            — AdsWizz fixes the billing currency per agency, so it must be
            stated explicitly rather than defaulted; selected product pricing
            must match it.
          type: string
          pattern: ^[A-Z]{3}$
        cpmLimit:
          description: >-
            Agency CPM ceiling. Every rate is guarded against this before any
            write.
          default: null
          nullable: true
          type: number
          minimum: 0
          exclusiveMinimum: true
        defaultAdvertiserId:
          description: >-
            Fallback AdsWizz advertiser id for principals without an explicit
            AdsWizz mapping.
          default: null
          nullable: true
          type: string
          maxLength: 64
      required:
        - type
        - agencyId
        - defaultCurrency
    AdServerConfigView:
      description: >-
        Non-secret view of the connection ad-server config. Returned by GET
        endpoints; never contains credentials.
      oneOf:
        - $ref: '#/components/schemas/GamAdServerConfigOutput'
        - type: object
          properties:
            type:
              type: string
              enum:
                - freewheel
            clientId:
              nullable: true
              type: string
            username:
              nullable: true
              type: string
            environment:
              type: string
              enum:
                - production
                - staging
            defaultAdvertiserId:
              nullable: true
              type: string
          required:
            - type
            - clientId
            - username
            - environment
            - defaultAdvertiserId
          additionalProperties: false
        - type: object
          properties:
            type:
              type: string
              enum:
                - springserve
            email:
              nullable: true
              type: string
            environment:
              type: string
              enum:
                - production
            defaultDemandPartnerId:
              nullable: true
              type: integer
              minimum: -9007199254740991
              maximum: 9007199254740991
          required:
            - type
            - email
            - environment
            - defaultDemandPartnerId
          additionalProperties: false
        - type: object
          properties:
            type:
              type: string
              enum:
                - adswizz
            agencyId:
              type: integer
              minimum: -9007199254740991
              maximum: 9007199254740991
            environment:
              type: string
              enum:
                - AUDIOSERVE
            baseUrl:
              type: string
            forecastingBaseUrl:
              type: string
            defaultCurrency:
              type: string
            cpmLimit:
              nullable: true
              type: number
            defaultAdvertiserId:
              nullable: true
              type: string
          required:
            - type
            - agencyId
            - environment
            - baseUrl
            - forecastingBaseUrl
            - defaultCurrency
            - cpmLimit
            - defaultAdvertiserId
          additionalProperties: false
      type: object
    EsaInventorySync:
      description: >-
        Cached inventory-sync state for this managed ad-server source. Updated
        by the /webhooks/esa-sync receiver when the upstream service emits
        `sync_run.completed` / `sync_run.failed`, and by the /status polling
        fallback for missed deliveries.
      type: object
      properties:
        status:
          nullable: true
          description: >-
            Last known inventory-sync state on the upstream managed source.
            `unknown` means we have no signal yet (row predates the sync
            tracking, no webhook or status poll has landed). Other values mirror
            the upstream managed-source vocabulary.
          type: string
          enum:
            - unknown
            - never_run
            - running
            - success
            - failed
        lastRunAt:
          nullable: true
          type: string
          format: date-time
          pattern: >-
            ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
        completedAt:
          nullable: true
          type: string
          format: date-time
          pattern: >-
            ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
        itemCount:
          nullable: true
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
        error:
          nullable: true
          type: string
        updatedAt:
          nullable: true
          type: string
          format: date-time
          pattern: >-
            ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
      required:
        - status
        - lastRunAt
        - completedAt
        - itemCount
        - error
        - updatedAt
      additionalProperties: false
    ApiError:
      description: Structured error object
      type: object
      properties:
        code:
          description: Machine-readable error code
          type: string
        message:
          description: Human-readable error message
          type: string
        field:
          description: Field path associated with the error
          type: string
        details:
          description: Additional error context
          type: object
          additionalProperties: {}
      required:
        - code
        - message
      additionalProperties: false
    GamAdServerConfigOutput:
      description: >-
        Google Ad Manager configuration. Per-customer service-account
        credentials are managed by Scope3 (publisher grants access in their GAM
        admin console).
      type: object
      properties:
        type:
          type: string
          enum:
            - google_ad_manager
        networkCode:
          description: Google Ad Manager network code.
          example: '12345678'
          type: string
          minLength: 1
          maxLength: 32
          pattern: ^[0-9]+$
      required:
        - type
        - networkCode
      additionalProperties: false
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API key or access token

````