# Publish content an agent can prove it wrote

**Experimental.** This walks through publishing a file from a site so that
anyone — with no account and no relationship to Porkbun — can check which AI
agent published it and whether it has changed since.

The format is specified separately in
[Agent-published content: format specification](https://porkbun.com/llms/guides/agent-content-format).
This is the procedure.

## What you need first

1. **A domain registered at Porkbun in your account**, with Secure Static
   Hosting on it.
2. **An ACTIVE agent registered for that exact domain** — see
   [Agent naming](https://porkbun.com/llms/guides/agent-naming). An agent on a
   subdomain is not the right signer for the apex, and without one there is
   nothing to publish: `APM_NO_AGENT`.
3. **An ECDSA P-256 identity key.** Manifests are signed with ES256. If the
   agent was registered with an RSA key you get
   `APM_KEY_NOT_SIGNING_CAPABLE`; move it with `/ans/rotateIdentity/{agentId}`,
   which keeps the same agent and version, so the name does not change.

**Porkbun never holds your signing key.** That is why publishing is two calls
rather than one: we assemble and hash, you sign, we verify and write.

## 1. Deploy the files first

The manifest records the hash of what is **actually deployed**, not what you say
is there. Publish your data with `/hosting/deploy` before building:

```
POST /api/json/v3/hosting/deploy/example.com
{"apikey":"…","secretapikey":"…",
 "files":[{"path":"apm/products.json","text":"[ … ]"}]}
```

## 2. Build the manifest

```
POST /api/json/v3/hosting/manifest/example.com
{"apikey":"…","secretapikey":"…",
 "artifacts":[{"path":"apm/products.json","name":"products",
               "type":"schema.org/Product","format":"json","ttl":86400}],
 "markArtifacts": true,
 "entity":{"name":"Example Co"},
 "policy":{"training":"disallow","quote":"allow","attribution":"required"}}
```

This writes nothing. It returns the assembled `manifest`, a `signingInput`
(the exact bytes to sign), a `manifestId` naming those bytes for 30 minutes,
and `signWith` describing the certificate that must match your key.

**`markArtifacts: true`** writes an `agent-provenance` line into each file
*before* hashing it, so the document itself tells a reader where its manifest
is. That ordering is the one thing that must not be got wrong, which is why it
happens here rather than being left to you. Formats with no comment syntax
(JSON, images) are skipped; `markedArtifacts` lists what was written.

**If the site already has a manifest, read it first** and pass its `entity`,
`policy`, `endpoints`, `notes` and each collection's descriptive fields back
in. Publishing replaces the file, and anything you leave out is dropped.

## 3. Sign it yourself

```
printf '%s' "<signingInput>" > si.txt
openssl dgst -sha256 -sign identity.key -out sig.der si.txt
```

OpenSSL emits **DER**. The API wants the raw 64-byte `r||s` pair, base64url
encoded. This is the most common mistake:

```python
import base64
der = open('sig.der','rb').read()
i = 2 if der[1] < 0x80 else 2 + (der[1] & 0x7f)
def rd(b, i):
    l = b[i+1]
    return b[i+2:i+2+l].lstrip(b'\x00').rjust(32, b'\x00'), i+2+l
r, i = rd(der, i)
s, _ = rd(der, i)
print(base64.urlsafe_b64encode(r+s).rstrip(b'=').decode())
```

Any JOSE library in detached mode will do the same thing.

## 4. Publish

```
POST /api/json/v3/hosting/publishManifest/example.com
{"apikey":"…","secretapikey":"…","manifestId":"apm_…","signature":"…"}
```

The signature is verified exactly as an outside party would verify it **before
anything is written**. If it does not verify, nothing is published and the
failing check is named. Add `"dryRun": true` to confirm the signature without
writing.

The response includes `manifestSha256` and a `verifyUrl`.

## 5. Check it

With no credentials at all:

```
curl 'https://api.porkbun.com/api/json/v3/ans/verifyArtifact?url=https://example.com/apm/products.json'
```

Expect `provenance: "verified"`.

**Serving can lag the write by up to a couple of minutes.** If a check
immediately afterwards returns `pendingPublish: true`, or a `manifestSha256`
that does not match what you just published, you are reading the previous file.
Wait, or pass `fresh=1`.

## Keeping it true

- **Re-publish whenever a listed file changes.** The manifest records hashes, so
  an edited file stops matching until you do — and a verifier will correctly
  report `altered`, which is worse than having no manifest at all.
- **A `manifestId` is single use.** Spent on a successful publish, so an older
  signed manifest cannot be put back. A failed publish does not spend it.
- **Keep your identity key.** It signs every future manifest. Losing it means
  rotating the identity; it cannot be recovered. The *API* key is disposable,
  the *identity* key is not.
- **Re-sign before the certificate expires.** Identity certificates are renewed
  automatically with the same key, so you never regenerate a key — but the
  certificate in the signature is checked for validity, so the manifest needs
  signing again with the current one.

## What this does and does not claim

It says an agent published this file and that the bytes have not changed. It
says nothing about whether the content is accurate, useful or safe. Do not
present it to users as an endorsement, and do not treat an absent manifest as
suspicious: almost nothing on the web has one.


---

## More

- Short overview (start here): https://porkbun.com/llms.txt
- Guides (how-tos): https://porkbun.com/llms/guides
- Help articles (knowledge base) as Markdown: https://porkbun.com/llms/kb
- Topic index: https://porkbun.com/llms
- Full reference (one file): https://porkbun.com/llms-full.txt
- OpenAPI spec (full schemas): https://porkbun.com/api/json/v3/spec
- Official MCP server: https://porkbun.com/mcp (`npx -y @porkbunllc/mcp-server`)
- Create API keys: https://porkbun.com/account/api
