cd /news/ai-agents/how-to-let-an-ai-agent-publish-witho… · home › topics › ai-agents › article
[ARTICLE · art-181746] src=hatamoto.dev ↗ pub= topic=ai-agents verified=true sentiment=· neutral

How to let an AI agent publish without losing control

Hatamoto published a guide showing that an AI agent can draft and publish content on a Hatamoto site without bypassing human review, provided the key is issued to an Editor account, limited to read and write entity scopes, and paired with Review mode so publishes and edits to live pages wait for a person. The guide uses a fictional jazz club, the Blue Room, with an `event` content type and `notice` field, and recommends separate read-only and write keys, a 90-day expiry, dry-run previews, and version-checked writes so stale edits are refused. Hatamoto's MCP endpoint at `/mcp` and REST API at `/api/v1` enforce the key's scopes, with idle sessions ending after 30 minutes and a default limit of 1000 requests per hour.

recommendation

Give publishing agents an Editor-scoped key, not an owner key, enable Review, and require dry runs plus version-checked writes so stale edits are rejected.

more in playbook: Securing agents and AI tools
by read14 min views1 publishedDec 4, 2026
How to let an AI agent publish without losing control
Image: Hatamoto (auto-discovered)

How to give an AI assistant a key that can draft and publish on a Hatamoto site while its publishes and live edits wait for a person, with a made-up jazz club's event listings as the example.

An AI agent can publish on a Hatamoto site without taking the live site out of your hands, as long as you set three things up before you hand over a key. Make the key for an Editor account instead of your own, give it only the read and write entity scopes, and switch Review on so that its publishes and edits to live pages wait for a person (taking a page offline and creating a public person entry are the two exceptions, covered below). Then have the agent preview every change with a dry run and write with the version it read, so a stale edit is refused instead of applied.

The example through this guide is a made-up venue, the Blue Room, a small jazz club whose site has an event content type with a notice field. The owner wants an assistant to draft listings from the booking sheet and to mark a show as cancelled when the band pulls out, without being able to change the live site on its own.

What an agent can reach on a Hatamoto site #

Hatamoto has two doors for programs. The first is an MCP endpoint at /mcp. MCP, the Model Context Protocol, is a standard way for AI tools to call functions on a server. The second is the REST API under /api/v1, which a script calls with an X-API-Key header. Both open only as far as the key presented on each request.

Over MCP an agent gets a list of tools. With the right scopes it can list and search entities, read a content type's schema, create drafts, update and publish entries, restore earlier versions, upload media, edit menus and redirects, and read crawler analytics. The MCP server reference lists every tool with its inputs and the scope it needs. An idle session ends after 30 minutes, and a key gets 1000 requests per hour by default.

The server's own instructions tell the agent to read schemas_get first, create drafts, review them, then publish. A well-behaved assistant follows that. The controls below exist for the cases where it does not.

A key acts as the account it was made for, and Hatamoto checks that account's role afresh on each request. A key made for an Editor can do at most what an Editor can, and it stops working if the account is removed or loses its owner or editor role. For the Blue Room, what the agent can do comes down to the booker's account and the scopes the key leaves out.

Two keys for two jobs #

The club has two jobs for its assistant: answering questions about the site, and writing to it. These deserve separate keys, because where a key is made decides whose authority it carries, and that decides whether Review can hold it.

The read-only key, made in the admin

For reading, make a key in the admin. Open Settings > Integrations > API keys at <admin>/settings/api-keys and choose New API key; only owners can create keys. Tick Read entities, and Read reports if the agent should see crawler figures. The docs suggest a 90-day expiry, so a key you stop thinking about still runs out. The key begins with nxk_ and is shown once, in a banner, after Create key.

The agent gets the key in its MCP settings as a server entry: the site address followed by /mcp, and an Authorization: Bearer header carrying the key. The guide to connecting an AI agent has the settings block and a curl test.

The write key, made on the server

A key made in the admin belongs to the owner who made it. That is fine for reading. For writing it is the wrong key, because an owner's key publishes directly even when Review is on. The docs say not to give an admin-made key Write entities, and to revoke it if you already have.

Make the write key on the server instead, acting as an Editor account. The command needs a shell with the service's settings loaded so that DATABASE_URL is set.

  1. Invite the booker as an Editor under Settings > Users if the account does not exist yet.
  2. Switch Review on (next section) before the key exists, so there is never a window where it writes unchecked.
  3. On the server, run the create command with --as naming that account and only the two entity scopes.
  4. Store the key file where the agent's runtime can read it and nowhere else.
hatamoto apikey create --name "blue room agent" --scopes read:entities,write:entities --as booker@example.com --out ./agent.key

