# Accept legal terms

Accept the current AgentDB legal documents for your organization using your API token.

> HTML version: https://staging.agentdb.com/legal/accept — this file (/docs/legal/accept.md) is its markdown twin.

## Accept the current legal documents

Paste this page's URL with your organization's API token in the fragment —
`/legal/accept#token=YOUR_JWT` — or paste the token below. The page checks
which documents your organization still needs to accept
([Terms](/legal/terms), [Privacy](/legal/privacy)) and records your
acceptance through the API. The token never leaves your browser except to
call the API directly.

<div id="accept-app">
  <input id="accept-token" type="password" placeholder="Bearer token (JWT)" />
  <button id="accept-check" type="button">Check required documents</button>
  <div id="accept-status" role="status"></div>
  <div id="accept-docs"></div>
</div>

<script>
  (function () {
    // The layout emits this page's JSON-LD; scan every ld+json block for the
    // AcceptAction EntryPoint (the ${API} substitution happened at build).
    var ldScripts = document.querySelectorAll(
      'script[type="application/ld+json"]'
    );
    var api = null;
    ldScripts.forEach(function (ld) {
      try {
        var node = JSON.parse(ld.textContent);
        var actions = [].concat(node.potentialAction || []);
        actions.forEach(function (a) {
          if (a && a["@type"] === "AcceptAction" && a.target) {
            api = a.target.urlTemplate || a.target;
          }
        });
      } catch (e) {}
    });

    var tokenInput = document.getElementById("accept-token");
    var statusEl = document.getElementById("accept-status");
    var docsEl = document.getElementById("accept-docs");
    var hash = new URLSearchParams(location.hash.slice(1));
    if (hash.get("token")) tokenInput.value = hash.get("token");

    function post(body, token) {
      return fetch(api, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + token,
        },
        body: JSON.stringify(body),
      }).then(function (r) {
        return r.json().then(function (j) {
          return { status: r.status, json: j };
        });
      });
    }

    function check() {
      var token = tokenInput.value.trim();
      if (!api) {
        statusEl.textContent = "Page misconfigured: no API endpoint.";
        return;
      }
      if (!token) {
        statusEl.textContent = "Paste your API token first.";
        return;
      }
      statusEl.textContent = "Checking…";
      post(
        {
          "@context": "https://schema.org/",
          "@type": "CheckAction",
          object: { "@type": "DigitalDocument" },
        },
        token
      ).then(function (res) {
        var missing = (res.json && res.json.result) || [];
        if (res.status !== 200) {
          statusEl.textContent = "Check failed (HTTP " + res.status + ").";
          return;
        }
        if (!missing.length) {
          statusEl.textContent =
            "Nothing to accept — your organization is up to date.";
          docsEl.innerHTML = "";
          return;
        }
        statusEl.textContent = "Documents requiring acceptance:";
        docsEl.innerHTML = "";
        missing.forEach(function (doc) {
          var btn = document.createElement("button");
          btn.type = "button";
          btn.textContent =
            "Accept " + doc.identifier + " (" + doc.version + ")";
          btn.onclick = function () {
            btn.disabled = true;
            post(
              {
                "@context": "https://schema.org/",
                "@type": "AcceptAction",
                object: {
                  "@type": "DigitalDocument",
                  identifier: doc.identifier,
                  version: doc.version,
                },
              },
              token
            ).then(function (res2) {
              btn.textContent =
                res2.status === 200
                  ? "Accepted " + doc.identifier + " ✓"
                  : "Failed (HTTP " + res2.status + ") — retry";
              btn.disabled = res2.status === 200;
            });
          };
          docsEl.appendChild(btn);
        });
      });
    }

    document.getElementById("accept-check").onclick = check;
    if (tokenInput.value) check();
  })();
</script>

## Actions declared on this page (JSON-LD)

```jsonld
[
  {
    "@type": "AcceptAction",
    "name": "Accept a legal document",
    "target": {
      "@type": "EntryPoint",
      "urlTemplate": "https://staging-api.agentdb.com/api/action/admin",
      "httpMethod": "POST",
      "contentType": "application/json"
    }
  }
]
```
