JavaScript Document hasRedemptionRecord() Method

Intermediate
⏱️ 12 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Experimental
Instance method

What You’ll Learn

document.hasRedemptionRecord() is an instance method that asks whether the browser already has a redemption record from a given issuer (see MDN Document: hasRedemptionRecord()). Learn how it differs from hasPrivateToken(), secure-context rules, exceptions, and safe feature detection.

01

Kind

Instance method

02

Arg

issuer URL

03

Returns

Promise<boolean>

04

Context

Secure (HTTPS)

05

Checks

Redemption record

06

Status

Experimental

Introduction

In the Private State Token flow, issuers can mint tokens and later sites can redeem them. After redemption, the browser may store a redemption record. This method answers: do we already have one from issuer X?

MDN: hasRedemptionRecord() returns a promise that fulfills with a boolean indicating whether the browser has a redemption record originating from a particular issuer.

💡
Think: token check vs redemption check

1) hasPrivateToken() — token stored?
2) hasRedemptionRecord() — redemption record stored?
3) If yes, you may send it with operation: "send-redemption-record" (MDN)
4) Always feature-detect first

🔒
Secure context required

MDN: NotAllowedError is thrown if the document is not loaded in a secure context. Use HTTPS (or localhost) when experimenting.

Related tutorials: hasPrivateToken(), hasStorageAccess(), hasFocus().

Understanding document.hasRedemptionRecord()

An instance method on the Document interface from the Private State Token API (MDN). Call it on document.

  • issuer — string URL of an issuer server (MDN).
  • Return value — a Promise that resolves to a boolean (MDN).
  • true — a redemption record from that issuer is stored.
  • false — no redemption record for that issuer yet.
  • Experimental — limited browser support; feature-detect first (MDN).
  • Companion API — often used after tokens exist; see hasPrivateToken().

📝 Syntax

General form of Document.hasRedemptionRecord (MDN):

JavaScript
hasRedemptionRecord(issuer)

Parameters

  • issuer — a string representing the URL of an issuer server (MDN). Prefer a full absolute URL such as "https://issuer.example".

Return value

A Promise that resolves with a boolean value indicating whether the browser has a redemption record stored that originates from the specified issuer server (MDN).

Exceptions (MDN)

  • InvalidStateError — the current Document is not yet active.
  • NotAllowedError — the current Document is not loaded in a secure context.
  • TypeErrorissuer is not a valid URL.

MDN-inspired sample (instance call)

JavaScript
const hasRR = await document.hasRedemptionRecord("https://issuer.example");
if (hasRR) {
  await fetch("https://some-resource.example/", {
    method: "POST",
    privateToken: {
      version: 1,
      operation: "send-redemption-record",
      issuers: ["https://issuer.example"],
    },
  });
}

Tip: MDN’s snippet shows the same flow. This tutorial calls document.hasRedemptionRecord(...) because the method is an instance method on Document.

⚡ Quick Reference

GoalCode
Feature-detecttypeof document.hasRedemptionRecord === "function"
Check issuerawait document.hasRedemptionRecord("https://issuer.example")
Send if presentMDN: fetch(..., { privateToken: { version: 1, operation: "send-redemption-record", issuers: [...] } })
Secure context?window.isSecureContext
Invalid URLThrows TypeError (MDN)
MDN statusExperimental — limited availability

🔍 At a Glance

Four facts about document.hasRedemptionRecord().

Returns
Promise

boolean

Arg
issuer

URL string

Checks
redemption

record

Status
Experimental

MDN

📋 Success path vs common failures

SituationLikely resultWhat to do
Supported browser + HTTPS + valid issuerPromise → true/falseBranch on the boolean (MDN)
Method missingundefined functionFeature-detect; skip or fallback
HTTP pageNotAllowedError (MDN)Use a secure context
Bad issuer stringTypeError (MDN)Pass a valid absolute URL
Document not activeInvalidStateError (MDN)Wait until the document is ready

