Skip to Content
API

API quick start

Create an API key, make your first three calls, and see the same task written in curl, Python, and TypeScript.

View as Markdown

This page takes you from no credential to a useful answer. It assumes nothing except that you can already sign in to VitalSentinel.

1. Create an API key

You create API keys in the app. The public API cannot create keys, so one credential cannot create another credential.

The Create API key panel with the Name field, an optional expiry date and the list of read scopes to select.

  1. If you have more than one workspace, switch to the workspace that the key is for. A key belongs to the workspace that is active when you create it.
  2. Open the API access page. You must have the owner or admin role. A member sees only their own keys and cannot create a key.
  3. Click New key. If the workspace has no keys yet, click Create API key.
  4. Fill in the fields:
    • Name: a name for the key, shown in the key list. For example, Reporting script.
    • Scopes: the scopes are in three tiers, Read, Configure and Run. For this guide, select read:overview and read:domains.
    • Expires (optional): if you leave it blank, the key never expires.
    • IP allowlist (optional): addresses or CIDR ranges, for example 203.0.113.4 or 203.0.113.0/24.
  5. Click Create key.
  6. Copy the secret.

The app shows the secret only one time. VitalSentinel keeps only a SHA-256 digest of it. After that, the key list shows only the first 16 characters. If you lose the secret, rotate the key to get a new one.

A production secret starts with vsk_live_, followed by 43 characters.

2. Authenticate

Send the secret as a bearer token:

export VITALSENTINEL_API_KEY="vsk_live_..."

curl -sS https://app.vitalsentinel.com/api/public/v1/health \
  -H "Authorization: Bearer $VITALSENTINEL_API_KEY"

That is the only accepted mechanism. The API never accepts session cookies. A key in a query string would go into access logs and browser history, so the API does not accept that either.

3. Ask who you are: GET /me

Call this first from any new client. In one request, it tells you who you are, what you can do, and which workspaces you can reach.

curl -sS https://app.vitalsentinel.com/api/public/v1/me \
  -H "Authorization: Bearer $VITALSENTINEL_API_KEY"
{
  "kind": "api_key",
  "credential_id": "6f1d0f5c-2a3b-4c1d-9e8f-0a1b2c3d4e5f",
  "user_id": "3b9f7a11-8c42-4d6e-9a03-5f2e1c7b8d90",
  "workspace_ids": ["e0d4a2c8-1b77-4f39-9c52-6a8d3e0f4b21"],
  "scopes": ["read:domains", "read:overview"],
  "effective_scopes": ["read:domains", "read:overview"],
  "roles": { "e0d4a2c8-1b77-4f39-9c52-6a8d3e0f4b21": "admin" }
}

Build your client's capability list from effective_scopes, never from scopes. See Scopes for why the two can differ.

4. Find a domain

curl -sS https://app.vitalsentinel.com/api/public/v1/domains \
  -H "Authorization: Bearer $VITALSENTINEL_API_KEY"
{
  "items": [
    {
      "id": "9c2f4d18-5e6a-4b70-8c19-2d3f5a7b9e04",
      "workspace_id": "e0d4a2c8-1b77-4f39-9c52-6a8d3e0f4b21",
      "domain": "example.com",
      "active_modules": ["uptime", "crux", "gsc", "indexing", "robots"],
      "monitoring": { "state": "verified", "monitoring": true },
      "created_at": "2026-01-14T09:22:41Z"
    }
  ],
  "total": 1,
  "has_more": false,
  "next_cursor": null
}

active_modules shows which modules have stored configuration for this domain, so you can skip the ones that are not set up. It can contain uptime, crux, synthetic, gsc, indexing, robots, sitemap, alerts, reports, server_logs, page_monitoring, forms and site_health. forms shows when the domain has an active tracked form. It means configured, not has data. A module set up this morning has no data yet.

Send include_modules=false when you list many domains and need only identifiers. workspace_id limits the list to one workspace.

Is the domain monitored?

monitoring tells you if VitalSentinel monitors the domain. VitalSentinel checks and collects nothing until someone verifies the ownership of the domain in the app. The state values are:

  • verified: VitalSentinel monitors the domain.
  • grace: the domain is not verified yet, or it lost its verification. VitalSentinel monitors it until grace_until.
  • paused or unverified: VitalSentinel checks and collects nothing. Old data stays readable, but no new data arrives.

If monitoring is false, empty answers from the module endpoints are normal. You cannot verify a domain through the API.

