---
title: "Quickstart: REST"
description: "Make your first calls with an API key: create an inbox, wait for an email, read its link or code, clean up."
url: "https://docs.yoagent.dev/start/quickstart-rest"
---

# 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`](https://jqlang.org/) to pick fields from the answers), then shows the same flow in JavaScript and Python.

## Steps

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](https://docs.yoagent.dev/account/api-keys-oauth-and-permissions)), then copy the key from the window that opens. Keep it in an environment variable:

   ```bash
   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](https://docs.yoagent.dev/_astro/api-key-created.Czp5LUe5_Z2j1ztn.webp)

2. **Check the key.** `GET /v0/me` answers with the key’s organization and what it may do:

   ```bash
   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:

   ```bash
   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):

   ```bash
   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`.

   ```bash
   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:

   ```bash
   curl -s -X DELETE "https://api.yoagent.dev/v0/inboxes/$ADDRESS" -H "Authorization: Bearer $YOAGENT_KEY"
   ```

## The same flow in code

**JavaScript**

Node.js 18 or later, as an ES module (`email-test.mjs`):

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

**Python**

With [Requests](https://requests.readthedocs.io/) (`email_test.py`):

```python
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](https://docs.yoagent.dev/reference/rest-api); errors, pages and other rules all operations share: [API and MCP conventions](https://docs.yoagent.dev/reference/conventions).