Examples Gallery

Examples follow MDN Document: hasRedemptionRecord() with beginner-safe feature detection. Many demos will report “not supported” outside Chromium.

📚 Getting Started

Detect support before calling the experimental method.

Example 1 — Feature-detect safely

Always check that the function exists before awaiting it.

JavaScript
if (typeof document.hasRedemptionRecord === "function") {
  console.log("hasRedemptionRecord is available");
} else {
  console.log("hasRedemptionRecord is not supported in this browser");
}
Try It Yourself

How It Works

Experimental APIs are uneven across engines. Detection keeps demos from throwing when the method is missing.

Example 2 — Await the issuer boolean

MDN: resolve to whether a redemption record from that issuer is stored.

JavaScript
async function checkIssuer(issuer) {
  if (typeof document.hasRedemptionRecord !== "function") {
    return "unsupported";
  }
  const hasRR = await document.hasRedemptionRecord(issuer);
  return hasRR ? "redemption record present" : "no redemption record yet";
}

checkIssuer("https://issuer.example").then(console.log);
Try It Yourself

How It Works

Use a real absolute issuer URL. An invalid string can reject with TypeError (MDN).

📈 Practical Patterns

Send records, catch exceptions, and pair with token checks.

Example 3 — Send redemption record only if present

MDN flow: check first, then POST with send-redemption-record.

JavaScript
async function sendIfPresent(issuer, resourceUrl) {
  if (typeof document.hasRedemptionRecord !== "function") {
    throw new Error("Private State Tokens not supported");
  }

  const hasRR = await document.hasRedemptionRecord(issuer);
  if (hasRR) {
    await fetch(resourceUrl, {
      method: "POST",
      privateToken: {
        version: 1,
        operation: "send-redemption-record",
        issuers: [issuer],
      },
    });
  }
  return hasRR;
}
Try It Yourself

How It Works

Checking first avoids sending when no record exists. The privateToken fetch option belongs to the same experimental API family.

Example 4 — Catch MDN exceptions

Wrap calls so invalid URLs or insecure contexts fail gracefully.

JavaScript
async function safeHasRR(issuer) {
  if (typeof document.hasRedemptionRecord !== "function") {
    return { ok: false, reason: "unsupported" };
  }
  try {
    const hasRR = await document.hasRedemptionRecord(issuer);
    return { ok: true, hasRR };
  } catch (err) {
    // TypeError | NotAllowedError | InvalidStateError (MDN)
    return { ok: false, reason: err.name, message: err.message };
  }
}

safeHasRR("not-a-url").then(console.log);
Try It Yourself

How It Works

MDN documents three failure modes. Catching by err.name keeps messages clear for beginners and operators.

Example 5 — Pair with hasPrivateToken()

Show both Private State Token checks side by side when available.

JavaScript
async function snapshot(issuer) {
  const out = {
    hasPrivateToken: "unsupported",
    hasRedemptionRecord: "unsupported",
  };

  if (typeof document.hasPrivateToken === "function") {
    out.hasPrivateToken = await document.hasPrivateToken(issuer);
  }
  if (typeof document.hasRedemptionRecord === "function") {
    out.hasRedemptionRecord = await document.hasRedemptionRecord(issuer);
  }
  return out;
}

snapshot("https://issuer.example").then(console.log);
Try It Yourself

How It Works

Token presence and redemption-record presence answer different questions in the same privacy API family — useful when teaching the full flow.

🚀 Common Use Cases

  • Send only when ready — MDN: call send-redemption-record after confirming a record exists.
  • Privacy-preserving trust — Private State Tokens as a cookie-alternative family (MDN API).
  • Feature-gated UX — hide redemption flows when the method is unsupported.
  • Secure-only demos — enforce HTTPS before calling the API.
  • Paired checks — combine with hasPrivateToken().
  • Learning / migration — understand experimental privacy APIs without relying on them yet in production.

🧠 How hasRedemptionRecord() Works

