Quickstart: REST
The REST API lives at https://api.yoagent.dev/v0 and takes an API key in the Authorization header. This page
walks through a whole email test with curl (and jq to pick fields from the answers), then
shows the same flow in JavaScript and Python.
-
Create a key. In the dashboard, open API keys and click Create key. Choose One project and Full access (later, give a key only what it needs: API keys, OAuth and permissions), then copy the key from the window that opens. Keep it in an environment variable:
Terminal window export YOAGENT_KEY="<api key>"
-
Check the key.
GET /v0/meanswers with the key’s organization and what it may do:Terminal window curl -s https://api.yoagent.dev/v0/me -H "Authorization: Bearer $YOAGENT_KEY" | jq '.organization.name, .access'A missing or wrong key gets
401with the codeunauthorized. -
Create an inbox. An empty body gives an inbox with a random name on your project’s subdomain:
Terminal window INBOX=$(curl -s https://api.yoagent.dev/v0/inboxes \-H "Authorization: Bearer $YOAGENT_KEY" \-H "Content-Type: application/json" \-d '{}')ADDRESS=$(echo "$INBOX" | jq -r .address)echo "$ADDRESS"The answer has the inbox’s
inbox_id, itsaddress, such asinbox-3f9a1c2e@k7m2xq4p.yoagent.email, andcreated_at. Send an email to the address — from your app, or from your own mail. -
Wait for it.
GET /v0/messages/waitanswers as soon as a message to that address arrives, or with"message": nullwhentimeoutruns out (30 seconds by default, at most 2 minutes):Terminal window MESSAGE=$(curl -s -G https://api.yoagent.dev/v0/messages/wait \-H "Authorization: Bearer $YOAGENT_KEY" \--data-urlencode "to=$ADDRESS" \--data-urlencode "timeout=60" | jq .message)[ "$MESSAGE" = null ] && echo "Nothing came in time: wait again, or fail the test"echo "$MESSAGE" | jq '.subject, .from' -
Take the link or the code. Every message comes with the links and codes found in it. Each link has a
kind:verify,reset,unsubscribeorother.Terminal window echo "$MESSAGE" | jq -r '.links[]? | select(.kind == "verify") | .url'echo "$MESSAGE" | jq -r '.codes[0].code' -
Clean up. Deleting the inbox deletes its mail too, for good. An inbox’s address works wherever its id does:
Terminal window curl -s -X DELETE "https://api.yoagent.dev/v0/inboxes/$ADDRESS" -H "Authorization: Bearer $YOAGENT_KEY"
The same flow in code
Section titled “The same flow in code”Node.js 18 or later, as an ES module (email-test.mjs):
const API = "https://api.yoagent.dev/v0";const headers = { Authorization: `Bearer ${process.env.YOAGENT_KEY}`, "Content-Type": "application/json",};
async function call(method, path, body) { const response = await fetch(API + path, { method, headers, body: body && JSON.stringify(body), }); if (!response.ok) throw new Error( `${method} ${path}: ${response.status} ${await response.text()}`, ); return response.status === 204 ? null : response.json();}
const inbox = await call("POST", "/inboxes", {});console.log(`Send an email to ${inbox.address}`);try { const query = new URLSearchParams({ to: inbox.address, after: inbox.created_at, timeout: "60", }); const { message } = await call("GET", `/messages/wait?${query}`); if (!message) throw new Error("no email within 60 s"); const verify = message.links.find((link) => link.kind === "verify"); console.log(message.subject, verify?.url, message.codes[0]?.code);} finally { await call("DELETE", `/inboxes/${inbox.inbox_id}`);}With Requests (email_test.py):
import os
import requests
API = "https://api.yoagent.dev/v0"session = requests.Session()session.headers["Authorization"] = f"Bearer {os.environ['YOAGENT_KEY']}"
def call(method, path, **kwargs): response = session.request(method, API + path, timeout=90, **kwargs) response.raise_for_status() return response.json() if response.content else None
inbox = call("POST", "/inboxes", json={})print(f"Send an email to {inbox['address']}")try: query = {"to": inbox["address"], "after": inbox["created_at"], "timeout": 60} message = call("GET", "/messages/wait", params=query)["message"] if message is None: raise RuntimeError("no email within 60 s") verify = next((link for link in message["links"] if link["kind"] == "verify"), None) codes = message["codes"] print(message["subject"], verify and verify["url"], codes and codes[0]["code"])finally: call("DELETE", f"/inboxes/{inbox['inbox_id']}")after is the inbox’s creation time by the API’s clock: only mail that arrived since counts, whatever your machine’s
clock says. Every operation, with its fields and answers: REST API reference; errors, pages
and other rules all operations share: API and MCP conventions.