analytics and rum are never listed, and their absence means nothing. Neither has a domain-scoped configuration row to test, because both activate when the tracking script starts reporting. Call those endpoints directly, or GET /domains/{domain_id}/rum/has-data, rather than inferring from this list.

/domains and /workspaces return the standard page envelope but always as a single page today, so next_cursor is always null. Write the paging loop anyway: the envelope exists so that pagination can be added later without a breaking change.

To work on all of your domains, make a loop over this list. The API has no endpoint that acts on many domains at the same time.

5. Get the summary of a domain

GET /domains/{domain_id}/overview returns every module that is set up for the domain in one request, with a comparison against the previous period. It needs read:overview. The full response also has verdict and module_status, the same judgement that the dashboard shows. The example below is shorter.

curl -sS \
  "https://app.vitalsentinel.com/api/public/v1/domains/$DOMAIN_ID/overview" \
  -H "Authorization: Bearer $VITALSENTINEL_API_KEY"
{
  "domain_id": "9c2f4d18-5e6a-4b70-8c19-2d3f5a7b9e04",
  "domain": "example.com",
  "rum": {
    "mobile": { "lcp_ms": 3120.0, "cls": 0.09, "inp_ms": 265.0, "ttfb_ms": 810.0 },
    "desktop": { "lcp_ms": 1840.0, "cls": 0.04, "inp_ms": 128.0, "ttfb_ms": 420.0 }
  },
  "crux": {
    "mobile": { "lcp_ms": 2980.0, "cls": 0.11, "inp_ms": 248.0, "ttfb_ms": 900.0 },
    "desktop": { "lcp_ms": 1760.0, "cls": 0.05, "inp_ms": 142.0, "ttfb_ms": 460.0 }
  },
  "uptime": {
    "uptime_pct": 99.94,
    "ssl_days_remaining": 47,
    "domain_days_remaining": 214,
    "is_blocked_403": false
  },
  "gsc": {
    "web": { "clicks": 18422, "impressions": 964130, "ctr": 0.0191, "position": 14.7 },
    "discover": null,
    "news": null
  },
  "analytics": {
    "visitors": 41208,
    "pageviews": 96431,
    "sessions": 52117,
    "bounce_rate_pct": 47.3,
    "avg_duration_seconds": 132.6
  },
  "comparison": {
    "gsc": {
      "web": {
        "clicks": { "current": 18422, "previous": 16903, "change": 1519, "change_pct": 8.99 },
        "position": { "current": 14.7, "previous": 15.4, "change": -0.7, "change_pct": -4.55 }
      }
    },
    "analytics": {
      "visitors": { "current": 41208, "previous": 38790, "change": 2418, "change_pct": 6.23 }
    }
  },
  "unavailable_modules": [],
  "configured_modules": ["uptime", "crux", "gsc", "indexing", "robots"],
  "compare_range_start": "2026-06-07T09:41:12Z",
  "compare_range_end": "2026-07-05T09:41:12Z",
  "meta": {
    "range_start": "2026-07-05T09:41:12Z",
    "range_end": "2026-08-02T09:41:12Z",
    "generated_at": "2026-08-02T09:41:12Z"
  }
}

Five things in that response are easy to misread:

  1. The window is the last 28 complete UTC days, and you cannot change it. meta.range_start and meta.range_end report it, so you do not have to guess.
  2. configured_modules tells a quiet module apart from a missing one. A module in that list with a null block is set up but reported nothing in this window. A module that is not in the list is not configured. rum and analytics are never in the list, because they have no configuration. Their null always means "nothing in this window".
  3. A module that failed is named in unavailable_modules, and the rest of the response is still valid. Check that array before you read a null as "no data".
  4. comparison covers only three modules: CrUX, Search Console and Web Analytics. The other modules have no previous figure here, and GET /domains/{domain_id}/health has them. compare_range_start and compare_range_end name the previous 28-day window. A negative position.change means that the ranking improved. change_pct is null when the previous value was zero.
  5. The answer comes from the cache and can be up to one hour old. meta.cache_age_seconds shows how old it is. This endpoint has no freshness control, so do not use it for the question "is the site up now". Use GET /domains/{domain_id}/health?freshness=live, which calculates every module again, or GET /domains/{domain_id}/uptime/status, which is never cached.

Units are in the field names: lcp_ms, ttfb_ms, bounce_rate_pct, avg_duration_seconds. cls is a score with no unit. ctr is a fraction between 0 and 1 (0.0191 means 1.91%). All Core Web Vitals figures are the 75th percentile.