1

Pass an issuer URL

Must be a valid URL string identifying the issuer server (MDN).

Input
2

Browser checks redemption records

Looks for a record originating from that issuer (MDN).

Lookup
3

Promise resolves to a boolean

true if present, false if not (MDN).

Result
4

Decide next step

Skip, or send with fetch + send-redemption-record.

📝 Notes

  • MDN: marked Experimental — verify compatibility before production.
  • MDN: returns a Promise that fulfills with a boolean.
  • MDN: issuer must be a valid URL or you get TypeError.
  • MDN: secure context required; otherwise NotAllowedError.
  • Not the same as hasPrivateToken() — different stored artifact.
  • Related: hasPrivateToken(), hasStorageAccess(), hasFocus().

Limited / Experimental Browser Support

Document.hasRedemptionRecord() is Experimental on MDN. Support is primarily Chromium-based (Chrome / Edge from 117+, Opera from 103+). Firefox and Safari currently lack support. Logos use the shared browser-image-sprite.png sprite from this project.

Experimental · Limited

Document.hasRedemptionRecord()

Promise-based check for a stored redemption record from an issuer URL. Feature-detect before use.

Limited Not Baseline
Google Chrome 117+
Yes
Microsoft Edge 117+
Yes
Opera 103+
Yes
Mozilla Firefox Not supported
No
Apple Safari Not supported
No
Internet Explorer Not supported
No
hasRedemptionRecord() Partial

Bottom line: Use only with feature detection and a fallback. Prefer learning this API for privacy experiments; do not assume universal browser support.

Conclusion

document.hasRedemptionRecord(issuer) is an experimental instance method that resolves to whether a redemption record from that issuer is already stored. Feature-detect, stay on HTTPS, pass a valid issuer URL, and pair it with hasPrivateToken() when learning the full flow.

Continue with hasPrivateToken(), hasStorageAccess(), or the JavaScript hub.

💡 Best Practices

✅ Do

  • Feature-detect before calling (experimental)
  • Pass absolute issuer URLs
  • Use HTTPS / localhost (secure context) (MDN)
  • Catch TypeError / NotAllowedError / InvalidStateError (MDN)
  • Send redemption records only when the boolean is true (MDN)

❌ Don’t

  • Ship without a fallback on unsupported browsers
  • Confuse this with hasPrivateToken()
  • Pass relative or invalid issuer strings
  • Assume Firefox/Safari support today
  • Treat this as a Baseline everyday DOM API

Key Takeaways

Knowledge Unlocked

Five things to remember about hasRedemptionRecord()

Experimental issuer redemption-record check.

5
Core concepts
🔄02

Arg

issuer URL

MDN
🎯03

Checks

redemption

record
04

Detect

typeof check

first
🛡05

Status

Experimental

MDN

❓ Frequently Asked Questions

MDN: Document.hasRedemptionRecord() returns a promise that fulfills with a boolean indicating whether the browser has a redemption record originating from a particular issuer.
MDN marks Document.hasRedemptionRecord() as Experimental. It is not Deprecated or Non-standard, but support is limited — check compatibility before production use.
hasPrivateToken() asks whether a private state token from an issuer is stored. hasRedemptionRecord() asks whether a redemption record from that issuer already exists (after redeeming tokens).
MDN: issuer — a string representing the URL of an issuer server.
MDN: InvalidStateError if the Document is not yet active; NotAllowedError if not in a secure context; TypeError if issuer is not a valid URL.
It is an instance method on Document (MDN page type). Call it as document.hasRedemptionRecord(issuer), and feature-detect with typeof document.hasRedemptionRecord === "function".
Did you know?

MDN’s example only sends the redemption record when hasRedemptionRecord is true — the opposite pattern of hasPrivateToken, which often requests a token when the result is false.

Next: hasStorageAccess()

Learn how to check for third-party unpartitioned cookie access with the Storage Access API.

hasStorageAccess() →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful