Authentication
How to authenticate with the VPNDetection HTTP API.
Present your API key any of three ways, whichever suits your client:
curl -H "Authorization: Bearer $KEY" https://api.vpndetection.io/45.83.91.1
curl -H "X-Api-Key: $KEY" https://api.vpndetection.io/45.83.91.1
curl "https://api.vpndetection.io/45.83.91.1?apikey=$KEY"They are the same key. The query parameter exists for curl and the browser; prefer a header where setting one is easy. Create a key in the console.
The account, organization and key endpoints read Authorization: Bearer alone, and a key sent there as X-Api-Key or ?apikey= reads as no credential. They take a key or an OAuth access token from an app acting for a person (OAuth tokens), and each one lists the scope it needs (Scopes).
Lookup takes a key optionally
GET /{ip} and GET /myip answer without one, on Unlimited, the free plan, returning ip, is_vpn, is_tor and tor, is_relay and relay, is_bogon, location and asn. A key on a paid plan widens that answer to every field, every detail object included, such as vpn with its provider. A key on the free plan answers in full for its account's first 100 lookups each UTC day and as Unlimited after them, with trial_expired saying which. Past its quota, unless its account turned overage on, or past the overage cap it set, a paid key answers as Unlimited too, with cap_reached: true. A field your tier doesn't include is absent rather than false. Test for presence, not truthiness, or an unlicensed field reads as a negative result.
Unlimited has no daily or monthly cap, with a key or without one, and POST /batch needs a paid plan. See Rate Limits.
A key you send needs the ip.lookup scope, which you set on the key in the console. Without it, GET /{ip}, GET /myip and POST /batch answer 403 and count nothing.
Database downloads require one
Every /api/v1/database/* endpoint needs a key carrying the db.download scope, and that key's organization has to hold a license for the dataset being asked for. A key without the scope answers 401. A valid key whose organization holds no license for that dataset, or whose term has ended, answers 403.
OAuth tokens
A program that works for a person gets a token from our authorization server instead of asking them to paste a key. Two flows are supported:
- Authorization code with PKCE, for anything that can open a browser and receive a redirect: send the person to authorize with an S256
code_challenge, then exchange the code.plainis refused. Any client can use it without asking us first: make itsclient_idan https URL that serves its metadata (a Client ID Metadata Document), or register it. - Device authorization, for a command line: start one, show the person the
user_codeandverification_uri, and poll for the token while they approve it in the console. Only clients we registered, such as our CLI, can use it.
Either way the person signs in and approves the scopes the client asked for, picking one of their organization's API keys when it asks to use one. Your client is granted apikeys.use at most: our MCP server looks up with the key the person picked, and your client never sees it. Our CLI and browser extension ask for apikeys.reveal, and their token response carries the key as mslm:apikey. Send the access token itself as Authorization: Bearer $TOKEN.
The access token expires after expires_in seconds. Refresh it with the refresh_token grant, which consumes the refresh token you present and returns a new one, so store the new one before you use it. Revoking the refresh token ends the whole authorization, access tokens included; revoking an access token ends only that token. The endpoints, grant types and scopes are in the discovery document at https://api.vpndetection.io/.well-known/oauth-authorization-server.
Scopes
| Scope | Lets a credential | Used by |
|---|---|---|
ip.lookup | Look up addresses | Lookup, My IP, Batch |
db.download | List, inspect and download the databases your organization is licensed for, and the Open ones | Database |
account.read | Read your name, email and organization | Identity |
org.read | Read your organization and its members | Organization, Members |
apikeys.read | List your organization's API keys, without their secrets | List |
apikeys.manage | Create, rotate and revoke API keys | Create, Rotate, Revoke |
apikeys.reveal | Read back the secret of an API key you select | Reveal, Rotate, and the key our CLI or extension picks when it signs in |
apikeys.use | Make requests with an API key you select, without seeing the key itself | MCP server |
billing.read | Read your plan, usage and invoices | None of this API's endpoints |
ip.lookup and db.download are permissions an API key carries. The other seven are OAuth scopes: a person grants them when they approve a client, and they're narrowed on every request to what that person's role in the organization still allows, so a member who loses a role loses it on their live tokens too. Identity returns what a credential may do right now.
Error bodies
Lookups and the entitlement endpoint return a message:
{
"error": "not a valid IP address"
}The database, account and key endpoints return a result code:
{
"rc": "UNAUTHORIZED"
}The OAuth endpoints return RFC 6749 errors. A missing or invalid key is 401 on any endpoint that takes one. The account, organization and key endpoints answer 401 with NO_CREDENTIAL or INVALID_CREDENTIAL, and 403 with FORBIDDEN when the credential lacks the scope, without naming which.