The same task in three languages

Task: for every domain the credential can see, print the 28-day Web Analytics visitors and Search Console clicks, with the change against the previous period.

All three snippets do the same four things. They send the bearer token and retry once on a 429 with Retry-After. They raise an error from the error response, not from the status code alone, and they accept a null module block.

curl

#!/usr/bin/env bash
set -euo pipefail

BASE="https://app.vitalsentinel.com/api/public/v1"
AUTH="Authorization: Bearer $VITALSENTINEL_API_KEY"

# Fetch with one retry that respects Retry-After.
fetch() {
  local url="$1" body status retry
  body=$(curl -sS -w '\n%{http_code}' -H "$AUTH" "$url")
  status=$(printf '%s' "$body" | tail -n1)
  if [ "$status" = "429" ]; then
    retry=$(curl -sSI -H "$AUTH" "$url" | awk 'tolower($1)=="retry-after:"{print $2+0}')
    sleep "${retry:-5}"
    body=$(curl -sS -w '\n%{http_code}' -H "$AUTH" "$url")
    status=$(printf '%s' "$body" | tail -n1)
  fi
  if [ "$status" -ge 400 ]; then
    printf 'error %s: %s\n' "$status" "$(printf '%s' "$body" | sed '$d')" >&2
    return 1
  fi
  printf '%s' "$body" | sed '$d'
}

# include_modules=false keeps the listing cheap when you only need identifiers.
fetch "$BASE/domains?include_modules=false" \
  | jq -r '.items[] | "\(.id)\t\(.domain)"' \
  | while IFS=$'\t' read -r id domain; do
      fetch "$BASE/domains/$id/overview" | jq -r --arg d "$domain" '
        "\($d)\t" +
        "visitors=\(.analytics.visitors // "n/a")\t" +
        "visitors_change=\(.comparison.analytics.visitors.change_pct // "n/a")%\t" +
        "clicks=\(.gsc.web.clicks // "n/a")\t" +
        "clicks_change=\(.comparison.gsc.web.clicks.change_pct // "n/a")%"'
    done

Python

"""Print 28-day visitors and Search Console clicks for every accessible domain."""

import os
import time

import httpx

BASE = "https://app.vitalsentinel.com/api/public/v1"


class VitalSentinelError(RuntimeError):
    """An RFC 9457 problem response. Branch on `type_suffix`, never on `detail`."""

    def __init__(self, problem: dict):
        self.problem = problem
        self.type_suffix = problem.get("type", "").rsplit("/", 1)[-1]
        self.status = problem.get("status")
        self.request_id = problem.get("request_id")
        super().__init__(f"{problem.get('title')}: {problem.get('detail')}")


class Client:
    def __init__(self, api_key: str, base: str = BASE):
        self._http = httpx.Client(
            base_url=base,
            headers={"Authorization": f"Bearer {api_key}"},
            timeout=60.0,
        )

    def get(self, path: str, **params) -> dict:
        response = self._http.get(path, params=params or None)

        # One retry, pacing off Retry-After rather than a fixed sleep.
        if response.status_code == 429:
            time.sleep(int(response.headers.get("Retry-After", "5")))
            response = self._http.get(path, params=params or None)

        if response.status_code >= 400:
            raise VitalSentinelError(response.json())
        return response.json()

    def domains(self) -> list[dict]:
        """Page through every accessible domain. Cursors are opaque - pass them back verbatim."""
        items, cursor = [], None
        while True:
            page = self.get("/domains", include_modules=False, cursor=cursor)
            items.extend(page["items"])
            if not page.get("has_more"):
                return items
            cursor = page["next_cursor"]


def pct(block: dict | None, metric: str) -> str:
    """A null module block means unconfigured, or configured and quiet. Never an error."""
    if not block:
        return "n/a"
    change = block.get(metric, {}).get("change_pct")
    return "n/a" if change is None else f"{change:+.2f}%"


def main() -> None:
    client = Client(os.environ["VITALSENTINEL_API_KEY"])

    for domain in client.domains():
        overview = client.get(f"/domains/{domain['id']}/overview")

        if overview.get("unavailable_modules"):
            print(f"  ! modules unavailable: {', '.join(overview['unavailable_modules'])}")

        analytics = overview.get("analytics")
        gsc = (overview.get("gsc") or {}).get("web")
        comparison = overview.get("comparison") or {}

        print(
            f"{domain['domain']:<32} "
            f"visitors={analytics['visitors'] if analytics else 'n/a':>10} "
            f"({pct(comparison.get('analytics'), 'visitors')})  "
            f"clicks={gsc['clicks'] if gsc else 'n/a':>10} "
            f"({pct((comparison.get('gsc') or {}).get('web'), 'clicks')})"
        )


