Skip to Content
API

Authentication

API keys and the OAuth 2.1 authorization flow, including PKCE, resource binding, token lifetimes, and rotation.

View as Markdown

Every request to the public API carries a bearer token:

Authorization: Bearer <credential>

That is the only accepted mechanism. Two kinds of credential fit in that header. The API resolves both to the same identity, so the same rules for scopes, rate limits and credits apply to each.

Session cookies are never accepted. A request carrying a valid dashboard cookie and no Authorization header gets a 401 from every public endpoint, with no exception. Do not put a credential in a query string either. A query string goes into access logs and browser history.

Which one do you need?

API keyOAuth 2.1 app
Who holds itYouEach of your users
Created byAn owner or admin, in the appYour app, through a browser consent flow
ReachesExactly one workspaceThe workspaces the user selected at consent
LifetimeUntil revoked, or an optional expiryAccess token 60 minutes, refresh token 90 days
Right forYour own scripts, servers, CI, internal dashboardsA product other people sign in to, and MCP clients

If you are building something for yourself, use an API key and skip to Scopes. If you are building something other people connect their VitalSentinel account to, you need OAuth.

API keys

Creating one

See Quick start for each step. In short: open the API access page in your account settings. You need the owner or admin role. The key belongs to the workspace that is active when you create it.

The secret is shown exactly once. VitalSentinel stores only a SHA-256 digest, so a lost key must be rotated, not recovered.

Format

EnvironmentPrefixLength
Productionvsk_live_43 characters after the prefix
Everywhere elsevsk_dev_43 characters after the prefix

The prefix shows the environment, so a development key does not work in a production client. The key list in the dashboard shows the first 16 characters of each key so you can tell them apart.

One key, one workspace

A key belongs to a single workspace. To read several workspaces, you need one key for each workspace, or an OAuth grant. An OAuth grant can cover every workspace that the user selected on the consent screen.

A workspace can hold a limited number of live keys. See Plans and limits. Each live key has its own rate-limit bucket and is one more secret that can leak. Thus the number of keys has a limit, but API access itself does not.

Expiry, IP allowlists, and rotation

ControlBehavior
ExpiresOptional. Blank means the key never expires.
IP allowlistOptional list of addresses or CIDR ranges. A request from outside the list is rejected, and an allowlist that cannot be evaluated denies rather than allows.
RotateIssues a new secret while the old one keeps working through a Grace window you choose: none, 1 hour, 24 hours (recommended), 3 days, or 7 days. A rotation is not a hard cutover across every deployed client at once.
RevokeImmediate. There is no grace window, so use Rotate if you need one.

VitalSentinel records last_used_at at most once a minute. The key list tells you if something still uses a key, but it is not a precise audit trail. For that, see the Data access log of the workspace.

Every failure looks the same

No such key, revoked, expired, past its rotation grace period, IP outside the allowlist: all of these return the identical 401 body. That is deliberate. Distinguishing them would let someone holding a guessed key learn that it was once real.

OAuth 2.1

The authorization server lives in the VitalSentinel application, not in the MCP server. Any app can use it. The MCP server was the first consumer, but nothing about it is MCP-specific.

The flow is standard OAuth 2.1 authorization code with PKCE, plus RFC 8707 resource indicators. If your framework already speaks OAuth 2.1, the only unusual requirement is that the resource parameter is mandatory.

Discovery

Both documents are unauthenticated and served from the site root, not under the API prefix:

DocumentURLSpecification
Authorization server metadatahttps://app.vitalsentinel.com/.well-known/oauth-authorization-serverRFC 8414
Protected resource metadatahttps://app.vitalsentinel.com/.well-known/oauth-protected-resourceRFC 9728

A 401 from any endpoint also carries a WWW-Authenticate: Bearer resource_metadata="..." header pointing at the second document. That is the entire discovery mechanism for a client that has never seen VitalSentinel before.

Step 1: register your client

This does not work like Google OAuth. There is no console to visit, no project to create, and no credentials issued to you out of band ahead of time. Your code calls the registration endpoint at runtime and gets a client_id back in the response. Nobody approves it.

This is what makes MCP work. An AI client that does not know VitalSentinel finds this endpoint, registers itself and connects. No person has to approve the client.

Dynamic client registration (RFC 7591) is open by design, so a client can self-register on first use with no manual approval step.