--out writes the key to a new file with mode 0600; without it the key is printed once and never stored. The name is what the logs show, so name the key for its job.

Key Made where Acts as With Review on
Research key Admin, Settings > Integrations > API keys The owner who made it Reads only; nothing to hold
Drafting key Server, hatamoto apikey create --as The Editor named in --as Publishes and live edits wait for approval
Owner's key with Write entities Admin The owner Publishes directly; avoid

Scopes, and what write:entities leaves out #

A scope is a limit on what a key may do. Each MCP tool is tied to one scope. A key holding only read: scopes has no way to call a write tool, while a write:X scope covers read:X as well. A call without the needed scope fails with forbidden: the API key lacks the <scope> scope, and the refused call still lands in the audit log.

The part to plan for is what write:entities does not cover. It lets a key create, update, restore, publish and unpublish entities. It does not grant media, menus, redirects or terms; each has its own scope, and write:menus, write:redirects and write:terms are reachable only through MCP. The SEO scopes and write:terms work only while the key's creator is an owner, so a key created for an Editor does not get them.

Scope Admin label What the club's agent would use it for
read:entities Read entities Listing events, reading schemas, searching, reading version history
write:entities Write entities Drafting listings, changing a notice, publishing, restoring
write:media Write media Up a poster; withheld for now
write:menus Write menus Replacing the header menu; MCP only, withheld
read:reports Read reports Crawler and traffic figures; research key only

A key's scopes cannot be changed in the admin once it exists. The plain path is a new key with the right boxes ticked and a revoke on the old one. The users and API keys guide covers the roles behind keys and what each role may do.

For the Blue Room, the drafting key gets read:entities,write:entities and nothing else. When the club later wants the agent to attach posters, it makes a new key that adds write:media. Menus stay with a person: menus_update replaces every item when given a list, and menus have no version history to fall back on.

Holding the agent's changes for review #

Review is the switch that turns a write key from a publisher into a proposer. It is off by default, and with it off a key holding Write entities changes and publishes live content without anyone checking first. Turn it on at <admin>/settings/review before the drafting key exists.

Review follows the role of the key's creator. Keys made for an Editor, Author or Contributor wait. Keys made by an Owner or Reviewer publish directly even with Review on, which is why the drafting key is made for the booker's account. Three kinds of change are held: an edit to published content, publishing a draft, and scheduling. Over REST a held change answers 202; over MCP the tool returns status: pending_review with a changeset_id. Nothing is stored until a reviewer approves it in <admin>/review, and a key never approves a change, not even its own.

Review does not hold everything, and two exceptions matter for the club. Taking a page offline is never held; a key holding Write entities does that immediately. And a new person entry created as public goes live at once. The first is a judgment call. If the band cancels an hour before doors, you may want the agent to pull the listing immediately. If every change should pass a person, tell the agent to set the notice and leave the page up. No scope allows updates and forbids unpublishing, so this is an instruction to the agent, with the audit log as the check.

New pages and posts made by a key are always drafts. For the club, the agent drafts a listing with entities_create, the booker reads it in the admin, and either an owner or reviewer publishes it or the agent calls entities_publish and the change waits in the queue. The guide to editing your site with AI safely describes the whole chain from key to approval.

Preview, apply and undo #

Review protects the live site from the agent. Versions protect the agent from itself and from whoever else is editing. Every entity carries a version that counts changes to its attributes; over REST it arrives as the ETag header on a read, over MCP as entity.version from entities_get. The safe sequence is read, preview, then apply with that version.

Preview with a dry run

A dry run runs the change through validation and sanitizing and stores nothing. Over MCP, set dry_run: true on entities_update; over REST, add ?dry_run=1. The answer lists each change as a path, before and after, the current version, an errors list, and pending_review: true when the real call would be held. One gap: a slug or locale clash is caught only by the real write, so a clean dry run can still end in a 409. Dry runs count against the rate limit.

Apply with the version you read

Send the version back with the real call: version in the MCP input, If-Match over REST. If anyone changed the entry in between, the write is refused, with 412 over REST and conflict: stale version over MCP, and nothing is stored. Without a version the call is applied regardless, which is how an agent overwrites the booker's edit from five minutes ago.

Two details change what the agent should send. attributes replaces the stored object as a whole by default; to change one field, set merge: true over MCP or send a PATCH with Content-Type: application/merge-patch+json over REST, and null removes a key. And the version tracks content only. Renaming an entry or changing its slug, locale, parent, byline or status leaves the number where it was, so two of those changes sent with the same version can both go through.

Undo by restoring

