@adcp/sdk API Reference - v17.0.0-rc.0
    Preparing search index...

    Class BuyerAccountRegistry

    Index
    • Get an account for a natural key at this seller (AdCP 3.3). Routes by capability: request_account when the seller advertises account.requests, otherwise sync_accounts. Either way it resolves to an AccountOutcome: ready, pending, ambiguous or rejected. Pending, ambiguous and rejected are values, not errors; only a failure to process the call throws (AccountRequestError on the request_account path, the typed account errors on sync_accounts).

      Idempotent per (seller, caller, natural key): a repeat call returns the account, or the open request's current state, and never opens a duplicate. currency and timezone join the key when it does not carry them. Billing terms are sent only when an account is first requested.

      Breaking in SDK 17 (AdCP 3.3): ensure used to resolve to the registry's ProvisionedAccount. That call is now BuyerAccountRegistry.provision.

      Parameters

      Returns Promise<AccountOutcome>

    • Re-read open requests and accounts pending approval; resolve to the outcomes whose state moved. Call it from a cron job or an account_request.changed webhook. One list_accounts read covers every open request (request_ids); each account pending approval is re-read by its account_id.

      Parameters

      Returns Promise<AccountOutcome[]>

    • Change an account's attributes through request_account (AdCP 3.3 account.requests). Resolves to an AccountChangeOutcome: updated (same account_id, new revision, and effective_at for money terms), separate_account or matched_existing (a different account; the registry is not re-pointed until BuyerAccountRegistry.use), pending, or rejected.

      • Money changes (billing, billing_entity, payment_terms) need options.revision, the revision the change was approved against. The SDK never reads it for you, since that would defeat the lost-update protection. Without it nothing is sent: AccountRequestError with code ACCOUNT_REVISION_REQUIRED and dispatched: false.
      • Other changes read the current revision from list_accounts when omitted, and retry once on CONFLICT when the fields being changed did not change concurrently.
      • allowSeparateAccount defaults to false. A seller that would accept the change only on a new account then rejects it, and the outcome's requiresNewAccount is true.

      Unknown attributes (ACCOUNT_CHANGE_INVALID) and sellers that do not advertise account.requests (ACCOUNT_REQUESTS_UNSUPPORTED) are refused before dispatch. A failure to process the call throws AccountRequestError. A pending change is not kept in the registry, which maps natural keys: keep its request_id and read it back with BuyerAccountRegistry.changeStatus. A new change request for the same account supersedes an open one.

      Parameters

      Returns Promise<AccountChangeOutcome>

    • Point a natural key at accountId: account-scoped calls and new buys for key go to that account. The explicit step after BuyerAccountRegistry.change returned separate_account or matched_existing; the registry never re-points on its own. The account's status is read from list_accounts unless you pass it, so the spend gate still holds a payment_required or pending account. An account the caller cannot list is recorded as unknown and refused for spend until it is listed.

      Parameters

      Returns Promise<void>

    • Parameters

      • refs: readonly AccountReference[]
      • rows: readonly unknown[]
      • dryRun: boolean = false
      • OptionalobservationEpoch: number
      • OptionalexpectedRevision: number

      Returns Promise<void>

    • Parameters

      • rows: readonly unknown[]
      • OptionalqueriedAccountId: string
      • OptionalobservationEpoch: number

      Returns Promise<void>

    • After verifying account.status_changed, repair aliases by handle from the authoritative seller.

      Parameters

      • notification: { account_id: string }
      • Optionaloptions: TaskOptions

      Returns Promise<void>

    • Bind reduced account keys to the buyer keys they came from, before a request carrying them is sent to a seller on an older release. Each reduced key serves one buyer key only. A key sent unreduced claims itself (account and reduced equal), so a plain key and a reduced one can never land on the same seller account in either order.

      All-or-nothing: every claim is checked, against storage and against the other claims in the same request, before any is written. On a conflict nothing is written and the index and owner of the first conflicting claim are returned. A claim lost to a concurrent writer rolls back the claims this call already wrote.

      Parameters

      Returns Promise<{ index: number; owner: AccountReference } | undefined>

    • Forget that account reached this seller under a reduced key. Call once the account has moved to its full key: after a sync_accounts settings update rekeys operator_unit in place, or after opening a new account under the full key when the reduced fields (currency, timezone, brand.countries) cannot change on an existing account. Until then the client keeps addressing the seller account by its reduced key.

      Parameters

      Returns Promise<void>