curl -sS -X POST https://app.vitalsentinel.com/api/public/v1/oauth/register \
  -H "Content-Type: application/json" \
  -d '{
    "client_name": "Acme SEO Dashboard",
    "redirect_uris": ["https://acme.example.com/oauth/callback"],
    "grant_types": ["authorization_code", "refresh_token"],
    "response_types": ["code"],
    "token_endpoint_auth_method": "none"
  }'

The response carries your client_id immediately. Registration is rate limited per source address, at 20 per hour.

Do you get a client secret?

Only if you ask for one. token_endpoint_auth_method decides:

ValueYou are aSecretProof at token exchange
none (default)Public clientNone issuedThe PKCE code_verifier
client_secret_basicConfidential clientIssued once, at registrationThe secret, plus PKCE
client_secret_postConfidential clientIssued once, at registrationThe secret, plus PKCE

Use none for anything a user runs: a desktop app, a CLI, a browser app, an MCP client. A secret shipped to a user's machine is not a secret, which is what PKCE exists to replace.

Use a confidential client only when the exchange happens on a server you control and the secret never leaves it.

An issued secret is returned once, in the registration response, and is stored hashed. It does not expire. If you lose it, register a new client.

Registration does not deduplicate. Every call creates a new client_id, even with an identical name and redirect URI. Register once and store the result; do not register on every start.

Registered clients start unverified, and an unverified client works exactly like a verified one. The authorization endpoint never consults the flag. It changes only what the consent screen shows. An unverified app gets a not verified warning, so the user checks the redirect URI with more care. Verification is a trust signal for your users, not an access control on you.

Registration is open and unauthenticated, so your app is usable by any VitalSentinel user the moment you register it. There is no review queue to wait in and no approval to request.

The rules that do bind you:

RuleDetail
Redirect URIs are matched by exact string equality at authorization timeNever a prefix match, so register every exact URI you will use
No wildcardsA * anywhere in a redirect URI is rejected at registration
https onlyExcept http on 127.0.0.1, ::1, or localhost, for desktop clients
Length2048 characters maximum per URI
PKCEMandatory, S256 only

Or publish a client ID metadata document

Instead of registering, your client can use an https URL as its client_id. The URL points to a JSON document that describes the client (a Client ID Metadata Document). For example, Claude uses https://claude.ai/oauth/mcp-oauth-client-metadata. The authorization server metadata advertises client_id_metadata_document_supported: true. Dynamic client registration stays available.

VitalSentinel downloads the document when the client first sends the user to authorize, and checks it:

RuleDetail
The client_id URLhttps, with a path, 64 characters maximum
client_id in the documentMust be exactly the URL of the document
token_endpoint_auth_methodMust be none. The document must not contain a client_secret
redirect_urisAt least one, with the same rules as registration
Content typeapplication/json

VitalSentinel keeps the document for the max-age of its Cache-Control header, between 5 minutes and 24 hours. Without max-age, it keeps the document for 1 hour.

For a document client, an http redirect URI on 127.0.0.1, ::1 or localhost matches on any port. The scheme, host, path and query must still match exactly. A local app, such as Claude Code, can publish http://localhost/callback and listen on any port. Registered clients keep exact matching.

The consent screen shows App identity published by with the host and the full client_id. A document client starts unverified, the same as a registered client.

Step 2: send the user to authorize

GET https://app.vitalsentinel.com/api/public/v1/oauth/authorize
  ?response_type=code
  &client_id=<your client_id>
  &redirect_uri=https://acme.example.com/oauth/callback
  &scope=read:overview%20read:domains%20read:gsc
  &state=<random, single-use>
  &code_challenge=<base64url(sha256(verifier))>
  &code_challenge_method=S256
  &resource=https://api.vitalsentinel.com
ParameterRequirement
response_typeMust be code.
code_challenge_methodMust be S256. PKCE is mandatory; plain is not accepted.
resourceRequired, exactly one value. See Resource binding below.
scopeSpace-delimited scope strings. See Scopes.
stateNot optional in practice. Generate it randomly per attempt and check it on the callback.

The endpoint validates the request and redirects the browser to the VitalSentinel consent screen carrying a signed, ten-minute request handle. It never renders HTML itself.

If the client is unknown or the redirect URI is not registered, the error comes back to you directly. A redirect to an unverified URI would itself be the vulnerability. Every other failure also comes back to you directly, as a 400 problem response, not as a redirect. Its type is the OAuth error code, for example invalid-scope. Only first-party VitalSentinel clients get these errors as a redirect to the redirect URI, with an error parameter. If the user denies access on the consent screen, VitalSentinel still redirects to your redirect URI with error=access_denied.