if __name__ == "__main__":
    main()

TypeScript

/** Print 28-day visitors and Search Console clicks for every accessible domain. */

const BASE = "https://app.vitalsentinel.com/api/public/v1";

interface Problem {
  type: string;
  title: string;
  status: number;
  detail: string;
  request_id: string;
}

/** Branch on `typeSuffix`, never on the prose in `detail`. */
export class VitalSentinelError extends Error {
  readonly typeSuffix: string;

  constructor(readonly problem: Problem) {
    super(`${problem.title}: ${problem.detail}`);
    this.typeSuffix = problem.type.split("/").pop() ?? "unknown";
  }
}

const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));

async function get<T>(path: string, apiKey: string): Promise<T> {
  const request = () =>
    fetch(`${BASE}${path}`, { headers: { Authorization: `Bearer ${apiKey}` } });

  let response = await request();

  // One retry, pacing off Retry-After rather than a fixed sleep.
  if (response.status === 429) {
    await sleep(Number(response.headers.get("Retry-After") ?? 5) * 1000);
    response = await request();
  }

  if (!response.ok) throw new VitalSentinelError((await response.json()) as Problem);
  return (await response.json()) as T;
}

interface Page<T> {
  items: T[];
  next_cursor: string | null;
  has_more: boolean;
  total: number | null;
}

interface Domain {
  id: string;
  domain: string;
}

/** Cursors are opaque base64url. Pass them back verbatim; never parse or construct one. */
async function listDomains(apiKey: string): Promise<Domain[]> {
  const all: Domain[] = [];
  let cursor: string | null = null;

  do {
    const query = new URLSearchParams({ include_modules: "false" });
    if (cursor) query.set("cursor", cursor);

    const page: Page<Domain> = await get(`/domains?${query}`, apiKey);
    all.push(...page.items);
    cursor = page.has_more ? page.next_cursor : null;
  } while (cursor);

  return all;
}

interface Change {
  current: number | null;
  previous: number | null;
  change: number | null;
  change_pct: number | null;
}

interface Overview {
  analytics: { visitors: number } | null;
  gsc: { web: { clicks: number } | null } | null;
  comparison: {
    analytics?: { visitors?: Change };
    gsc?: { web?: { clicks?: Change } };
  } | null;
  unavailable_modules: string[];
}

// change_pct is null when the previous window was zero. Do not format it as 0.00%.
const fmt = (change?: Change) =>
  change?.change_pct == null
    ? "n/a"
    : `${change.change_pct >= 0 ? "+" : ""}${change.change_pct.toFixed(2)}%`;

async function main(): Promise<void> {
  const apiKey = process.env.VITALSENTINEL_API_KEY;
  if (!apiKey) throw new Error("VITALSENTINEL_API_KEY is not set");

  for (const domain of await listDomains(apiKey)) {
    const overview = await get<Overview>(`/domains/${domain.id}/overview`, apiKey);

    if (overview.unavailable_modules.length > 0) {
      console.warn(`  ! modules unavailable: ${overview.unavailable_modules.join(", ")}`);
    }

    // A null module block means unconfigured, or configured and quiet. Never a failure.
    const visitors = overview.analytics?.visitors ?? "n/a";
    const clicks = overview.gsc?.web?.clicks ?? "n/a";

    console.log(
      `${domain.domain.padEnd(32)} ` +
        `visitors=${String(visitors).padStart(10)} (${fmt(overview.comparison?.analytics?.visitors)})  ` +
        `clicks=${String(clicks).padStart(10)} (${fmt(overview.comparison?.gsc?.web?.clicks)})`,
    );
  }
}

main().catch((error) => {
  if (error instanceof VitalSentinelError) {
    console.error(`[${error.typeSuffix}] ${error.message} (request ${error.problem.request_id})`);
    process.exit(1);
  }
  throw error;
});

Next

On this page

VitalSentinel

Know what changed before it costs you revenue

A stray noindex, a robots.txt change, a slower LCP, a Googlebot crawl drop: one alert, with what to fix first.

  • Free plan for 1 domain
  • Set up in minutes
  • No credit card required