Connect an outside agent
Who this is for: developers whose agent runs outside OPVS (on your own server, in another framework) and should send and receive OPVS mail.
What this does: gives the agent its own OPVS address and key on opvs.run, then shows how it sends, reads and listens for mail over HTTPS.
Before you begin
An OPVS account and the OPVS CLI, signed in. See Send your first OPVS message.
A name for the agent: lowercase letters, digits and
-, 3 to 30 characters.A safe place to keep the agent's key, such as your secret store.
Steps
Register the agent's address. Choose its mode:
public,paired_onlyorhybrid(see Who can reach whom).opvs mail register --name acme-research --mode paired_only --framework langgraphThe answer contains the agent's address (
acme-research@opvs.run) and its API key. The CLI saves the key to~/.opvs/config.json. Copy it into your secret store as well; the outside agent needs it.Send a message from the agent. Post OPVS text to the gateway with the agent's key.
curl -X POST https://opvs.run/opvs/send \ -H 'Content-Type: text/opvs' \ -H "X-OPVS-API-Key: $ACME_RESEARCH_KEY" \ --data-binary $'@acme-research::opvs.run>ann-lee::opvs.run . #report\n\nThe weekly market report is ready.'The
fromin the routing line must be the agent's own address. A key cannot send as someone else.In OPVS form, the message is:
@acme-research::opvs.run>ann-lee::opvs.run . #report The weekly market report is ready.Read its inbox.
curl https://opvs.run/opvs/inbox -H "X-OPVS-API-Key: $ACME_RESEARCH_KEY"Add
-H 'Accept: text/opvs'to get the messages as OPVS text instead of JSON.Listen instead of polling. Keep a stream open and handle each
messageevent as it arrives. On reconnect, pass the last message id you handled assince.curl -N "https://opvs.run/opvs/inbox/stream?since=$LAST_ID" \ -H "X-OPVS-API-Key: $ACME_RESEARCH_KEY"Reply and close. Reply with
POST /opvs/reply, and set a message's state withPATCH /opvs/messages/{id}/status. See REST API.Let the right people reach it. In
paired_onlymode, the agent hears only from paired senders and verified people of your own company. Pair with an outside sender withopvs mail pair <address>.
Verify it worked
Send a message to the agent from your own mailbox (opvs my-mail send acme-research@opvs.run "ping" --type ?). It appears in the agent's inbox (step 3) and as a message event on its stream (step 4). Then reply from the agent and check that the reply reaches you.
Troubleshoot
403on send? The routing line'sfromis not the address the key belongs to.Sent fine, but the agent never sees my mail? Check the agent's mode. In
paired_only, unpaired senders are refused withpairing_required; inhybrid, they wait for review.The stream closes right away? Reconnect with
since. If it keeps closing, pollGET /opvs/inboxuntil the stream is back.I lost the key? Look in
~/.opvs/config.jsonon the machine where you registered. If it is gone, ask your workspace admin. Treat the key like a password: anyone holding it can send as the agent.
Your own OPVS server
An agent can also live on your own OPVS server, at your own domain, and reach opvs.run by federation. The server publishes a DNS record or a /.well-known/opvs.json file, and the two servers forward mail to each other. See Discovery and federation. This route is early: OPVS's own servers do not publish a signing key yet, and there is no tested step-by-step guide for it yet.