@adcp/sdk API Reference - v7.9.0
    Preparing search index...

    Class BuyerRetryPolicy

    Buyer-side retry policy with operator-grade defaults per AdCP error code.

    import { decideRetry, type RetryDecision } from '@adcp/sdk';

    try {
    return await callAgent({ idempotency_key: key, ... });
    } catch (e) {
    const error = extractAdcpError(e);
    const decision = decideRetry(error, { attempt });

    if (decision.action === 'retry') {
    await sleep(decision.delayMs);
    return callAgent({ idempotency_key: key, ... }); // SAME key
    }
    if (decision.action === 'mutate-and-retry') {
    // Apply correction (decision.field, decision.suggestion), fresh key.
    return callAgent({ idempotency_key: crypto.randomUUID(), ... });
    }
    throw new Error(`Escalate: ${decision.reason}${decision.message}`);
    }
    Index

    Constructors

    Methods

    Constructors

    • Parameters

      • opts: {
            overrides?: Partial<
                Record<
                    | "INVALID_REQUEST"
                    | "AUTH_REQUIRED"
                    | "RATE_LIMITED"
                    | "SERVICE_UNAVAILABLE"
                    | "POLICY_VIOLATION"
                    | "PRODUCT_NOT_FOUND"
                    | "PRODUCT_UNAVAILABLE"
                    | "PROPOSAL_EXPIRED"
                    | "BUDGET_TOO_LOW"
                    | "CREATIVE_REJECTED"
                    | "UNSUPPORTED_FEATURE"
                    | "AUDIENCE_TOO_SMALL"
                    | "ACCOUNT_NOT_FOUND"
                    | "ACCOUNT_SETUP_REQUIRED"
                    | "ACCOUNT_AMBIGUOUS"
                    | "ACCOUNT_PAYMENT_REQUIRED"
                    | "ACCOUNT_SUSPENDED"
                    | "COMPLIANCE_UNSATISFIED"
                    | "GOVERNANCE_DENIED"
                    | "BUDGET_EXHAUSTED"
                    | "BUDGET_EXCEEDED"
                    | "CONFLICT"
                    | "IDEMPOTENCY_CONFLICT"
                    | "IDEMPOTENCY_EXPIRED"
                    | "CREATIVE_DEADLINE_EXCEEDED"
                    | "INVALID_STATE"
                    | "MEDIA_BUY_NOT_FOUND"
                    | "NOT_CANCELLABLE"
                    | "PACKAGE_NOT_FOUND"
                    | "CREATIVE_NOT_FOUND"
                    | "SIGNAL_NOT_FOUND"
                    | "SESSION_NOT_FOUND"
                    | "PLAN_NOT_FOUND"
                    | "REFERENCE_NOT_FOUND"
                    | "SESSION_TERMINATED"
                    | "VALIDATION_ERROR"
                    | "PRODUCT_EXPIRED"
                    | "PROPOSAL_NOT_COMMITTED"
                    | "IO_REQUIRED"
                    | "TERMS_REJECTED"
                    | "REQUOTE_REQUIRED"
                    | "VERSION_UNSUPPORTED"
                    | "CAMPAIGN_SUSPENDED"
                    | "GOVERNANCE_UNAVAILABLE"
                    | "PERMISSION_DENIED",
                    RetryDecisionOverride,
                >,
            > & Record<string, RetryDecisionOverride>;
            unknownCode?: "escalate" | "mutate";
        } = {}
        • Optionaloverrides?: Partial<
              Record<
                  | "INVALID_REQUEST"
                  | "AUTH_REQUIRED"
                  | "RATE_LIMITED"
                  | "SERVICE_UNAVAILABLE"
                  | "POLICY_VIOLATION"
                  | "PRODUCT_NOT_FOUND"
                  | "PRODUCT_UNAVAILABLE"
                  | "PROPOSAL_EXPIRED"
                  | "BUDGET_TOO_LOW"
                  | "CREATIVE_REJECTED"
                  | "UNSUPPORTED_FEATURE"
                  | "AUDIENCE_TOO_SMALL"
                  | "ACCOUNT_NOT_FOUND"
                  | "ACCOUNT_SETUP_REQUIRED"
                  | "ACCOUNT_AMBIGUOUS"
                  | "ACCOUNT_PAYMENT_REQUIRED"
                  | "ACCOUNT_SUSPENDED"
                  | "COMPLIANCE_UNSATISFIED"
                  | "GOVERNANCE_DENIED"
                  | "BUDGET_EXHAUSTED"
                  | "BUDGET_EXCEEDED"
                  | "CONFLICT"
                  | "IDEMPOTENCY_CONFLICT"
                  | "IDEMPOTENCY_EXPIRED"
                  | "CREATIVE_DEADLINE_EXCEEDED"
                  | "INVALID_STATE"
                  | "MEDIA_BUY_NOT_FOUND"
                  | "NOT_CANCELLABLE"
                  | "PACKAGE_NOT_FOUND"
                  | "CREATIVE_NOT_FOUND"
                  | "SIGNAL_NOT_FOUND"
                  | "SESSION_NOT_FOUND"
                  | "PLAN_NOT_FOUND"
                  | "REFERENCE_NOT_FOUND"
                  | "SESSION_TERMINATED"
                  | "VALIDATION_ERROR"
                  | "PRODUCT_EXPIRED"
                  | "PROPOSAL_NOT_COMMITTED"
                  | "IO_REQUIRED"
                  | "TERMS_REJECTED"
                  | "REQUOTE_REQUIRED"
                  | "VERSION_UNSUPPORTED"
                  | "CAMPAIGN_SUSPENDED"
                  | "GOVERNANCE_UNAVAILABLE"
                  | "PERMISSION_DENIED",
                  RetryDecisionOverride,
              >,
          > & Record<string, RetryDecisionOverride>

          Per-code override functions. Keyed by error code (typed as Partial<Record<ErrorCode, RetryDecisionOverride>> so typos like POLICY_VIOLATIN fail compile). Returns null to fall through to the default policy.

        • OptionalunknownCode?: "escalate" | "mutate"

          What to do when the error code is not in the standard vocabulary AND has no per-code override. 'escalate' (default) is the safer choice for unknown vendor codes — buyer surfaces to user. 'mutate' lets the buyer attempt a generic correction-and-retry.

      Returns BuyerRetryPolicy

    Methods