Implementation10 min readâ€ĸ

How to Set Up robots.txt for AI Crawlers Like GPTBot and ClaudeBot

A marketing team adds "User-agent: *" and "Disallow: /" to keep its docs out of model training, and a day later the brand stops appearing in ChatGPT search answers.

A marketing team adds "User-agent: *" and "Disallow: /" to keep its docs out of model training, and a day later the brand stops appearing in ChatGPT search answers. You avoid this by giving each AI crawler its own user-agent group and making three separate calls: training crawlers (GPTBot, ClaudeBot), search and answer crawlers (OAI-SearchBot, Claude-SearchBot), and user-triggered fetchers (ChatGPT-User, Claude-User). In Sanity, those rules can live as a schema in the Content Lake and render at /robots.txt through a GROQ query.

The stakes cut both ways. If you block the wrong token, you drop out of the AI answers your buyers already read. If you allow the wrong one, your content can end up in a training set nobody approved. robots.txt is also a voluntary signal, so even a correct file proves nothing until you check it against your server logs.

This guide treats robots.txt as a policy, not a config file. Legal, SEO, and content teams make one decision per crawler together. Those decisions get written as rules and checked in logs, and editors can change them without waiting for a release.

What types of AI crawlers visit your website?

Three types of AI crawlers visit most websites, and each one asks for a different permission. Training crawlers collect pages for future model training. Search and answer crawlers index pages so an AI product can cite them in answers. User-triggered fetchers retrieve a specific page because a person asked an assistant to read it right now. Most bad AI crawler policies come from treating these three as one bot.

OpenAI and Anthropic both split their bots along these lines. OpenAI runs GPTBot for training, OAI-SearchBot for inclusion in ChatGPT search, and ChatGPT-User for actions a user starts. It also runs OAI-AdsBot, which only visits ad landing pages and whose data OpenAI says isn't used for training. Anthropic runs ClaudeBot for training data, Claude-SearchBot for search indexing, and Claude-User for user-initiated fetches. Typical OpenAI user agent tokens look like GPTBot/1.4, OAI-SearchBot/1.4, and ChatGPT-User/1.0.

Google and Perplexity follow different patterns. Google-Extended is a product token, not a separate crawler. It controls whether content Google already crawls is used for Gemini training and grounding, and it has no effect on Google Search indexing. Perplexity runs PerplexityBot for indexing and Perplexity-User for user-triggered fetches.

The settings are independent of each other. OpenAI's documentation states that "each setting is independent of the others," so a Disallow for GPTBot does nothing to OAI-SearchBot, and an Allow for OAI-SearchBot doesn't grant training access. Anthropic draws the same line. Restricting ClaudeBot signals that a site's future materials should be excluded from training, while disabling Claude-User may reduce the site's visibility for user-directed web search.

In practice, that means one user-agent group per crawler and one documented decision per group. Before anyone edits the file, legal, SEO, and content teams should agree on a short register: who runs each crawler, what it is for, and what the organization has decided about it.

Illustration for How to Set Up robots.txt for AI Crawlers Like GPTBot and ClaudeBot
Illustration for How to Set Up robots.txt for AI Crawlers Like GPTBot and ClaudeBot

An AI crawler is a purpose, not a company

OpenAI says that if both GPTBot and OAI-SearchBot are allowed, it may use one crawl for both purposes. To show up in ChatGPT search while keeping content out of training, allow OAI-SearchBot and disallow GPTBot by name. Allowing search access tells OpenAI nothing about your training preference.

How do you write robots.txt rules for GPTBot, ClaudeBot, and other AI crawlers?

To write robots.txt rules for AI crawlers, give each user agent its own group and list Allow and Disallow lines path by path. A crawler follows the most specific group that names it, so a named GPTBot group replaces whatever the wildcard group says for that bot. The procedure below produces a file that allows AI search, blocks training, and handles user-triggered fetchers explicitly.

1. Inventory your paths. List the sections that matter: marketing pages, /docs/, /blog/, account areas such as /account/, and any internal or staging routes.

2. Add search and answer crawlers first. Write "User-agent: OAI-SearchBot" followed by "Allow: /" and "Disallow: /account/". Repeat the group for Claude-SearchBot and PerplexityBot if you want to be included there too.

3. Add training crawlers with your training decision. To opt out entirely, write "User-agent: GPTBot" and "Disallow: /", then do the same for ClaudeBot and the Google-Extended token. To allow training on public docs only, pair "Allow: /docs/" with "Disallow: /".

4. Add user-triggered fetchers on purpose. Write groups for ChatGPT-User and Claude-User even though vendors say robots.txt may not apply to them. The rule records your intent.

5. Set a crawl rate where it's supported. Anthropic supports the non-standard Crawl-delay directive, for example "User-agent: ClaudeBot" with "Crawl-delay: 1". Other crawlers may ignore it.

6. Put the wildcard group last. "User-agent: *" covers every crawler you haven't named, including new AI bots.

7. Publish on every host. Anthropic requires robots.txt on each subdomain, so docs.example.com needs its own file.

Path matching is the most common trap. Under the robots exclusion standard, the longest matching rule wins, not the first line, so "Allow: /docs/" beats "Disallow: /" for a docs URL. Test real URLs against each group before you ship.

Should you block AI training crawlers but allow AI search crawlers?

For most organizations, yes. Allow AI search crawlers, and make a separate, deliberate call on training crawlers. That keeps you visible without handing over a training decision by accident. OpenAI states that you can allow OAI-SearchBot so your site appears in search results and still disallow GPTBot to signal that your content shouldn't be used for training.

The search side has concrete consequences. OpenAI says sites that block OAI-SearchBot don't appear in ChatGPT search answers, though they can still surface as navigational links. Anthropic says disabling Claude-User may reduce a site's visibility for user-directed web search. If buyers ask an assistant which vendors to shortlist, a blocked search crawler means a missing answer.

The training side is a policy question, not a technical one. Publishers with licensing concerns, regulated firms, and companies with proprietary documentation often disallow GPTBot, ClaudeBot, and Google-Extended. Developer-tool companies sometimes allow training on public docs because they want models to answer questions about their APIs correctly. Either choice can be right. The mistake is leaving the decision to the wildcard default.

Timing matters too. OpenAI says a robots.txt change takes about 24 hours to affect search, so reversing a policy isn't instant. If both GPTBot and OAI-SearchBot are allowed, OpenAI may use one crawl for both purposes. That's another reason to state the training decision explicitly instead of assuming search access implies nothing about training.

A new signal now sits next to robots.txt. Anthropic says that as of October 30, 2026, it has started honoring a machine-readable "no AI training" preference based on draft work in the IETF aipref working group, and it is rolling this out over time. Explicit ClaudeBot rules in robots.txt take precedence for a given path. If ClaudeBot isn't named, Anthropic falls back to the general setting. The draft can still change, so keep naming ClaudeBot directly in robots.txt and treat the general preference signal as a backstop.

What can't robots.txt do to control AI crawlers?

robots.txt can't enforce anything or authenticate anyone. It is a voluntary signal that well-behaved crawlers read and choose to follow, so even a perfect file stops nothing on its own. Treating robots.txt as access control is the costliest mistake in AI crawler policy, because teams end up exposing sensitive paths they think are protected.

Three gaps follow from that. First, user-triggered fetchers sit partly outside the protocol. OpenAI says ChatGPT-User is not used for crawling the web in an automatic fashion and that, because these actions are initiated by a user, robots.txt rules may not apply. ChatGPT search opt-outs are controlled through OAI-SearchBot, not ChatGPT-User. Third-party reports claim Perplexity-User may also ignore robots.txt. That claim hasn't been confirmed against Perplexity's own documentation, so check it before relying on it either way.

Second, user agent strings can be spoofed. Anyone can send a request claiming to be GPTBot. A Disallow rule does nothing against a scraper that lies about who it is, and an Allow rule can be abused by one that pretends to be a crawler you trust.

Third, robots.txt is public. A Disallow line for /internal-pricing/ tells every reader where to look. Paths that really need protection belong behind authentication, not in a crawler directive.

Real enforcement lives elsewhere: authentication for private content, and WAF or CDN bot rules for traffic you want to refuse. Be careful with blunt IP blocks, though. Anthropic warns that blocking its IPs may not work correctly or reliably guarantee an opt-out, because it stops the crawler from reading robots.txt at all. Anthropic also says its bots don't try to get past CAPTCHAs. The pattern that holds up uses robots.txt to state policy, server logs to verify behavior, and enforcement tools for the few paths where policy alone isn't enough.

â„šī¸

robots.txt is a request, not a lock

OpenAI says robots.txt rules "may not apply" to ChatGPT-User because those fetches are started by a user. Anthropic warns that IP blocking can stop ClaudeBot from reading robots.txt, so the block may fail to guarantee an opt-out. Put private paths behind authentication, use robots.txt to state policy, and use server logs to confirm crawlers follow it.

How do you check AI crawler compliance with server logs?

To check AI crawler compliance, match the user agent strings in your server logs against each vendor's published IP ranges, then look for verified requests to paths you disallowed. Matching user agents alone isn't enough, because the string is trivial to spoof. The IP check is what turns a claim into evidence.

1. Pull the published ranges. OpenAI publishes JSON files at openai.com/gptbot.json, openai.com/searchbot.json, openai.com/chatgpt-user.json, and openai.com/adsbot.json. Refresh them on a schedule instead of hardcoding them.

2. Filter logs by token. Search access logs for GPTBot, OAI-SearchBot, ChatGPT-User, ClaudeBot, Claude-SearchBot, Claude-User, and PerplexityBot. When OpenAI fetches robots.txt itself, the user agent may include a robots.txt marker, which confirms the bot read your file.

3. Verify the source. For each hit, check whether the client IP falls in the vendor's published range. Requests that claim a vendor token from outside the range are impersonators. Send them to your security team, and don't count them against the vendor. If you can't verify a vendor's ranges, mark its traffic as unverified.

4. Compare against policy. Among verified requests, flag any that hit a path disallowed for that user agent.

5. Allow time for propagation. OpenAI says a robots.txt change takes roughly 24 hours to affect search, so start measuring a day after the change, not the minute it ships.

6. Separate user-triggered traffic. Given the vendors' stated carve-outs, ChatGPT-User and Claude-User requests to disallowed paths aren't necessarily violations. Report them in their own bucket.

Run this as a recurring report, not a one-off audit, showing verified requests by crawler, path, and allowed or disallowed status. When a new crawler shows up in the report, add a named group for it to robots.txt instead of letting the wildcard decide. When a verified crawler keeps hitting disallowed paths, that's the case for escalating to CDN or WAF enforcement for those paths.

How do you generate robots.txt from structured content in Sanity?

In Sanity, you generate robots.txt by modeling crawler rules as a schema in the Content Lake and rendering them at the /robots.txt route with a GROQ query. Each rule is an entry with a user agent, a path, and an allow or disallow value, plus optional fields such as crawl delay and a note on why the decision was made. Editors change the rules in the Studio, and the next refreshed /robots.txt reflects the published values.

This is where Sanity, the AI Content Operating System, fits. As the intelligent backend for companies building AI content operations at scale, it treats a crawler policy like any other structured content, with a schema instead of a text file edited by hand. That maps to the pillar Model your business. The schema can require every rule to name a known user agent and every path to start with a slash. It can also require GPTBot and ClaudeBot to carry an explicit decision.

The frontend's /robots.txt route runs a GROQ query that fetches the published rules, groups them by user agent, and prints the groups with the wildcard last. Because the query reads published content only, draft edits never reach crawlers.

The pillar Automate everything covers the cache. Most sites cache /robots.txt at the CDN, so a published edit has to invalidate the cached copy. Functions are small, single-purpose pieces of code that run on Sanity's cloud infrastructure and react to content changes. A document function on the update event, or a Sync tag invalidate function reacting to Live Content sync tags, can refresh the cached file. Publishing a document is what fires an update on the published document, so use create and update instead of the deprecated publish event. The function is declared in a Blueprint, sanity.blueprint.ts, kept in the repository next to the application code.

The result: an SEO lead can allow Claude-SearchBot on /docs/ without filing a ticket or waiting for a release.

✨

Policy changes without a deploy

Blueprints and Functions are generally available. A Function declared in sanity.blueprint.ts can react to an update on the crawler policy document and refresh the cached robots.txt. The rule an editor publishes in the Studio becomes the rule crawlers read, with no code change in between.

How should teams version and govern AI crawler rules?

Teams should version AI crawler rules like any policy with legal consequences: stage every change, have the right owner review it, and keep it traceable afterward. Content can't be pulled back out of a training set once a crawler has taken it, so if someone reverses a training opt-out by mistake, the review step matters more than the edit.

Static files in git already give you history and pull request review, which is why many engineering teams keep robots.txt in the repository. The tradeoff is ownership. The people who decide AI training policy usually sit in legal, content, or SEO, and they rarely open pull requests. When the people making the decision can't touch the file, it drifts away from the policy.

Sanity closes that gap. The rules stay with the people who own them, and the process stays in code. Content Releases let a team stage a set of crawler rule changes and publish them together, for example allowing Claude-SearchBot and OAI-SearchBot on a new /guides/ section. Functions have an includeAllVersions setting that controls whether versions events from Content Releases and Scheduled Drafts trigger them, so a check can run while rules are still staged in a release.

Workflows, currently in beta and opt-in, model the editorial process as data. Workflows are defined in TypeScript and versioned and deployed like the rest of your code, so the approval process can't drift from what's written down. A rule like "any change to a training crawler rule needs legal review" becomes part of the workflow. The audit then becomes a GROQ query asking which crawler rules were published without legal review. Because Workflows is in beta, add it to your process, but don't depend on it for compliance.

Infrastructure follows the same principle. The Blueprint file is the source of truth for which Functions exist. If a Function isn't in the blueprint, it isn't deployed. The automation that regenerates robots.txt is reviewed and versioned in git, and the rules it renders are edited by the people accountable for them.

Ways to publish and govern robots.txt rules for AI crawlers

FeatureSanityStatic robots.txt in gitCDN or WAF bot managementHardcoded framework route
Who can change AI crawler rulesEditors change user agent, path, and allow or disallow fields in the Studio. The /robots.txt route renders the published values through a GROQ query.Anyone with repository access edits the file and merges a pull request. Changes ship with the next deploy, which suits engineering-owned policy.Security or platform teams edit bot rules in the CDN or WAF console. This sits apart from site content and usually outside editorial access.Developers edit rules in application code, such as a robots route in the framework. Every change needs a code review and a deploy.
Time from decision to live fileA Function on the update event, or a Sync tag invalidate function, refreshes the cached robots.txt after publish. No deploy needed.As fast as your deploy pipeline. A same-day change is realistic when engineers are available and slower when they aren't.Rule changes take effect at the edge independently of site deploys once someone with console access saves them.Tied to the application's release cycle. It can be quick with continuous deployment, but an engineer always has to make the change.
Enforcement against noncompliant botsStates policy only, like any robots.txt. Pair it with authentication and CDN or WAF rules for paths that must be refused.States policy only. Well-behaved crawlers follow it, while spoofed or user-triggered fetchers may not.Real enforcement: can block, challenge, or rate-limit by user agent or IP. Anthropic warns that IP blocks can stop ClaudeBot from reading robots.txt.States policy only. It can be combined with custom middleware checks, but the team writes and maintains that code.
Versioning, staging, and auditContent Releases stage rule changes together. Workflows (beta) turn audits into a GROQ query, such as rules published without legal review.Full git history and pull request review out of the box. A strong audit trail for anyone comfortable reading diffs.Depends on the provider. Many keep change logs for rule edits, but those live in a separate tool from site content and policy notes.Git history covers the code that generates the file. Policy intent lives in commit messages and code comments.
Validation of per-crawler decisionsSchema validation can require a known user agent token and a leading slash on paths, plus an explicit decision for GPTBot and ClaudeBot.Relies on reviewers or a lint step in CI to catch typos in user agent tokens or path syntax before merge.Bot rules follow the provider's own configuration model. robots.txt still has to be written and published from another source.Typed config can catch some errors at build time. How much it catches depends on the checks the team writes.
Rules across multiple subdomainsA schema can hold rules per host, so docs and marketing subdomains each render their own file, as Anthropic requires per subdomain.Each subdomain needs its own file in its own repository or build output, and the files can drift apart across properties.Rules can apply across zones or hostnames from one console, but they don't generate or publish robots.txt files.Each app serves its own route. Sharing rules needs a common package or duplicated code across applications.