Cardsite API Reference
Canonical machine-readable spec:
shared/contracts/openapi.yaml(OpenAPI 3.1). This document is the human-readable reference and operational guide.
Surface: 366 routes across user, admin, public, webhook, and observability namespaces. Current stable version is v1.
Table of contents
- Base URLs
- Authentication
- Versioning policy
- Response envelope
- Pagination
- Error model
- Idempotency
- Rate limits
- Security headers & CSRF
- Request tracing
- Endpoint groups
- Auth
- Account
- Short links
- Biolinks & blocks
- QR codes
- Projects, domains, pixels
- Splash pages, notification handlers
- vCards, events, signatures, static, files
- Workspaces
- Teams (legacy)
- AI tools
- Statistics
- Payments & billing
- Payment processors
- Affiliates / referrals
- Uploads
- Codes (gift codes)
- PWAs
- Logs & internal notifications
- Public endpoints
- Webhooks
- Observability
- Admin API
- GDPR
- Background jobs
- Feature flags
- Webhook signatures
- Display rules
- Plan limits
- Block types schema
Base URLs
| Environment | URL |
|---|---|
| Production | https://prod.cardsite.io |
| Local dev (Docker Compose / Vite proxy) | http://localhost:8080 |
The production backend listens on
:18810behind the Caddy reverse proxy (PORT=18810in.env.production); local development uses:8080(the binary default, and whatdocker-composeexposes). Point the app athttp://localhost:8080for local work.
All user/admin endpoints live under /api/v1 and /admin-api/v1 respectively. Public endpoints (/l/{url}, /b/{url}, /webhook/{gateway}, /health, /ready, /metrics, /sitemap*.xml) sit at the root.
Authentication
Pass one of:
Authorization: Bearer <jwt-or-token-or-api-key>
- JWT — obtained via
POST /api/v1/auth/login. HS256, 7-day expiry. Full account access; non-revocable until expiry, which is why the lifetime is short — long-lived programmatic access belongs to scoped tokens. - Scoped API token (ADR-0002) —
cst_-prefixed secret minted viaPOST /api/v1/account/tokens. Recommended for headless/agent access. Scoped deny-by-default (links:read,links:write,biolinks:write,billing:read, … — write implies read; the grantable list is returned byGET /api/v1/account/tokens), revocable immediately (DELETE /api/v1/account/tokens/{id}), optional expiry, stored only as a SHA-256 digest — the plaintext is shown once at creation. Tokens cannot reach account settings, token management, auth/2FA, checkout, teams, workspaces, history/undo, the realtime stream, or admin endpoints regardless of scopes, and billing surfaces are read-only. Tokens are pinned to the workspace they were minted in — theX-Workspace-IDheader is ignored for token principals. - Legacy API key — full-access bearer credential, regenerated via
POST /api/v1/account/api-key(the new key is returned once; only its digest is stored). Kept for backward compatibility as a single implicit full-scope token — prefer scoped tokens for anything new. - 2FA challenge — if 2FA is enabled,
/auth/loginreturnsrequires_2fa: trueinstead of a token; resend withcodein the body to complete the login.
Workspace context (migration 000026, ADR-0006). user_id is the
owner-of-record and billing anchor; workspace_id is the access boundary.
Session requests may select a workspace with the X-Workspace-ID header —
it must be a workspace the caller is a member of (403 otherwise; unknown
and foreign ids are indistinguishable). No header resolves to the caller's
personal workspace, so pre-workspace clients behave unchanged. Roles:
member reads/creates/edits, admin additionally deletes resources and
manages members, owner additionally renames/deletes the workspace.
Admin endpoints (/admin-api/v1/*) additionally require the authenticated user to have type = 1.
# Login → get JWT
curl -X POST https://prod.cardsite.io/api/v1/auth/login \
-H 'Content-Type: application/json' \
-H 'X-Requested-With: XMLHttpRequest' \
-d '{"email":"you@example.com","password":"…"}'
# Use the JWT
curl https://prod.cardsite.io/api/v1/links \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIs…'
Versioning policy
- The current stable version is v1 (
/api/v1/,/admin-api/v1/). - Breaking changes (field removal, semantic changes) are published under a new prefix (
/api/v2/). - Deprecated fields remain in responses for at least two minor releases and are annotated in
openapi.yamlwithx-deprecated: true. - Non-breaking additions (new optional fields, new endpoints) are introduced without a version bump.
Response envelope
Every JSON endpoint returns:
{
"data": <payload | null>,
"meta": { "page": 1, "per_page": 25, "total": 412 },
"error": null
}
| Field | When set |
|---|---|
data | Successful response payload. null on error. For empty collections, the axios interceptor on the frontend normalizes null → []. |
meta | Present on paginated/list responses. May also carry resource-specific keys. |
error | null on success. On failure, a human-readable string. Some validation errors include additional fields (e.g. limit, current, max on plan-limit failures). |
Pagination
List endpoints accept these query params:
| Param | Type | Default | Notes |
|---|---|---|---|
page | int | 1 | 1-indexed |
per_page | int | 25 | Max 100 |
search | string | — | Free-text search where supported |
sort | string | resource-specific | e.g. created_at:desc |
filter[*] | string | — | Resource-specific filters |
Response meta carries {page, per_page, total}.
Error model
| Status | Meaning |
|---|---|
| 400 | Malformed request (bad JSON, missing required field) |
| 401 | Missing or invalid token; 2FA challenge required |
| 403 | Authenticated but not authorized (admin gate, ownership, blacklisted IP, maintenance mode) |
| 404 | Resource not found or not visible to the caller |
| 409 | Conflict (duplicate slug, etc.) |
| 422 | Validation or plan-limit failure — body adds {limit, current, max} when applicable |
| 429 | Rate-limited (Retry-After header in seconds) |
| 500 | Internal error (request_id in X-Request-ID for support) |
| 503 | Maintenance mode |
Example plan-limit response:
HTTP/1.1 422
{
"data": null,
"error": "Plan limit reached: links",
"limit": "links",
"current": 50,
"max": 50
}
Idempotency
POST requests may include an Idempotency-Key: <uuid> header:
curl -X POST https://prod.cardsite.io/api/v1/links \
-H 'Authorization: Bearer …' \
-H 'X-Requested-With: XMLHttpRequest' \
-H 'Idempotency-Key: 5cda6f5e-1f0b-4f02-a8b7-94b41f1f7b1e' \
-H 'Content-Type: application/json' \
-d '{"url":"https://example.com"}'
Within 24 hours a repeated call with the same key returns the original cached response (same status, same body) and adds:
Idempotent-Replayed: true
A daily cron purges expired keys.
Rate limits
| Scope | Limit | Header on lockout |
|---|---|---|
Authenticated /api/v1 and /admin-api/v1, per IP | 60 req / 60 s | Retry-After: 60 |
| Public routes (redirects, public biolinks, webhooks, sitemaps), per IP | 300 req / 60 s | Retry-After: 60 |
Auth (/auth/register, /auth/login, /auth/lost-password) per IP | 6 attempts / 10 min | Retry-After: 600 |
AI generations (POST /ai/*) per user (fallback to IP) | 50 / hour | Retry-After: 3600 |
All limits are runtime-tunable from /admin/settings → Security — changes take effect within 60 s without restart. See services/ratelimit_config.go.
Rate-limited responses return HTTP 429.
Security headers & CSRF
Every response includes:
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
Referrer-Policy: strict-origin-when-cross-origin
X-Request-ID: <16-hex-char-id>
State-changing requests (POST/PUT/PATCH/DELETE) must include:
X-Requested-With: XMLHttpRequest
…or the request is rejected with 403 by the CSRF guard. Exemptions: webhooks (/webhook/*), OAuth callbacks (/api/v1/auth/oauth/*/callback), and the two routes whose credential is in the request itself: POST /unsubscribe (token) and POST /api/v1/emails/bounce (X-Bounce-Secret).
The frontend's axios client sets X-Requested-With automatically. CLI users (curl, httpie, scripts) must add it manually for non-idempotent verbs.
Request tracing
Every request gets a 16-hex-char ID:
- Echoed back as
X-Request-IDresponse header - Attached to every
sloglog line asrequest_id - Pass
X-Request-ID: <your-id>to propagate from an upstream
When opening a support ticket, include X-Request-ID from the failing response.
Endpoint groups
Auth
/api/v1/auth/* — no authentication required.
| Method | Path | Description |
|---|---|---|
| POST | /register | Create account. Body: {email, password, name?, captcha?}. Sends activation email if email_activation setting is on. |
| POST | /login | Returns {token, user} or {requires_2fa: true} if 2FA enabled. |
| POST | /lost-password | Send reset email. Body: {email}. |
| POST | /reset-password | Apply reset token. Body: {code, password}. |
| POST | /resend-activation | Re-send activation email. |
| POST | /activate-user | Activate via code from email. |
| GET | /captcha | Get CAPTCHA challenge (when enabled). |
| GET | /oauth/providers | List configured OAuth providers. |
| GET | /oauth/{provider}/initiate | Start OAuth flow → redirects to provider. |
| POST | /oauth/{provider}/callback | Complete OAuth flow. Body: {code, state}. |
| POST | /2fa/setup | (auth required) Returns TOTP provisioning URI + recovery codes. |
| POST | /2fa/verify | (auth required) Activate 2FA. Body: {code}. |
| DELETE | /2fa | (auth required) Disable 2FA. Body: {password}. |
Lockout: 6 attempts / 10 min per IP on /register, /login, /lost-password.
Two-factor recovery codes
ADR-0173. POST /api/v1/auth/2fa/verify (body {code}) turns 2FA on and returns recovery_codes: ten one-time codes, xxxx-xxxx-xxxx-xxxx, shown this once and stored only as hashes. At sign-in, POST /api/v1/auth/login takes recovery_code in place of twofa_token (after a correct password; case, spaces and dashes ignored; spent on use; a wrong or used code is 401 under the same lockout) and answers with recovery_codes_remaining. GET /api/v1/auth/2fa/recovery-codes → {twofa_enabled, remaining}; POST /api/v1/auth/2fa/recovery-codes {password} replaces the set and returns it once (409 when 2FA is off). Turning 2FA off deletes the codes. 2FA turns on only when verify confirms the code; setup alone stores a pending secret and is refused (409) while 2FA is on (ADR-0174). An OAuth sign-in to an account with 2FA on answers {twofa_required, twofa_pending_token, twofa_pending_expires, twofa_complete_at} instead of a session; POST /api/v1/auth/login/2fa {pending_token, twofa_token | recovery_code} exchanges it (5 minutes, 5 attempts, single use, same lockout). Each event is written to the account's log (login.recovery_code, login.recovery_code_rejected, twofa.enabled, twofa.recovery_codes_regenerated, twofa.disabled).
Account
/api/v1/* — authenticated.
| Method | Path | Description |
|---|---|---|
| GET | /user | Current user profile (id, email, name, type, plan, settings, preferences, billing). |
| PUT | /account | Update profile. Accepts name, email, timezone, language, billing (JSONB), is_newsletter_subscribed, anti_phishing_code, and per-profile settings. |
| PUT | /account/password | Body: {current_password, new_password}. |
| GET | /account/plan | Plan + subscription summary (renewal date, limits, current usage). |
| POST | /account/api-key | Regenerate legacy API key — old key invalidated; the new key is returned once. |
| GET | /account/tokens | List scoped API tokens (revoked included) + the grantable scope list. |
| POST | /account/tokens | Mint a scoped token. Body: {name, scopes[], expires_at?}. Secret returned once. Session-only. |
| DELETE | /account/tokens/{id} | Revoke a token — takes effect immediately; the row is kept as an audit record. |
| GET | /account/preferences | Load UI/feature preferences (JSONB). |
| PUT | /account/preferences | Save preferences. |
| GET | /account/export | GDPR data export — returns a ZIP archive of all user data (one JSON file per category: profile, links, qr_codes, payments, activity_logs, notification_handlers, splash_pages, domains, pixels, projects, uploads). |
| DELETE | /account | Delete account. Body must include password. Cascades across all user-owned tables. |
Short links
Every addressable resource — short link, bio page, vCard, event, file link, static page, splash page, payment link — is a row in links, discriminated by type. That table backs the whole collection; the endpoints below are the short-link product only, and type is not a filter on them (ADR-0008). For a view across every type, see GET /resources/recent (ADR-0009); for one other type, see that product's own endpoints.
| Method | Path | Description |
|---|---|---|
| GET | /links | List short links (type='link' only) with pagination, search, filter by project_id, domain_id, is_enabled. meta.total counts the filtered set. |
| POST | /links | Create. See body schema below. |
| GET | /links/{id} | Get one. |
| PUT | /links/{id} | Update. |
| DELETE | /links/{id} | Delete. |
Link create/update body
{
"url": "https://example.com/long-url",
"alias": "my-link",
"domain_id": 5,
"project_id": 12,
"splash_page_id": 3,
"pixels_ids": [1, 7],
"settings": {
"password": "secret",
"clicks_limit": 100,
"expiration_url": "https://example.com/expired",
"forward_query_parameters": true,
"http_status_code": 301,
"targeting_countries": ["US", "CA"],
"cloaking_is_enabled": true,
"app_linking_is_enabled": true,
"app_linking_android_url": "https://play.google.com/...",
"app_linking_ios_url": "https://apps.apple.com/..."
},
"display_rules": { "...": "see Display rules section" },
"scheduled_at": "2026-06-01T00:00:00Z",
"scheduled_end": "2026-06-30T23:59:59Z",
"timezone": "America/Los_Angeles"
}
Plan-limit-checked: returns 422 {limit: "links", current, max} when the user has reached their quota.
Biolinks & blocks
A biolink is a link of type=biolink plus its ordered blocks.
| Method | Path | Description |
|---|---|---|
| GET | /biolinks | List biolink pages. |
| POST | /biolinks | Create. Body accepts everything a link does + settings for SEO, theme, branding, PWA, custom code, display_rules. |
| GET | /biolinks/{id} | Get one. |
| PUT | /biolinks/{id} | Update. |
| DELETE | /biolinks/{id} | Delete. |
| GET | /biolinks/{id}/blocks | List blocks for a biolink (returned as part of /biolinks/{id} too). |
| GET | /biolink-blocks | List all blocks (with biolink_id filter). |
| GET | /biolink-blocks/types | Public block type registry — returns 85 typed BlockTypeInfo entries with Fields []BlockFieldSpec. |
| POST | /biolink-blocks | Create a block. Body: {type, biolink_id, settings, sort}. |
| POST | /biolink-blocks/order | Reorder blocks. Body: {ids: [1, 7, 3]}. |
| GET | /biolink-blocks/{id} | Get one. |
| PUT | /biolink-blocks/{id} | Update. |
| DELETE | /biolink-blocks/{id} | Delete. |
Block types
85 typed block types organized as Fields []BlockFieldSpec with {Name, Kind, Label, Help, DefaultValue, Validation, Options}. The frontend renders them with a generic BlockFields (apps/web/src/components/blocks/BlockFields.tsx) based on Kind:
text, textarea, url, email, phone, color, image_upload, file_upload, bool, int, select, datetime, timezone, multi_select, rich_text, code, display_rules, notification_handlers_picker, payment_processors_picker, markers_list, times_grid.
Biolink templates & themes
| Method | Path | Description |
|---|---|---|
| GET | /biolinks-templates | Public list of biolink page templates. |
| GET | /biolinks-themes | Public list of typed BiolinkThemeSettings themes (41 fields covering background, profile, buttons, social icons, typography, animation, custom CSS). |
QR codes
| Method | Path | Description |
|---|---|---|
| GET | /qr-codes | List user's QR codes. |
| POST | /qr-codes | Create a saved QR code. |
| GET | /qr-codes/types | Public list of 28 QR types across 8 groups (web, basic, contact, messaging, network, location, calendar, payment, app). |
| POST | /qr-codes/generate | Generate a one-off PNG without saving. |
| GET | /qr-codes/{id} | Get one. |
| PUT | /qr-codes/{id} | Update. |
| DELETE | /qr-codes/{id} | Delete. |
| GET | /qr-codes/{id}/generate | Returns PNG (Content-Type: image/png). |
Style fields
foreground, background, background_color_transparency, foreground_gradient_color, foreground_gradient_type, eyes_inner_color, eyes_outer_color, inner_eye_style, outer_eye_style, frame, frame_color, frame_text, frame_text_font, frame_text_size, qr_code_logo_size.
Projects, domains, pixels
Standard CRUD under each path:
| Resource | Path |
|---|---|
| Projects | /projects, /projects/{id} |
| Domains | /domains, /domains/{id}, POST /domains/{id}/verify |
| Pixels | /pixels, /pixels/{id}, GET /pixels/types (public list of 24 pixel providers) |
Pixel types (24)
facebook, google_analytics, google_tag_manager, linkedin, pinterest, twitter, quora, tiktok, snapchat, reddit, bing, hotjar, mixpanel, segment, intercom, crisp, freshchat, clarity, adobe_analytics, matomo, plausible, fathom, simple_analytics, umami.
Domain verification
Domain rows track SSL state, redirect_type, forward_parameters, and verification. POST /domains/{id}/verify runs the DNS check and updates is_verified + last_verified_at.
Splash pages, notification handlers
| Resource | Path |
|---|---|
| Splash pages | /splash-pages, /splash-pages/{id} |
| Notification handlers | /notification-handlers, /notification-handlers/{id} |
Splash-page advanced fields (secondary_button_*, ads_header, ads_footer, custom_css, custom_js) live in the settings JSONB.
Notification handler types: webhook, slack, discord, telegram, msteams, googlechat, email, twilio_sms, twilio_call, whatsapp, x.
vCards, events, signatures, static, files
Each is a links-table type-discriminated resource with its own CRUD path:
| Resource | Path | Notes |
|---|---|---|
| vCards | /vcards, /vcards/{id}, GET /vcards/{id}/download | Download returns a .vcf file |
| Events | /events, /events/{id} | Event links with ICS export |
| Signatures | /signatures, /signatures/{id} | Email signature HTML builder |
| Static pages | /static, /static/{id} | Self-hosted page builder |
| File links | /files, /files/{id} | File download links (upload via /uploads first) |
| Payment links | /payment-links, /payment-links/{id} | Short URLs redirecting to an external checkout (location_url must be http/https) |
Workspaces
Session-only (closed to API tokens). These act on the workspace named in
the path, not the X-Workspace-ID context; membership is checked per
call, and non-membership answers 404 like an unknown id. Personal
workspaces cannot be renamed, deleted, or given members.
| Method | Path | Description |
|---|---|---|
| GET | /workspaces | Workspaces the caller belongs to, with their role. |
| POST | /workspaces | Create a shared workspace (caller becomes owner; draws on the teams plan limit). |
| PUT | /workspaces/{id} | Rename (owner only). |
| DELETE | /workspaces/{id} | Delete the workspace and everything in it (owner only). |
| GET | /workspaces/{id}/members | Members with name/email/role (any member). |
| POST | /workspaces/{id}/members | Add an existing user by email. Body: {email, role: member|admin} (admin+). |
| PUT | /workspaces/{id}/members/{user_id} | Change a member's role between member and admin (admin+; the owner row is immutable). |
| DELETE | /workspaces/{id}/members/{user_id} | Remove a member (admin+; the owner cannot be removed). |
| POST | /workspaces/{id}/leave | Leave (non-owners). |
Teams (legacy)
The user-facing teams UI was retired in favor of workspaces (ADR-0006); these endpoints remain for legacy data access and the admin resources tab.
| Method | Path | Description |
|---|---|---|
| GET | /teams | Teams the caller owns. |
| POST | /teams | Create team. |
| GET | /teams/{id} | Get team. |
| PUT | /teams/{id} | Update. |
| DELETE | /teams/{id} | Delete. |
| GET | /teams/{team_id}/members | List members. |
| POST | /teams/{team_id}/members | Add member. Body: {email, access_keys}. |
| PUT | /teams/{team_id}/members/{member_id} | Update member's access_keys. |
| DELETE | /teams/{team_id}/members/{member_id} | Remove member. |
| GET | /teams-member | Teams the caller is a member of. |
| PUT | /teams-member/{id} | Accept invitation. |
| DELETE | /teams-member/{id} | Leave team. |
access_keys is a string array drawn from the 47-key permission matrix (AllTeamAccessKeys in the Go models). Format: {create|update|delete|read}.{resource} (e.g. create.biolinks, delete.qr_codes, read.statistics).
AI tools
All POST endpoints are rate-limited by the AI quota (50/hour/user).
Generation is synchronous: the provider call may take up to 120 s, so every /api/v1/ai/* route has a 130 s write deadline instead of the server's 15 s. A proxy in front must allow at least that (nginx proxy_read_timeout 300s does).
Chat
| Method | Path | Description |
|---|---|---|
| GET | /ai/chats | List chats. |
| POST | /ai/chats | Create chat. Body: {title, assistant_id?}. |
| GET | /ai/chats/{id} | Get chat with messages. |
| POST | /ai/chats/{id}/messages | Send a message. Body: {content, model?}. |
| DELETE | /ai/chats/{id} | Delete. |
Images
| Method | Path | Description |
|---|---|---|
| GET | /ai/images | List generated images. |
| POST | /ai/images | Body: {prompt, model, size, quality, n}. |
| DELETE | /ai/images/{id} | Delete. |
Text
| Method | Path | Description |
|---|---|---|
| GET | /ai/texts | List generated texts. |
| POST | /ai/texts | Body: {template_id?, variants, max_words_per_variant, creativity_level, creativity_level_custom?, language, dynamic_inputs}. creativity_level (low/medium/high/custom) maps to temperature. |
| DELETE | /ai/texts/{id} | Delete. |
Syntheses (TTS)
| Method | Path | Description |
|---|---|---|
| GET | /ai/syntheses | List. |
| POST | /ai/syntheses | Body: {text, voice, model, format}. |
| DELETE | /ai/syntheses/{id} | Delete. |
Transcriptions (STT)
| Method | Path | Description |
|---|---|---|
| GET | /ai/transcriptions | List. |
| POST | /ai/transcriptions | Multipart: audio file + form fields. |
| DELETE | /ai/transcriptions/{id} | Delete. |
Statistics
| Method | Path | Description |
|---|---|---|
| GET | /statistics | User-level analytics. Query: type, range. |
| GET | /statistics/{link_id} | Per-link analytics. |
type values: clicks_chart, countries, continents, cities, referrers, devices, browsers, operating_systems, languages, clicks_over_time, unique_vs_total, qr_scans.
range values: today, yesterday, week, month, year, all. Or pass from/to ISO 8601 dates.
Payments & billing
| Method | Path | Description |
|---|---|---|
| GET | /plans | List active plans. |
| POST | /checkout | Initiate payment. Body: {plan_id, gateway, billing_cycle, coupon?} → returns redirect URL or client-side payment intent. |
| GET | /payments | Payment history. |
| GET | /payments/{id} | Get one. |
| POST | /subscription/cancel | Cancel active subscription. |
| GET | /invoices/{id} | Download invoice PDF. |
| GET | /credit-notes/{id} | Download credit note PDF. |
Payment processors
User-side CRUD for per-user payment processors used by donation/product/service biolink blocks.
| Method | Path | Description |
|---|---|---|
| GET | /payment-processors | List the caller's processors. |
| POST | /payment-processors | Body: {name, gateway, credentials} — credentials are encrypted at rest. |
| GET | /payment-processors/{id} | Get one. |
| PUT | /payment-processors/{id} | Update. |
| DELETE | /payment-processors/{id} | Delete. |
Affiliates / referrals
| Method | Path | Description |
|---|---|---|
| GET | /referrals/stats | Visit/sign-up/commission summary. |
| POST | /referrals/key | (Re)generate the caller's referral key. |
| GET | /referrals/commissions | List commissions. |
| GET | /referrals/withdrawals | List withdrawal requests. |
| POST | /referrals/withdraw | Request a withdrawal. Body: {amount, payment_method, details}. |
Uploads
| Method | Path | Description |
|---|---|---|
| GET | /uploads | List the caller's uploaded files. |
| POST | /uploads | Multipart upload — returns {url, key, size, content_type}. Stored locally or on S3 (if S3_* configured) with optional CDN prefix. |
| DELETE | /uploads/{id} | Delete. |
MIME type sniffed from the file contents (http.DetectContentType), not the filename.
Codes (gift codes)
User-side endpoints for redeeming codes created by admins:
| Method | Path | Description |
|---|---|---|
| POST | /codes/validate | Body: {code} — check if a code is valid and what it does. |
| POST | /codes/redeem | Body: {code} — apply the code to the current account. |
PWAs
| Method | Path | Description |
|---|---|---|
| GET | /pwas | List the caller's PWAs. |
| POST | /pwas | Create. |
| GET | /pwas/{id} | Get one. |
| PUT | /pwas/{id} | Update. |
| DELETE | /pwas/{id} | Delete. |
| GET | /pwas/{id}/manifest.json | Public PWA manifest endpoint. |
Logs & internal notifications
| Method | Path | Description |
|---|---|---|
| GET | /logs | User's activity logs. |
| GET | /internal-notifications | All notifications. |
| GET | /internal-notifications/unread | Unread only. |
| POST | /internal-notifications/{id}/read | Mark one as read. |
| POST | /internal-notifications/read-all | Mark all read. |
| GET | /history | Undo/redo history for the caller. |
| GET | /history/session?session_id= | {undoable, redoable} counts for one editor session. |
| POST | /history/undo | Undo the session's single most recent event. Body: {session_id} — a per-tab id; "default"/empty are rejected. |
| POST | /history/redo | Redo the most recently undone event (same body). |
| GET | /realtime | Server-Sent Events stream: {type, data} events on the caller's user:{id} and active workspace:{id} channels, 25s heartbeats. Session-only. |
History is scoped to (user, workspace, per-tab session) and moves one
event per call; block writes only record history when the editor sends
X-Session-ID. Biolink block updates support optimistic concurrency:
send the loaded version and a stale save answers 409 instead of
overwriting (omit version for last-write-wins).
Public endpoints
No authentication required.
| Method | Path | Description |
|---|---|---|
| GET | /l/{url} | Short-link redirect — applies GeoIP, cookie-based unique visitors, display rules, click tracking, click limit, password gate, expiration_url. Returns 30x to the destination (or the expiration_url when limits exhausted). |
| GET | /b/{url} | Public biolink JSON — display-rule-filtered blocks ready for React rendering. |
| GET | /api/public/biolinks/{url} | Same as /b/{url} (alias). |
| POST | /b/{url}/submit | Form submission (email/phone collector). Dispatches to the page's configured notification handlers. |
| GET | /api/v1/blog | List blog posts. |
| GET | /api/v1/blog/categories | List categories. |
| GET | /api/v1/blog/{url} | Get post. |
| GET | /api/v1/pages | List CMS pages. |
| GET | /api/v1/pages/{url} | Get page. |
| GET | /api/v1/languages | i18n catalogs (for the frontend bootstrap). |
| GET | /api/v1/reference/targeting | Display-rule targeting vocabulary — see Reference data. |
| POST | /api/v1/push-subscribers | Subscribe a browser to Web Push. |
| POST | /api/v1/push-subscribers/unsubscribe | Unsubscribe. |
| GET | /api/v1/og-images | Dynamic Open Graph image generator. |
| POST | /api/v1/og-images/webhook | OG image generator webhook. |
| GET | /sitemap.xml, /sitemap-*.xml | SEO sitemaps. |
| POST | /api/v1/cookie-consent | Record cookie-consent acceptance. |
| GET | /broadcast/view | Email-open tracking pixel. |
| GET | /broadcast/click | Email-click tracking redirect. Redirects only to a URL signed for that broadcast and recipient (id, url, sig); anything else is 400. |
| GET | /unsubscribe?token= | Confirmation page for a person who opened the List-Unsubscribe link. Changes nothing. |
| POST | /unsubscribe?token= | RFC 8058 one-click unsubscribe. The token is the per-recipient token in the List-Unsubscribe URL (also accepted as a form or JSON token). Idempotent. Exempt from the CSRF header. |
| POST | /api/v1/emails/bounce | ESP webhook for bounce notification. Header X-Bounce-Secret: $BOUNCE_WEBHOOK_SECRET; 404 while that is unset, 401 without it. Body: {email, bounce_type: hard|soft|complaint, reason}. A hard bounce or complaint suppresses every later send. |
| GET | /api/public/resolve/{url} | What a bare address is, for the app's catch-all. No side effects. See Bare addresses. |
| GET | /{url}, /{url}/* | A bare address (card.site/slug, yourdomain.com/slug): the redirect path's rules. A reserved word is 404. With X-Cardsite-Spa-Fallback: 1 (set by the web server) a page the app draws is 404 so the app is served in place. |
| GET | /internal/tls/ask?domain= | Caddy on-demand TLS: 200 only for an enabled, verified custom domain (ADR-0169). Internal; never expose. |
Every public resource door (/api/public/{biolinks,vcards,events,payments,cards}/{url}, /@{url}) resolves by (host, slug): the request's Host, or the host query parameter when the app draws a custom-domain resource from its own origin (ADR-0169).
Bare addresses
card.site/{slug} and card.site/@{slug} (ADR-0170). The app's catch-all route asks:
GET /api/public/resolve/{slug}[?host=yourdomain.com]
200 {"data": {
"slug": "alice",
"type": "biolink", // a registered link type
"render": "page", // "page" | "redirect"
"page": "biolink", // biolink | vcard | event | payment | null
"data_url": "/api/public/biolinks/alice",// the type's own door, or null
"handoff_url": "/l/alice", // the redirect path
"card_url": "/api/public/cards/alice"
}}
404 — reserved word, unknown, disabled, lapsed or out of schedule
render: "page": draw the page in place from data_url; that fetch runs the gates and records the visit. render: "redirect": location.replace(handoff_url + search). ?host= is carried into every URL it returns. @{slug} stays the card route (/api/public/cards/{slug}). Reserved words: models.ReservedSlugs, the same list as apps/web/src/lib/reservedSlugs.ts; a slug that is a reserved word is refused at create and rename (409 "That address is reserved").
| GET | /api/v1/directory | Public biolink directory (opt-in via directory_is_enabled). Supports ?search=. |
| GET | /api/v1/spotlight?q=… | Global search across biolinks + short links + users. Authenticated: its result set names accounts, so an anonymous caller could enumerate them. |
Webhooks
| Method | Path | Description |
|---|---|---|
| POST | /webhook/{gateway} | Payment gateway webhook. Gateway implementations: stripe, paypal, razorpay, coinbase, mollie, paddle, paddle_billing, paystack, payu, mercadopago, midtrans, iyzico, flutterwave, klarna, lemonsqueezy, myfatoorah, plisio, plisio_whitelabel, revolut, cryptocom, yookassa. |
Each request is:
- Signature-verified (HMAC-SHA256 or gateway-specific scheme; see "Webhook signatures" below).
- Deduplicated via the
webhook_logstable —UNIQUE (gateway, external_id). Replays are rejected with 200. - Logged to
webhook_logswith(signature_valid, payload, processed_at, error). - Idempotent at the payment level — a secondary check on the
paymentstable prevents double-credit if a row was already created.
CSRF guard is exempted for /webhook/*.
Observability
Public endpoints, no auth.
| Method | Path | Description |
|---|---|---|
| GET | /health | Lightweight liveness — always 200. |
| GET | /ready | DB ping. Returns {status: "ok"|"fail", checks: {db: "ok"|"fail"}}. Use for load-balancer readiness probes. |
| GET | /metrics | Prometheus text format — requests_total, errors_total, uptime_seconds, goroutines, heap_alloc_bytes. |
Admin API
Internal contract — not for external/mobile clients. The
/admin-api/v1/*surface is documented here for platform operators only. It is not part of the published client contract (openapi.yaml) and must not be built against by the mobile app or third-party SDK consumers. It is access-gated server-side (type = 1), but its shape may change without the versioning guarantees that apply to the client surface.
/admin-api/v1/* — requires users.type = 1. Every state-changing request is recorded in admin_logs by middleware/admin_audit.go.
Catalog
| Resource group | Notes |
|---|---|
/statistics | Site-wide stats |
/users, /users/{id}, /users/{id}/plan-settings, /users/{id}/one-time-login-code | Full user admin + 70-field plan-settings override (26 limits + 25 boolean flags) |
/links, /links/{id} | Read-only list + delete |
/plans, /plans/{id} | Full CRUD |
/payments, /payments/{id}/approve | List, approve, delete |
/codes, /codes/{id}, /codes/{id}/redeemed | Full CRUD + redemption list. Supports scheduling + bulk-prefix. |
/settings, /settings/{key} | Catalog by 14 categories: general, captcha, security, payments, integrations, emails, notifications, ai, plans, branding, broadcasts, push, blog, advanced |
/taxes, /taxes/{id}, /taxes-import | Tax rules + bulk CSV import |
/internal-notifications | Batch create |
/affiliates-withdrawals, /affiliates-withdrawals/{id}/approve | Withdrawal approval |
/biolinks-templates, /biolinks-themes | Template + theme CRUD (typed BiolinkThemeSettings) |
/domains, /projects, /pixels, /qr-codes, /splash-pages, /signatures, /teams, /notification-handlers, /data | Read-only + delete |
/blog-posts, /blog-categories, /pages, /page-categories | CMS CRUD |
/broadcasts, /broadcasts/segment-count | 11-dimension segment filter (countries, continents, cities, browsers, languages, OS, browser languages, status, source, plans, newsletter, user IDs) + audience preview |
/languages | i18n catalog admin |
/push-notifications, /push-subscribers | Author push notifications, list subscribers, segment filters. Nothing sends them — services/notification.go answers the push_notifications handler type with "not yet implemented", and no VAPID key exists in the server. An owner decision, recorded under ROADMAP.md → DEFERRED (ADR-0014) |
/chat-assistants, /ai-templates, /ai-template-categories | AI prompt library |
/documents, /guest-payments, /images, /pwas, /chats, /syntheses, /transcriptions, /biolink-blocks | Read-only + delete |
/payment-processors | Read-only + delete (user side handles CRUD) |
/invoices/{id}, /credit-notes/{id} | Admin PDF download |
/system-logs, /system-logs/{name}, /system-logs/{name}/download | Application log viewer over $UPLOAD_PATH/logs/, where the request logger appends api.log |
/feature-flags, /feature-flags/{id} | Full CRUD over the feature-flag registry |
/plugins | Read-only. The modules compiled into this server, each with status (active / inactive / built_in) resolved from the services the process actually constructed, and the configuration keys it reads — key names and a set boolean, never values. Status reflects the configuration loaded at startup (ADR-0014) |
GDPR
Export
curl -X GET https://prod.cardsite.io/api/v1/account/export \
-H "Authorization: Bearer $TOKEN" \
-o my-data.zip
Returns a ZIP archive with one JSON file per data category. Currently covers: profile.json, links.json, qr_codes.json, payments.json, activity_logs.json, notification_handlers.json, splash_pages.json, domains.json, pixels.json, projects.json, uploads.json.
Deletion
curl -X DELETE https://prod.cardsite.io/api/v1/account \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-H "X-Requested-With: XMLHttpRequest" \
-d '{"password": "your-password"}'
password is required for re-authentication. The deletion cascades across all user-owned tables.
Background jobs
Long-running tasks are dispatched to an internal PostgreSQL job queue (job_queue table, migration 000020):
- Workers: 3 goroutines polling with
SELECT … FOR UPDATE SKIP LOCKED LIMIT 1(multi-replica safe). - Retries: exponential back-off (
2^attemptminutes), up tomax_attemptsbefore the row is marked dead. - Reaper: a separate goroutine resets
runningrows older than 10 minutes (covers worker crashes). - Registered handlers:
send_email,broadcast_email,ai_image_generate.
There is no public job-status endpoint — jobs are an implementation detail of broadcast emails and async AI image generation. Failed jobs surface to admins via /admin-api/v1/system-logs.
Feature flags
# Authenticated — the flags on for the signed-in user, evaluated against
# their plan. 401 without a session; anonymous callers have no plan, so
# there is nothing to evaluate (ADR-0011).
GET /api/v1/feature-flags/evaluate
→ { "data": ["new_editor", "beta_directory"], "meta": null, "error": null }
Admins manage the registry under /admin-api/v1/feature-flags. Each flag has {key, name, description, enabled, plan_ids} — a flag is "on" for a user when enabled=true AND (plan_ids is blank OR it names the user's users.plan_id). plan_ids is a comma-separated list of numeric plan IDs; the API rejects anything else with 400, because a plan name stored there would list back as targeting and match nobody.
Frontend hook — the key comes from the registry, never a loose string, and
scripts/check-entitlement-parity.mjs fails the build on both a key that is not
registered and a registered key nothing reads:
import { FEATURE_FLAGS } from '../lib/featureFlags';
const isOn = useFeatureFlag(FEATURE_FLAGS.bioPageUnwiredSettings);
isOn is false while the evaluation is in flight and false if it fails, so a
flag must always grant the deviation and never the default (ADR-0011).
Webhook signatures
Every gateway with secret support verifies inbound webhooks. Examples:
| Gateway | Header / scheme |
|---|---|
| Stripe | Stripe-Signature: t=…,v1=… (HMAC-SHA256 of t.payload) |
| PayPal | paypal-transmission-id + paypal-cert-url (PayPal verification API) |
| Razorpay | X-Razorpay-Signature (HMAC-SHA256) |
| Coinbase | X-CC-Webhook-Signature (HMAC-SHA256) |
| Paddle (classic) | p_signature field with public-key signature verification |
| Paddle Billing | Paddle-Signature: ts=…;h1=… (HMAC-SHA256) |
| Plisio / Plisio Whitelabel | verify_hash in body |
| Flutterwave | verif-hash header |
If a signature fails, the row is still written to webhook_logs with signature_valid=false and an error is logged. The request returns 400.
Display rules
display_rules is a JSONB column on links and biolinks_blocks. Each
dimension is two flat keys — a list and its condition — not a nested
object. All keys are optional; an absent or empty list means "allow all".
{
"countries": ["US", "CA"], "countries_condition": "show",
"continents": ["NA"], "continents_condition": "show",
"cities": ["New York"], "cities_condition": "show",
"browsers": ["chrome"], "browsers_condition": "show",
"operating_systems": ["ios"], "operating_systems_condition": "show",
"device_types": ["mobile"], "device_types_condition": "show",
"languages": ["en"], "languages_condition": "show"
}
A condition defaults to "show". show hides the row when the visitor does
not match; hide hides it when they do.
Values are matched whole-string, case-insensitively, against what the
server resolved for that visitor — so "en-US" never matches (the language
compared is the primary subtag, "en"), and neither does any value the server
cannot produce. Get the vocabulary from
GET /api/v1/reference/targeting rather than writing
literals: it returns one {value, label} list per key above, and the browser,
OS and device lists are derived from the parser that names visitors, so they
cannot offer an unmatchable value (ADR-0017).
cities has no list — it is free text compared against the resolved English
city name.
Plus two schedule keys inside the same blob, RFC 3339 strings:
scheduled_at— row invisible before thisscheduled_end— row invisible after this
(links and biolinks_blocks also carry scheduled_at, scheduled_end and
timezone as columns, from migration 000013. The columns and the keys are
separate mechanisms; Match reads the keys.)
services/display_rules.go → DisplayRulesService.Match(rules, ctx) is called
from the public biolink handler and from the redirect handler, with a
VisitorContext derived from the request (GeoIPService +
services/useragent.go). A link whose rules exclude the visitor answers the
404 a missing link shows (ADR-0090).
Reference data
| Method | Path | Description |
|---|---|---|
| GET | /api/v1/reference/targeting | Public. The vocabulary a display_rules object may name, keyed by the display_rules key each list populates: continents (7), countries (~250, ISO 3166-1 alpha-2), browsers, operating_systems, device_types, languages (~190, ISO 639-1). Each entry is {value, label}; value is what a rule stores and what the server matches, label is display only. |
Plan limits
Every Create handler calls services/plan_limits.go → CheckLinks/Biolinks/QrCodes/Domains/Pixels/Projects/etc. Returns 422 with {limit, current, max} if the user is at quota. Admins can override per-user limits via PUT /admin-api/v1/users/{id}/plan-settings (26 numeric limit fields + 25 boolean feature-flag toggles). The body must be a JSON object — null, an array, a string or a number is refused with 400, and {} is how the overrides are cleared. Registered quota keys are validated there exactly as on the plan form, and it matters more on this path: the override wins over the plan, so a value the enforcement read cannot parse would silently beat a correct number on the plan.
Block types schema
Every biolink block is described by a BlockTypeInfo:
type BlockTypeInfo struct {
Type string // e.g. "link", "heading", "donation"
Name string // human label
Icon string // Lucide icon name
Group string // category in the Bio page editor's block palette
Fields []BlockFieldSpec
}
type BlockFieldSpec struct {
Name string
Kind string // see Kind table below
Label string
Help string
DefaultValue any
Validation string // optional regex / rule
Options []FieldOption // for select / multi_select
}
| Kind | Frontend renderer |
|---|---|
text, textarea, url, email, phone | Input / Textarea |
color | ColorPicker |
image_upload, file_upload | FileUploader |
bool | Switch |
int | Input type="number" |
select, multi_select | Select / MultiSelect |
datetime | DateTimePicker |
timezone | TimezonePicker |
rich_text | RichTextEditor |
code | CodeEditor |
display_rules | DisplayRulesEditor |
notification_handlers_picker | NotificationHandlersPicker |
payment_processors_picker | PaymentProcessorsPicker |
markers_list | MarkersList |
times_grid | TimesGrid |
GET /api/v1/biolink-blocks/types returns the full registry — 85 typed block types covering links, social, media, forms, e-commerce, calendar, custom code, and integrations.
See also
shared/contracts/openapi.yaml— machine-readable specdocs/ARCHITECTURE.md— system architecture + multi-region ADRdocs/SECURITY.md— security checklistdocs/PERFORMANCE.md— load-test baselinedocs/DEPLOYMENT.md— install + backup/DRstudio/studio/README.md— the Studio design system: tokens, components, interaction patterns
Source: docs/API.md