---
name: botid
description: "Protect specific routes and server actions from bots in code with Vercel BotID (`botid` npm package). Use when installing BotID, calling `initBotId()` or `checkBotId()`, mounting `<BotIdClient />`, gating signup, login, checkout or AI inference endpoints, allowing verified bots such as ChatGPT agents through, enabling Deep Analysis, or debugging a route that always reports a bot. For site-wide bot rules (Bot Protection, AI Bots, custom rules on bot name or category), use the `vercel-firewall` skill."
summary: "Vercel BotID in code: initBotId() protect list, checkBotId() in the handler, verified bots, Deep Analysis, and local testing."
metadata:
  priority: 6
  docs:
    - 'https://vercel.com/docs/botid'
    - 'https://vercel.com/docs/botid/get-started'
  importPatterns:
    - 'botid'
    - 'botid/*'
  bashPatterns:
    - '\bnpm\s+(install|i|add)\s+[^\n]*(?<![\w@/-])botid(?![\w/-])'
    - '\bpnpm\s+(install|i|add)\s+[^\n]*(?<![\w@/-])botid(?![\w/-])'
    - '\bbun\s+(install|i|add)\s+[^\n]*(?<![\w@/-])botid(?![\w/-])'
    - '\byarn\s+add\s+[^\n]*(?<![\w@/-])botid(?![\w/-])'
  promptSignals:
    phrases:
      - 'botid'
      - 'bot id'
      - 'checkbotid'
      - 'initbotid'
      - 'botidclient'
      - 'invisible captcha'
    allOf:
      - [ 'deep analysis', bot ]
      - [ captcha, login ]
      - [ captcha, signup ]
      - [ captcha, form ]
      - [ bot, signup ]
      - [ bot, checkout ]
      - [ bot, login ]
      - [ bot, 'server action' ]
      - [ bot, endpoint ]
      - [ bots, endpoint ]
      - [ captcha, vercel ]
    anyOf:
      - 'bot'
      - 'bots'
      - 'captcha'
    noneOf:
      - 'slack bot'
      - 'discord bot'
      - 'telegram bot'
    minScore: 6
retrieval:
  aliases:
    - botid
    - vercel botid
    - invisible captcha
    - bot detection sdk
  intents:
    - protect an api route from bots
    - stop bots on signup or checkout
    - protect ai endpoint from bots
    - allow verified bots through botid
    - enable deep analysis
  entities:
    - BotID
    - checkBotId
    - initBotId
    - BotIdClient
    - Deep Analysis
    - Kasada
