Share link error contract
Every public share-link endpoint (/share/document/<token>, /shared/<token>, /shared/citation/…) returns a stable JSON envelope on failure and emits a matching browser event so embedders can react without polling.
JSON error envelope
All non-2xx responses use the schema below. Use code to branch — the message is for humans only.
{
"error": {
"code": "share_link_expired", // stable machine token (snake_case)
"message": "This share link expired on 2026-05-08.",
"httpStatus": 410, // mirrors the HTTP status
"retryable": false, // safe to auto-retry?
"retryAfterSeconds": null, // present on 429 / 503 when known
"requestId": "req_01HX…", // attach to support tickets
"expiresAt": "2026-05-08T12:00:00Z", // optional context fields
"docsUrl": "https://aiboss.info/docs/share-link-errors"
}
}code
httpStatus
retryable
true ⇒ transient, retry with backoff. false ⇒ permanent, escalate to UI.Error code catalogue
The matrix below is authoritative. New codes will be appended; existing rows will not change semantics.
| code | httpStatus | retryable | Meaning |
|---|---|---|---|
| share_link_invalid | 404 | false | Token does not match any known share. Almost always permanent — verify the URL or request a new link. |
| share_link_revoked | 410 | false | The share owner explicitly revoked access. The link will never become valid again. |
| share_link_expired | 410 | false | The expires_at timestamp has passed. Ask the owner to issue a fresh link. |
| share_link_locked | 423 | false | Owner requires a passphrase or step-up auth. Render the unlock UI before retrying. |
| share_link_quota_exceeded | 429 | true | View / download quota for this token is temporarily exhausted. Honour the Retry-After header. |
| share_link_rate_limited | 429 | true | Too many requests from this client. Back off using exponential delay (2^n × 1s, max 60s). |
| share_link_document_unavailable | 409 | true | The underlying document is still ingesting or temporarily unreadable. Retry in a few seconds. |
| share_link_storage_unavailable | 503 | true | Storage backend is degraded. Safe to retry; surface the system status link to the user. |
| share_link_internal_error | 500 | true | Unhandled server error. Retry once; if it persists, log the request_id and contact support. |
| share_link_bad_request | 400 | false | Malformed query (missing token, invalid format). Fix the request before retrying. |
Browser event: aiboss:share-link-error
When the in-page share viewer encounters an error it dispatches a CustomEvent on window so host pages and embeds can react without monkey-patching fetch. The event bubbles, is composed (crosses shadow-DOM boundaries) and is non-cancelable.
Event signature
Type: CustomEvent<ShareLinkErrorDetail>
interface ShareLinkErrorDetail {
code: string; // e.g. "share_link_expired"
httpStatus: number; // 4xx / 5xx
retryable: boolean; // matches JSON envelope
retryAfterSeconds: number | null;
message: string; // human-readable, already localised
requestId: string | null;
token: string; // the share token (never the underlying doc id)
surface: "document" | "analysis" | "citation";
occurredAt: string; // ISO 8601 UTC
}
window.addEventListener("aiboss:share-link-error", (event) => {
const detail = (event as CustomEvent<ShareLinkErrorDetail>).detail;
if (detail.retryable) scheduleRetry(detail.retryAfterSeconds ?? 5);
else showFatal(detail.code, detail.message);
});The event fires once per failed attempt, including auto-retry attempts. Deduplicate on requestId if you forward to analytics.
DOM data attributes
The share viewer mirrors the latest error onto its root element so you can target it from CSS, query selectors, or a MutationObserver without subscribing to the event bus.
| Attribute | Description |
|---|---|
| data-share-state | "loading" | "ready" | "error" — high-level lifecycle. |
| data-share-error-code | Mirror of detail.code. Absent when state ≠ error. |
| data-share-error-status | Numeric HTTP status, e.g. "410". |
| data-share-error-retryable | "true" or "false". Use it to gate retry buttons via CSS:[data-share-error-retryable="false"] .retry-btn { display:none }. |
| data-share-error-retry-after | Seconds until next safe retry. Empty when unknown. |
| data-share-request-id | Server-side request id for support escalation. |
Example markup
<div id="aiboss-share-root" data-share-state="error" data-share-error-code="share_link_rate_limited" data-share-error-status="429" data-share-error-retryable="true" data-share-error-retry-after="30" data-share-request-id="req_01HX…" > … </div>
Retry guidance
- Only retry when
retryable === true. Permanent codes should surface a clear UI affordance instead. - Honour
retryAfterSeconds(or theRetry-Afterheader) before scheduling the next attempt. - Use exponential backoff with full jitter — base
1s, cap60s, max5attempts per page session. - Log
requestIdalongside any user-facing error so support can correlate quickly.