Overview

The AllternitBus API provides the runtime surface agents use to send and receive messages, store encrypted secrets, resolve connector credentials, and manage identity channels such as email, phone, and wallet addresses. All authenticated routes are mounted under /api/v1 and require a valid bearer token via the platform auth middleware. The public inbound webhook is mounted at /webhooks/photon and is called server-to-server by Photon.codes.

Base URL

Authenticated surface:
Public webhook surface:
For local development:

Authentication

All authenticated routes require a valid bearer token in the Authorization header. The inbound Photon webhook is authenticated server-to-server by Photon.codes and does not carry a Clerk session. See Authentication for details.

Endpoints

Message inbox

Send a message

Delivers a message to the agent’s inbox. The route path is kept for backward compatibility with the Photon.codes integration.

Request body

Example request

Example response

List inbox messages

Returns messages for the agent, newest first.

Query parameters

Example request

Example response

Inbound webhook

Receive an inbound message

Public webhook called by Photon.codes when an inbound SMS or message arrives. The payload is routed to the agent whose identity channel matches the to phone number. No bearer token is required.

Request body

Example request

Example response

Secrets

Set a secret

Stores an encrypted secret value for the agent. Values are sealed at rest via token_crypto. If a secret with the same key already exists, it is overwritten.

Request body

Example request

Example response

Resolve secrets

Decrypts and returns values for the requested secret references. Required secrets that are missing or cannot be decrypted are reported in missing and errors.

Request body

Each reference:

Example request

Example response

Connectors

Resolve connector credentials

Resolves live credentials for the requested connector bindings. The route first looks up a connected connector_connections row for the caller, then falls back to legacy allternit_vault_credentials that belong to the agent and user.

Request body

Each binding:

Example request

Example response

Identity channels

Get identity channels

Returns the agent’s bound identity channels: email, phone, and wallet. Channels that have not been provisioned are returned as null.

Example request

Example response

Provision email

Provisions an email address for the agent using the domain configured in ALLTERNIT_BOT_EMAIL_DOMAIN. When the mailflare agent-email rail is configured (ALLTERNIT_MAILFLARE_URL + ALLTERNIT_MAILFLARE_ADMIN_KEY), this creates a real mailbox on the mailflare worker, mints a mailbox-scoped send/read API key, seals it server-side, and stores the channel with provider "mailflare". The agent can then genuinely receive and (subject to approval) send internet email. When mailflare is not configured, the endpoint falls back to minting an address record only (provider "commrails") with no send/receive transport. Provisioning is idempotent: re-provisioning an agent returns its existing channel.

Example request

Example response

Agent email rail

Real inbound/outbound email for agents, backed by a per-installation mailflare worker (see services/mailflare/). Inbound mail arrives as an HMAC-signed webhook and is bridged into the agent’s Rails Mail threads; outbound mail is held for human approval before it is sent.

Send email (approval-gated)

The message is not sent immediately. It is recorded as pending_approval and a review is requested on a Rails Mail thread (mail:email-out-<id>). A human approves or rejects via POST /api/rails/mail/decide with { "thread": "<thread_id>", "approve": true|false }; approving triggers the actual send and writes a receipt with the provider message id. The decide response includes an email object for email threads.

Email rail status

Reports whether the mailflare rail is configured, the agent email domain, and whether the worker is reachable. Use this to diagnose installations.

Inbound webhook (server-to-server)

Public route called by the mailflare worker, authenticated by an X-Email-Platform-Signature HMAC-SHA256 header against ALLTERNIT_MAILFLARE_WEBHOOK_SECRET. message.inbound events are stored and bridged into the receiving agent’s Rails Mail thread (mail:email-in-<agent>). Unknown recipients return 202 and are logged.

Provision phone

Assigns a phone number to the agent from the comma-separated pool in ALLTERNIT_BOT_PHONE_POOL. The first number not already assigned to another agent is chosen.

Example request

Example response

Cross-surface bridge

Bridge a session

Requests a cross-surface bridge for a session. The route path is kept for backward compatibility. The payload is echoed back with a bridged status.

Request body

Example request

Example response

Error codes