title: botid
canonical_url: https://skilld.dev/gh/vercel/vercel-plugin/botid
last_updated: 2026-11-18T19:13:53.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [.vercel.approvers](https://skilld.dev/api/skills-raw/vercel/vercel-plugin/botid/.vercel.approvers).
>
> If the user asked to install this Skill, run `npx skilld install vercel/vercel-plugin/botid`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/botid`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/vercel/vercel-plugin/botid) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/botid`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/botid --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/botid --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.


# Vercel BotID

You are an expert in Vercel BotID — invisible, per-route bot protection added in code.

## What It Is

- **Client**: a script attaches challenge headers to the requests you list in `protect`
- **Server**: `checkBotId()` sends those headers to Vercel and returns a verdict for the current request
- **No CAPTCHA**, no score header to read in proxy or middleware
- **Vercel only**: needs the request context and an OIDC token, so it fails self-hosted or under `next start`
- **Levels**: Basic (free, all plans) and Deep Analysis (Kasada, Pro $1 per 1,000 `checkBotId()` calls, Enterprise custom). Only `checkBotId()` calls are billed

## Setup

```bash
npm i botid
```

No config wrapper or rewrites needed: Vercel routes BotID requests automatically. Remove any old `withBotId`, `botid/nuxt` or BotID `vercel.json` rewrites.

### Client: declare protected routes

```ts
// instrumentation-client.ts (Next.js 15.3+)
import { initBotId } from 'botid/client/core';

initBotId({
  protect: [
    { path: '/api/signup', method: 'POST' },
    { path: '/api/user/*', method: 'POST' },
    { path: '/checkout', method: 'POST' }, // server action invoked from /checkout
  ],
});
```

- `*` matches any characters, including `/` and nothing; `method: '*'` matches any method
- Next.js < 15.3: `<BotIdClient protect={routes} />` from `botid/client` in the root layout `<head>`
- Nuxt: `plugins/botid.client.ts` with `enforce: 'pre'`. SvelteKit: `init()` in `src/hooks.client.ts`
- Requests must use `fetch` or XHR. Traditional `<form action method>` posts aren't supported; use `onSubmit` + `fetch` or a server action

### Server: check before the expensive work

```ts
import { checkBotId } from 'botid/server';

export async function POST(request: Request) {
  const { isBot } = await checkBotId();
  if (isBot) return Response.json({ error: 'Access denied' }, { status: 403 });
  // inference, writes, payments
}
```

Same call at the top of a server action. Result fields: `isBot`, `isHuman`, `isVerifiedBot`, `verifiedBotName`, `verifiedBotCategory`, `bypassed`. Pages Router in development: pass `advancedOptions: { headers: req.headers }`.

## Verified Bots

Allow specific agents (botid 1.5.0+) from the [verified bots directory](https://vercel.com/docs/bot-management#verified-bots-directory):

```ts
const { isBot, isVerifiedBot, verifiedBotName } = await checkBotId();
if (isBot && !(isVerifiedBot && verifiedBotName === 'chatgpt-operator')) {
  return Response.json({ error: 'Access denied' }, { status: 403 });
}
```

For a trusted service not in the directory, use a separate authenticated route or a WAF bypass rule scoped to its IPs. Bypassed traffic returns `bypassed: true`.

## Advanced Options

- **Deep Analysis**: dashboard Firewall → Rules → **Vercel BotID Deep Analysis**, or `vercel firewall rules update bot-id --action deep-analysis` (staged; `basic` reverts). Billed, so confirm with the user and let them publish
- **Per-route level**: `advancedOptions.checkLevel: 'deepAnalysis' | 'basic'` (1.4.5+) on **both** the `protect` entry and `checkBotId()`; a mismatch fails verification
- **Separate frontend host**: `checkBotId({ advancedOptions: { extraAllowedHosts: ['app.example.com'] } })`
- **Check once per visit**: [verify on page load](https://vercel.com/docs/botid/verify-on-page-load) and issue a signed cookie only when `isHuman && !bypassed`. It's a bearer credential; keep auth, rate limits and CSRF protection

## Testing

- **Local** (`NODE_ENV=development`): returns human. Force a verdict with `checkBotId({ developmentOptions: { bypass: 'BAD-BOT' } })` (or `'HUMAN'`, `'GOOD-BOT'`)
- **Deployed**: test from the app UI or a `fetch` on a page that loaded the script. `curl`, Postman and the address bar are reported as bots, as expected
- **Monitor**: Firewall traffic view, filtered to BotID; Observability Plus adds metrics

## Common Pitfalls

- **Always a bot**: route missing from `protect`, `path`/`method` mismatch, or a non-browser caller. The logged misconfiguration warning names the `{ path, method }` to add
- **Always human**: `checkBotId()` not called in the handler, or its result ignored
- **`VERCEL_OIDC_TOKEN is not set`**: running outside Vercel

## When to Use

- Signup, login, checkout, form posts and server actions called by your own frontend
- AI inference and other expensive endpoints

## When NOT to Use

- Site-wide page and crawler traffic → Bot Protection or AI Bots managed rules (`vercel-firewall` skill)
- Public APIs called by servers, webhooks or CLIs → API keys, rate limits or WAF rules
- Targeting a bot by name or category → custom rules (`vercel-firewall` skill)

## References

- 📖 docs: https://vercel.com/docs/botid
- 📖 get started: https://vercel.com/docs/botid/get-started
- 📖 advanced configuration: https://vercel.com/docs/botid/advanced-configuration
- 📖 verified bots: https://vercel.com/docs/botid/verified-bots
- 📖 form submissions: https://vercel.com/docs/botid/form-submissions
- 📖 verify on page load: https://vercel.com/docs/botid/verify-on-page-load