Step 3: the user consents

The consent screen shows your client name, your full redirect URI and a workspace picker. It also shows the scopes that you asked for, in the tiers Read, Configure and Run. The user selects which workspaces the grant reaches. That is not always all of them.

On approval the browser is redirected to your redirect_uri with code and state.

Step 4: exchange the code

curl -sS -X POST https://app.vitalsentinel.com/api/public/v1/oauth/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d grant_type=authorization_code \
  -d code=<the code> \
  -d redirect_uri=https://acme.example.com/oauth/callback \
  -d client_id=<your client_id> \
  -d code_verifier=<the original verifier> \
  -d resource=https://api.vitalsentinel.com
{
  "access_token": "eyJhbGciOi...",
  "token_type": "Bearer",
  "expires_in": 3600,
  "refresh_token": "vsr_...",
  "scope": "read:overview read:domains read:gsc"
}

Check the returned scope. It shows the scopes that the user granted. These can be fewer than what you asked for.

Authorization codes are single-use and expire after 60 seconds.

Step 5: refresh

curl -sS -X POST https://app.vitalsentinel.com/api/public/v1/oauth/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d grant_type=refresh_token \
  -d refresh_token=<current refresh token> \
  -d client_id=<your client_id> \
  -d resource=https://api.vitalsentinel.com

Refresh tokens are single-use and rotate on every call. Every refresh returns a new one and invalidates the one you sent. If you send a refresh token that was already replaced, VitalSentinel revokes the full grant and every access token of that grant. Only a copy can still hold an old refresh token.

Thus, store the new refresh token before you use the new access token. Never run two refresh attempts at the same time for the same grant. A retry loop that refreshes twice signs your user out.

Token lifetimes

TokenLifetimeShape
Access token60 minutesJWT, bound to the resource chosen at authorization
Refresh token90 daysOpaque, stored hashed, single-use with rotation
Authorization code60 secondsSingle-use

Revoking

curl -sS -X POST https://app.vitalsentinel.com/api/public/v1/oauth/revoke \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d token=<an access or refresh token> \
  -d client_id=<your client_id>

RFC 7009. Accepts either token type and revokes the whole grant behind it, including access tokens already issued. It always returns 200, including for an unknown token, so it cannot be used to test whether a token exists.

Users can also revoke your app on the Connected apps page. It lists their live grants and the workspaces that each grant reaches. Build for this: a grant can disappear at any time, and your next call then gets a 401.

Resource binding is mandatory

The resource parameter (RFC 8707) fixes the audience your token is valid for. It is set at authorization time, copied onto the grant at exchange time, and can never be re-chosen later.

Targetresource value
REST APIhttps://api.vitalsentinel.com
MCP serverhttps://mcp.vitalsentinel.com

The two are not symmetric, and it matters when you decide which to ask for:

Token minted withREST APIMCP server
resource=https://api.vitalsentinel.comAcceptedRejected, 401 with invalid_token
resource=https://mcp.vitalsentinel.comAcceptedAccepted

The MCP server holds no credentials of its own and sends your token unchanged to the REST API. Thus the REST API must accept an MCP-audience token, or MCP cannot work. The check in the other direction is strict: the MCP server rejects a REST-audience token. A token copied from a REST client cannot be used again in an MCP session.

For an ordinary REST integration, use the REST identifier. There is no privilege difference between the two, only reach.

The binding still has a purpose. A token made for this deployment cannot be used against a different resource server that trusts the same authorization server. A wrong audience returns 401 with invalid-audience, not a scope error. Thus you can tell it apart from a permissions problem.

OAuth endpoint rate limits

These endpoints run before a credential exists, so they are limited per source IP rather than per credential:

EndpointLimit
POST /oauth/register20 per hour
GET /oauth/authorize120 per hour
Consent screen (resolve and submit)120 per hour, shared, so a completed consent spends two units
POST /oauth/token3,000 per hour
POST /oauth/revoke600 per hour

Behind a corporate NAT or a mobile carrier's shared address space, every user shares one bucket. Budget accordingly.

Error format on OAuth endpoints

The token endpoint returns RFC 6749 errors, not the application/problem+json shape the rest of the API uses:

{ "error": "invalid_grant", "error_description": "Authorization code has expired" }

Every other endpoint uses the problem format.

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