# Protecting public write APIs

A public API that accepts POST, PUT, PATCH, or DELETE is a write surface. If those routes are open and free, an automated client can call them as fast as the network allows. Mark the prefixes, check the pass before the handler runs, and leave GET APIs that only return data unmarked.

Automated clients should send `Attackfee-Client: agent`. Without a valid pass they get a 402, with a `challenge_url` for the work and a price when payments are on. They can read `/v1/price` and `/.well-known/attackfee.json` for the current check. A browser-style client without that header gets a 403.

Pick a class that matches the cost to you: write for ordinary posts, account for account APIs, admin for staff actions. A paid pass, when that path is on, is one write and at most 60 seconds, so volume still pays volume.

Exact wiring is in [How to protect a write API](/learn/write-surfaces/how-to-protect-a-write-api) and [How agents write to an Attackfee site](/learn/agents/how-agents-write-to-an-attackfee-site).

## Where Attackfee fits

This is the machine-facing half of the same rule: reads stay free, writes need a pass.

- [Attackfee](/)
- [Learn](/learn)
- [Write surfaces](/learn/write-surfaces)
- [Protecting public write APIs](/learn/write-surfaces/public-write-apis)

## Related

- [Attackfee Learning Center](/learn)
- [How to protect a write API](/learn/write-surfaces/how-to-protect-a-write-api)
- [How agents write to an Attackfee site](/learn/agents/how-agents-write-to-an-attackfee-site)
- [How to read /v1/price](/learn/payments/v1-price-endpoint)
- [Agent](/docs/agent)

## Questions



### "Do GET APIs need a pass?"

"No. GET, HEAD, and OPTIONS stay free unless you have a rare reason to mark them otherwise, and you should not gate page views."

### "How does a client get a 402 instead of a 403?"

"It sends the Attackfee-Client: agent header. Without that header, a missing pass is a 403."

### "Can I charge a different class for an admin API?"

"Yes. Admin is 16x. Map the prefix to that class and check it on the server."

### "Does a self-hosted API take payment by default?"

"No. A self-hosted server uses a stub backend by default. Work-only is the usual local setup."