Undo means restoring an earlier version, and a restore is stored as a new version, so history is kept. Over MCP the agent uses entities_versions, entities_version_get and entities_restore; over REST it is POST /api/v1/entities/{id}/restore/{version}. Restoring published content is held for review like any other live edit. A person can do the same from the item's Versions tab in the admin, where you can view, compare and restore, as the content editing guide describes.

Cancelling a live show, step by step #

The Friday headliner has pulled out and the listing is published. Review is on and the agent holds the drafting key. The exchange below is MCP tool input, following the docs' own example; <id> is the event's id.

  1. Read the event with entities_get . The answer carriesversion: 7 .
{"id": "<id>"}
  1. Preview the notice with a merge and a dry run.
{"id": "<id>", "attributes": {"notice": "Cancelled"}, "merge": true, "version": 7, "dry_run": true}

The answer shows one change and warns that the real call will be held:

{"dry_run": true, "version": 7, "changes": [{"path": "notice", "before": null, "after": "Cancelled"}], "errors": [], "pending_review": true}
  1. Send the same call without dry_run . It returnsstatus: pending_review . The event stays at version 7 and the public page is unchanged.
  2. The owner opens <admin>/review and approves. The event moves to version 8 and the notice is live.
  3. If the band un-cancels, the agent restores version 7 with entities_restore , passingexpected_version: 8 . That restore is held again until someone approves it.
{"id": "<id>", "version": 7, "expected_version": 8}

Over REST the same change is a PATCH with X-API-Key, a merge-patch content type and If-Match: "7", previewed with ?dry_run=1; the held real write answers 202. Either way the live page did not change until a person said so.

Seeing what the agent did #

Owners read the Audit log at <admin>/audit. A REST change appears as Source API under the key's name. An MCP write adds two rows: the tool call, as Source Agent, and the resulting change, as Source API. Refused tool calls are logged too, so an agent that keeps trying media_upload without the scope leaves a trail.

Version history carries the second record. A direct change is tagged [mcp:<name>] when it came through MCP or [api-key:<name>] over REST, followed by the optional change_summary the agent sent. A change approved in review and a REST restore are untagged, and publishing or unpublishing writes no version at all, so look in the audit log for who published what.

While a change waits, <admin>/review names the account that asked for it, and the audit log keeps the submission under the key's name. That is the practical reason for one key per agent: with two agents sharing a key, the log cannot tell you which one proposed the cancellation.

If you have not worked with versions in the admin before, the guide on how authoring works in Hatamoto walks through drafts, publishing and versions from the editor's side.

Rules for agent keys #

The docs set out the mechanisms; these rules apply them to a site like the club's.

One key per agent, named for the job, because the name is what the logs show. The smallest scope that does the job, and a new key when the job grows, since the admin cannot widen a key after the fact. An expiry on every admin-made key; the form offers never, 30 days, 90 days or a year. Rotate with New secret on the key's row, which stops the old secret at once, and Revoke when the agent is retired. For a contractor's agent, set Access ends on for the account the key acts as: the keys that person created stop working when that day ends, and an hourly job revokes them and records user.access_ended in the audit log.

Checklist before the first write

  1. Review is on at <admin>/settings/review .
  2. The agent's write key was made on the server with --as naming an Editor account, never in the admin.
  3. Its scopes are read:entities,write:entities and nothing more.
  4. The agent's instructions tell it to read with entities_get , preview withdry_run , and sendversion on every update.
  5. Any owner-made key with Write entities has been revoked.
  6. You have decided whether the agent may unpublish, and said so in its instructions.

Frequently asked questions about agent publishing #

Can the agent approve its own change?

No. A key never approves a change, including one it submitted; approval happens in <admin>/review by a person. If a change went live that you expected to be held, check that Review is on, that the key was not made by an Owner or Reviewer, and that it was not a new person entry created as public.

Can I add a scope to an existing key?

Not in the admin. The owner-only REST routes for keys can change scopes, name, description, rate limit and active state with PATCH /api/v1/api-keys/{id}. For most sites the cleaner move is a new key and a revoke on the old one, so the audit trail shows a clean cut.

What do 401 and forbidden mean from the agent?

401 means the key is missing, mistyped, revoked or expired, or its creator no longer has a role that may use keys. A lost key cannot be shown again; New secret on its row issues a fresh one. The forbidden error means the call needs a scope the key was not given, and that attempt is already in the audit log.

Does the rate limit get in the way of a careful agent?

A key gets 1000 requests per hour by default, and reads and dry runs count against it. The read, preview, apply pattern costs about three requests per change. The CLI's --rate-limit flag sets a different hourly figure per key.

── more in #ai-agents 4 stories · sorted by recency
── more on @hatamoto 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/how-to-let-an-ai-age…] indexed:0 read:14min 2026-12-04 · —