Skip to content

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.

  1. 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>"

    The new API key’s window in the dashboard: the key to copy and the commands that connect an MCP client with it

  2. Check the key. GET /v0/me answers 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 401 with the code unauthorized.

  3. 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, its address, such as inbox-3f9a1c2e@k7m2xq4p.yoagent.email, and created_at. Send an email to the address — from your app, or from your own mail.

  4. Wait for it. GET /v0/messages/wait answers as soon as a message to that address arrives, or with "message": null when timeout runs 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'
  5. Take the link or the code. Every message comes with the links and codes found in it. Each link has a kind: verify, reset, unsubscribe or other.

    Terminal window
    echo "$MESSAGE" | jq -r '.links[]? | select(.kind == "verify") | .url'
    echo "$MESSAGE" | jq -r '.codes[0].code'
  6. 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"

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}`);
}

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.