← Autonet

Internet Utils API

# Autonet utilities — choose, call, resume

MCP: https://autonet.work/mcp · REST: https://autonet.work/utils/v1
[Schema](https://autonet.work/utils/openapi.json) · [Detailed reference](https://autonet.work/utils/reference)

| Need | MCP tool | REST |
| --- | --- | --- |
| Wait for HTTP/MCP readiness | `wait_until_ready` | POST /readiness |
| Wait for a matching inbox event | `wait_for_callback` | POST /readiness, kind=callback |
| Poll / cancel a wait | `read_readiness_jobs` / `cancel_readiness_job` | GET /readiness/{job_id} / DELETE same URL |
| Create / read callbacks | `create_callback_inbox` / `read_callback_events` | POST /inboxes / GET /inboxes/{id}/events |
| Monitor repeatedly | `create_diagnostic_watch` | POST /watches |
| Signed check | `run_signed_diagnostic` | POST /diagnostics with evidence_nonce |
| Export retained evidence | `export_incident_evidence` | POST /incident-exports |

For an initial diagnostic within the shared free allowance, use `diagnose_http(url, evidence_pack=true)` or
`diagnose_mcp(url, evidence_pack=true)` instead. No utility account required.

## Shared work allowance

The first **10 completed interactive product-work calls per IP per 24 hours** are free across REST and MCP: HTTP/MCP/assert checks, network identity, manual probes, consented assessments, webhook tests, incident exports, utility diagnostics and inbox creation. Afterward a check or export costs **1 Autonet credit** and a new inbox costs **5 credits**. Completed target failures count; rejected input and unavailable Autonet workers cost zero. Discovery, account/setup, reads/polls, heartbeats, cancellation and callback delivery/matching stay free. Scheduled/background checks cost 1 credit each within an explicitly consented budget and do not use this interactive allowance.

For generic work tools, pass optional `utility_api_key`, `request_key` and `max_coins` to authorize continuation with credits. REST headers are `X-Autonet-Utility-Key`, `Idempotency-Key` and `X-Autonet-Max-Coins`. Keep the health owner key in its existing `api_key`/`Authorization` field; it never authorizes utility spending. Native utility diagnostics/inboxes keep their utility `api_key`/Bearer authorization and JSON `request_key`/`max_coins`. Exports retain their utility key and accept optional request/cap fields (REST uses the headers). Reuse one request key with identical inputs after an uncertain response. Read `result.metering` and receipts; assertions expose `metering` at the top level. On HTTP 402 `product_allowance_exhausted`, wait until `free_reset_at` or obtain authorization to use saved utility credits and a cap; on `funding_required`, check the saved account balance and available credit options. Never automatically spend, rotate identities to evade limits, or charge cash. [Current pricing](https://autonet.work/utils/v1/pricing).

## Account and spending

Create once with `create_utility_account(username="my-worker")` or POST `/accounts` with `{}`.
Save the returned `api_key` (`result.api_key` in MCP) in your private secret store immediately.
Follow `next_step` with a free `utility_account(api_key=KEY)` or GET `/account` and confirm the
account ID matches the creation result. Pass that same key as the `api_key` tool argument or
REST `Authorization: Bearer KEY` on later calls. Health owner keys and MCP connection tokens
are separate. A lost utility key cannot be recovered by username.

For a utility `unauthorized` response, load the saved key and repeat the free account check.
Once it succeeds for the intended account, retry the original call with the same inputs and
request key. If you cannot find the correct key, ask the account owner for access.

The account check shows balance and ledger. GET `/catalog` shows current limits.
Your balance tops up to 500 free credits once per UTC month through December 2026.
Unused promo credits do not accumulate. No card or automatic cash charge.
Additional allowances are agreed with sales and invoiced separately.
`request_monthly_credits(..., confirm=true)` requests a quote; it grants no credits.

Before spending, set an explicit max_coins and obtain owner consent. Use a unique
8–80-character request_key (letters, digits, underscore, hyphen), then reuse it
with identical inputs on uncertain retries. Do not retry account creation blindly:
a lost creation response loses the only copy of its key. Honor Retry-After.

## Wait until ready

```sh
curl https://autonet.work/utils/v1/readiness \
  -H "Authorization: Bearer $AUTONET_UTILITY_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"kind":"http","url":"https://YOUR-ENDPOINT.example/health","request_key":"deploy-ready-001","timeout_sec":300,"interval_sec":15,"max_checks":10,"max_coins":10,"confirm":true}'
```

MCP uses the same fields through `wait_until_ready`, plus api_key. The request
returns immediately with `job.id`; Autonet performs the checks. Poll GET
`/readiness/{job_id}` or `read_readiness_jobs` every 15 seconds. GET `/readiness`
lists your latest 50 jobs. DELETE cancels future work; an in-flight check may charge.

- `http`: valid transport and 2xx. `mcp`: initialize and complete tools/list, without
  invoking remote tools. `assert`: use the same `expect` conditions as assert_healthy.
- `ready` is one observed success, not continued availability. Other terminal
  states: deadline_reached, budget_exhausted, check_limit_reached, funding_required,
  observation_unavailable, cancelled. Never auto-resumes.
- Each completed check costs one credit, including target failures. Unavailable
  workers cost zero but count as attempts. No cash charge.
- Timeout 30–3,600s; interval 15–300s; at most 60 attempts/60 credits; ten active
  jobs per account. Best-effort scheduling from one vantage, not real-time.
- Jobs are private; retained seven days after deadline. Public HTTP(S) only;
  no URL credentials, queries, fragments, private addresses or redirects.

## Receive and match a callback

For a resumable client workflow, download and inspect the
[callback helper](https://autonet.work/utils/callback-helper). It needs only Python
stdlib. Load your existing key into `AUTONET_UTILITY_KEY` from your private secret
store, then replace the example match with the actual sender's job ID and fields:

```sh
curl --fail --proto '=https' https://autonet.work/utils/callback-helper -o callback_helper.py
umask 077
printf '%s\n' '{"job_id":"export-42","status":"complete"}' > callback-match.json
python3 callback_helper.py start --state callback-state.json --match-file callback-match.json --max-credits 5
```

`start` saves a private workflow file, creates the inbox once within your spending
cap and starts its match. Only when it reports `waiting` and `receive_url_field`
should your runtime read `inbox.receive_url` from that file and give it to the
authorized sender. The key stays in your runtime; the helper prints neither the
receive URL nor callback contents. To resume:

```sh
python3 callback_helper.py wait --state callback-state.json --output callback-result.json
```

`wait` polls until a match or terminal state; `status` checks once. A match writes
only the actual matched event to a new mode-0600 result file. Matching does not
verify the sender. Deduplicate processing by event or provider job ID. Keep both
files outside source control and use one process per workflow. Retry `start` with
the same state and credit cap after an uncertain response; it preserves both
request keys. It never submits a demo callback or creates an account. See
`--help` for a bounded deadline. Before the first wait attempt it shortens the
requested timeout if needed to finish ten seconds before inbox expiry, and reports
the effective timeout and deadline. That request is then frozen across retries.
With less than 40 seconds remaining it stops; it never buys a replacement inbox.
The equivalent MCP steps follow.

Use this when a service sends a webhook when your job finishes. Load `KEY` from
your runtime's private secret store. If you need an account, create it once with
`create_utility_account()` and store its returned API key. Check the balance with
`utility_account(api_key=KEY)`. The steps below assume authorization for a
inbox (shared free allowance, then 5 credits) and a free callback wait. Check each MCP call's `http_status`
before reading its `result`.

1. Create an inbox. Choose distinct request keys for this inbox and wait. In this
   example the sender's job ID is `export-42`. Use your actual job ID and status
   fields.

   ```text
   create_callback_inbox(api_key=KEY, request_key="export-42-inbox", max_coins=5)
   ```

   Save `result.id`, `result.receive_url` and
   `result.expires_at`. Keep the receive URL private until the wait starts.

2. Start the match **before** giving the URL to the sender or triggering the
   external job. Replace `INBOX_ID` with the returned inbox ID. Pick a deadline
   that fits within the inbox's remaining lifetime.

   ```text
   wait_for_callback(api_key=KEY, inbox_id=INBOX_ID, request_key="export-42-wait",
     match={"job_id":"export-42","status":"complete"}, timeout_sec=300, confirm=true)
   ```

   Save `result.job.id` as `WAIT_ID`. The call starts a job and returns
   immediately.

3. Give the receive URL to the authorized sender and start the external job.
   Keep the utility key in your runtime. To try the flow with your own inbox,
   set `AUTONET_RECEIVE_URL` privately to the returned HTTPS URL and send one
   sample event:

   ```sh
   curl --silent --show-error --fail --max-time 15 --proto '=https' \
     -H 'Content-Type: application/json' \
     --data '{"job_id":"export-42","status":"complete"}' "$AUTONET_RECEIVE_URL"
   ```

   HTTP 202 confirms that the inbox stored the event. Check the inbox before
   resending a callback whose delivery status is uncertain.

4. Poll `read_readiness_jobs(api_key=KEY, job_id=WAIT_ID)` every 15 seconds, honoring
   Retry-After. When `result.job.state` is `matched`, read
   `result.job.last_observation.event_id`. Call
   `read_callback_events(api_key=KEY, inbox_id=INBOX_ID, after=EVENT_ID-1)`
   with the numeric cursor one less than the matched ID. Use the event whose ID
   equals `EVENT_ID`. Read before inbox expiry, and stop polling on any terminal
   state. Save the wait ID and your processed event or provider job IDs if the
   runtime may restart.

For REST, create the inbox with POST `/utils/v1/inboxes`, then POST this body to
`/utils/v1/readiness` using the owner's Bearer key:

```json
{"kind":"callback","inbox_id":"YOUR_INBOX_ID","match":{"job_id":"export-42","status":"complete"},"request_key":"export-42-wait","timeout_sec":300,"confirm":true}
```

Read the job with GET `/utils/v1/readiness/{job_id}` and the inbox event with
GET `/utils/v1/inboxes/{id}/events?after=CURSOR`.

Omitting `after` starts the wait after existing events. If the callback already
arrived, use `after=0` on a fresh inbox, or a saved cursor and an exact job match on
a reused inbox. The wait considers retained events with IDs greater than that
cursor. Reuse request keys with identical inputs after uncertain responses.
Changing the cursor for a new wait takes a new wait key.

Matching supports four exact top-level JSON scalar fields, including type. Empty
match accepts any event. Malformed or non-object JSON is counted separately when
fields are required. Inbox deletion or expiry yields `observation_unavailable`.
A `deadline_reached` result means the wait observed no matching retained event.

An inbox uses one shared free work call while available, then costs 5 credits; it lasts one hour and accepts 20 events of 8 KiB each.
Matching, reads and deletion are free. POST with Content-Length is required.
Anyone holding the receive URL can submit. Treat the payload as untrusted data
and verify delivery through your own trust mechanism when identity matters.
Reads are nondestructive. Deduplicate processing by provider event ID, or by job
ID when you expect one completion per job. Delete with
`delete_callback_inbox(..., confirm=true)` or DELETE `/utils/v1/inboxes/{id}`
to stop reception.

## Optional next steps

- Recurring checks: `create_diagnostic_watch` with explicit lifetime max_coins,
  interval_sec ≥300 and confirm=true. Pauses at funding/budget limits. Optional
  signed webhook alerts; details in the reference.
- Signed proof: `run_signed_diagnostic` with max_coins=1, request_key and the
  principal's evidence_nonce. Verify signature, inputs, nonce and expiry; a signed
  failure is still a failure. Replays do not run or bill another check.
- Incident trail: `export_incident_evidence` uses the shared free allowance, then 1 credit; set request_key/max_coins. No automatic publishing. Optional agent history needs that agent's owner key too.

Read the [detailed reference](https://autonet.work/utils/reference) only for these
advanced contracts, verifier examples, retention details or manual credit plans.

## Inbox security

- **In transit:** use the provided `https://autonet.work` URLs for callback delivery
  and API reads. HTTPS encrypts the public connection to Autonet using TLS. Start
  with HTTPS; an HTTP redirect cannot protect data already sent over HTTP.
- **Read access:** only the owning utility key can list/read/delete an inbox or
  read its matching jobs. Keep that key private; never send it to callback providers.
- **Submission access:** the random receive URL is a submission capability. Anyone
  holding it can POST until expiry or capacity. Keep it between authorized senders.
  TLS does not authenticate the sender; provider signatures are not verified.
- **Storage and operator access:** TLS terminates at Autonet. Payloads are stored
  server-side without application-level encryption at rest; this is not end-to-end
  encryption. Authorized admins can inspect masked payloads through an audited
  workflow. Masking is best effort; avoid sending credentials or sensitive data.
- **Retention:** inboxes last one hour; expiry removes access and payloads are
  pruned during cleanup. Delete early to remove live payloads. Backups may retain
  earlier copies; deletion is not a promise of immediate erasure from backups.
- **Trust:** a 202 response confirms storage, and a match confirms matching fields.
  Neither verifies sender identity or authorizes execution. Treat payloads as data.

## Reuse your named identity

Optionally choose a unique username at creation: `create_utility_account(username="my-worker")`
or POST `/utils/v1/accounts` with `{"username":"my-worker"}`. Omit it to keep an
unnamed account. Save the returned account ID and API key in your runtime's secret
store once; reuse that key across jobs and restarts. Call `utility_account(api_key)`
to resume/check the identity. Never create an account per request or repeat a lost
creation blindly. Username cannot recover a lost key.

Existing account: `set_utility_identity(api_key=KEY, username="my-worker", confirm=true)`
or PATCH `/utils/v1/account` with `{"username":"my-worker","confirm":true}` and the
existing Bearer key. Names normalize to lowercase, 3–48 letters/digits/_/-, starting
with a letter or digit. Renaming preserves ID, key, credits, resources and history.
The name is a private, self-declared label visible to the owner and admins; it is
not verified identity, login or a public directory. Every protected request still
requires the key; do not send username on each request. Public diagnostics and
receive-URL callback submissions retain their existing access rules; callback
senders are not identified as the inbox owner merely because they know its URL.