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

    Function useIdempotencyKey

    • Validate a bring-your-own-key idempotency_key up front and return a { idempotency_key } fragment to spread into a mutating request.

      Useful when the caller persists keys across process restarts (e.g., key stored in a DB alongside a campaign row) and wants to catch drift before the round-trip — the server would reject a malformed key with INVALID_REQUEST, but failing locally produces a faster, cleaner error.

      Throws when the key doesn't match IDEMPOTENCY_KEY_PATTERN (^[A-Za-z0-9_.:-]{16,255}$).

      Parameters

      • key: string

      Returns { idempotency_key: string }

      const key = await db.getOrCreateIdempotencyKey(campaign.id);
      const result = await client.createMediaBuy({ ...params, ...useIdempotencyKey(key) });