# Protecting a search box that posts its query

A docs site often has a search box that posts its query to an index or a billed backend. The docs pages should stay free to read, including for crawlers and answer engines. The posted query is the write.

Mark the form with `data-attackfee="search"` and map that route to the search class, which is 1x the unit cost. Check the pass on the server before you run the query. Leave every doc page as an unmarked GET.

This is the same setup on a marketing site or a dashboard, whenever search is a post that costs you to run. It is not for a client-side filter of a page that is already loaded.

Exact steps are in [How to protect a search field from bots](/learn/write-surfaces/how-to-protect-a-search-field). An illustration of a billed backend is in [A search box that calls a paid backend](/learn/write-surfaces/a-search-box-and-a-paid-backend).

## Where Attackfee fits

Keep `/docs` and the rest of the read half open. Price only the posted search. See [Why a posted search query is a write](/learn/write-surfaces/posted-search-is-a-write) and [Why reading should stay free](/learn/concepts/why-reads-should-stay-free).

- [Attackfee](/)
- [Learn](/learn)
- [Write surfaces](/learn/write-surfaces)
- [Protecting a search box that posts its query](/learn/write-surfaces/search-boxes-that-post)

## Related

- [Attackfee Learning Center](/learn)
- [Why a posted search query is a write](/learn/write-surfaces/posted-search-is-a-write)
- [How to protect a search field from bots](/learn/write-surfaces/how-to-protect-a-search-field)
- [A search box that calls a paid backend](/learn/write-surfaces/a-search-box-and-a-paid-backend)
- [Docs](/docs)

## Questions



### "Should I gate the docs pages too?"

"No. Keep the docs as free GET requests. Only the posted query is a write."

### "Which attribute do I put on the form?"

"data-attackfee=search, and map that route to the search class on the server."

### "What if search is a live GET to an API?"

"GET stays free. If that GET is costly, prefer caching, or change it to a posted search and mark that route."

### "Does the hosted demo include this?"

"No. Use the local demo, which includes a posted search, or follow the search-field how-to."
