Let a machine that has no agent key upload one file to this Energon, with the bytes going straight to the content origin instead of through you. Use an upload grant because it is the narrowest credential that works: it covers one target, works once, and expires within an hour. A fleet orchestrator, a CI job, or a sandboxed agent can then publish a file it built locally without ever holding an account token.
Let a machine upload without a token
When to use a grant
Pick the credential by what the other machine needs to do:
| The other machine needs to | Use |
|---|---|
| Upload one file once, now (a new file, a replacement, or one site path) | An upload grant (this page) |
| Publish a whole site update it built, as one release | A whole-site grant bound to an approved deployment session |
| Keep updating one existing public URL over time, from outside this Energon | A write password |
Act as an account on many objects (list, read through /v1, publish freely) | Its own agent key through Connect an agent |
A grant acts as the account that minted it: the upload passes that account’s write policy, and that account becomes the writer. It is not an account, it cannot call /v1, and it cannot be used as an agent key.
1. Token holder: mint the grant
You need an agent key that can write the target. Choose exactly one target:
{"type": "new_file", "filename": "report.pdf"}creates a loose file owned by your account when the upload lands. Optionalwrite_policyworks as it does onPOST /v1/files. Optionalttlmust be one of this Energon’s retention preset ids fromGET /v1/help; unlikePOST /v1/files, seconds are not accepted. From v1.10.0, optionalpasswordandwrite_passwordset the new file’s share password and write password at mint, so the file is protected from the moment the upload lands. The mint response echoes them once insidetarget;GET /v1/grants/{id}never returns them, and the uploading machine never sees them. From v1.15.0, optional"link_access": "private"makes the new file private from the moment it lands; combining it withpasswordorwrite_passwordis400 link_access_conflict.{"type": "file", "id": "<file id>"}replaces an existing loose file at the same URL. From v1.11.0, if others may revise that file, add"expected_version"set to its currentcontent_generation(see Replace only if nobody else has). Mint refuses a stale value with409 file_conflict. If someone replaces the file after you mint, the upload writes nothing and the grant endsfailedwithlast_error: file_conflict, so older bytes never overwrite newer work. Onlyfiletargets takeexpected_version.{"type": "site_path", "site_id": "<site id>", "path": "index.html"}adds or replaces one path in an existing site and keeps the other paths. To publish a whole folder as one release, use a whole-site grant instead of one grant per path; separate path grants publish one at a time.
export ENERGON_ORIGIN="https://hub.your-company.example"
test -n "$ENERGON_TOKEN" || { echo "Set a human-authorized ENERGON_TOKEN" >&2; exit 1; }
GRANT_JSON=$(curl -fsS "$ENERGON_ORIGIN/v1/grants" \
-H "Authorization: Bearer $ENERGON_TOKEN" \
-H "Content-Type: application/json" \
--data '{"target":{"type":"new_file","filename":"report.pdf"},"expires_in":"15m","max_bytes":10485760}')
printf '%s' "$GRANT_JSON" | jq '{id, upload_url, expires_at, max_bytes, url, status_url}'
GRANT_ID=$(printf '%s' "$GRANT_JSON" | jq -r .id)Optional fields:
expires_in:5m,15m(default),30m, or1h. A grant never outlives the token that minted it, soexpires_atcan be earlier than you asked for.max_bytes: the largest body the upload may send, capped at this Energon’s per-file limit.sha256: the expected SHA-256 of the body, as hex. An upload whose bytes do not match publishes nothing.
The response returns secret once, with the no-store header. url is the public URL the upload will change for file and site_path targets, and null for new_file, whose URL comes back from the upload and from the status read.
2. Hand off the upload URL and secret
Send the other machine upload_url and secret, plus max_bytes and sha256 if you set them, so it knows the limits. Use whatever private channel your system already has, such as an orchestrator task payload. The other machine needs nothing else: no token, no Access session, and no /connect.
3. Uploading machine: PUT the bytes
Send the file as the raw body with the secret in the Authorization header. Do not send a filename, password, TTL, expected-version, or content type header; the grant fixed the target at mint, and metadata headers are 400. The uploader cannot choose the content type: a new file’s type follows its filename and contents, and a replaced file keeps its stored type.
export UPLOAD_URL="https://content.your-company.example/_grants/<grant id>"
export GRANT_SECRET="<grant secret>"
curl -fsS -X PUT "$UPLOAD_URL" \
-H "Authorization: Bearer $GRANT_SECRET" \
--data-binary @report.pdfcurl --data-binary @file sets Content-Length, which bodies over 25 MB require. Success is 201 for a new file or path and 200 for a replacement, with the public url. The grant is then used up. If the machine is lost, it can read GET /llms.txt on the content origin, which describes this protocol.
Or let the bundled helper do it
From v1.12.0, the skill ships a Python 3 helper, scripts/energon_publish.py, that does this step without putting the secret on the command line. A machine without the installed skill can download it from agent_skills_url in /v1/help. Pass the whole mint response on stdin, or in a mode-600 file with --grant-file PATH:
python3 energon_publish.py publish-file report.pdf --grant-file - < grant.jsonThe helper refuses an upload_url that is not on the content origin /v1/help reports, does not follow redirects, retries 409 grant_busy, and prints the published url. If the grant was already used, it reports that upload’s url instead of failing. python3 energon_publish.py inspect report.pdf prints the size and sha256 to put in max_bytes and sha256 when you mint. Use Energon through a tool gateway covers the helper’s other commands and the case where a gateway, not a person, holds the token.
4. Token holder: read the result
curl -fsS "$ENERGON_ORIGIN/v1/grants/$GRANT_ID" \
-H "Authorization: Bearer $ENERGON_TOKEN" | jq '{state, url, last_error, expires_at}'Any token of the minting account can read it. state is one of:
unused: not uploaded yet. The same secret still works untilexpires_at.uploading: an upload holds the grant right now.consumed: published;urlis the public URL. From v1.10.0,result_idis the id of what the upload wrote: the new or replaced loose file’s id, or the site id for asite_pathtarget.failed: ended for good;last_errorsays why, for exampletoken_revoked,file_not_found, orfile_conflict. Mint a new grant, but afterfile_conflictread the file again and decide with the person who asked before you do.file_recovery_requiredis the exception: a new grant would fail too, so ask an administrator to reconcile the file first.expired: the grant ran out before a successful upload. Mint a new grant.
Grant records are deleted a day after they expire, after which the status read is 404 grant_not_found.
Recover from the usual failures
| Status | error | What it means |
|---|---|---|
404 | grant_invalid | Wrong grant id or secret. Check what was handed off. |
410 | grant_used | Already used. The body names the published url and, from v1.10.0, its result_id. |
410 | grant_expired | The grant ran out. Ask the token holder for a new one. |
410 | grant_failed | Ended for good: the minting token was revoked, the target was deleted, the account lost write access, or the file changed after expected_version (reason: file_conflict). The body has reason. Ask for a new grant. With reason: file_recovery_required, the file needs an administrator to reconcile its storage, and a new grant fails too until then. |
409 | grant_busy / file_busy | Another upload or write is in progress. Retry the same upload. |
413 | too_large | The body is over max_bytes or this Energon’s limit. Nothing was published. |
413 | storage_cap | This Energon is out of storage. Free space, then retry with the same grant. |
400 | checksum_mismatch | The bytes do not match sha256. Nothing was published; retry with the right bytes. |
400 | bad_request / bad_content_type | A metadata header or a multipart body was sent. Send raw bytes only. |
Retryable failures (409, 413 storage_cap, and most 5xx) hand the grant back, so the same secret works until it expires. The exception is 500 storage_rollback_failed: storage could not be restored, so the grant stays held until it expires and retries return 409 grant_busy. Report it, and mint a new grant once storage recovers. Grant responses on the content origin never include a hub field or an api_url. A PUT to the upload path on the hub origin returns 404 naming the content-origin URL, because clients drop Authorization on a cross-host redirect.
The grant secret is a credential. Never put it in a URL, a log, a commit, or a published file. Revoking the token that minted a grant ends that grant, and revoking a person’s tokens ends every grant they minted. There is no separate per-grant revoke; grants last at most an hour.
For the exact request and response fields, see HTTP API. For how grants sit next to share passwords, write passwords, and write policy, read Sharing, access, and expiry.