# Send and receive your first threaded email quickly

## Prerequisites

- Email ownership verified through OTP or OAuth at [getmail.bot](https://getmail.bot)
- An integration API key with read/write permissions; browser sign-in credentials expire within 24 hours
- A recipient address you control
- An active inbox on an enabled, verified sending domain, with its returned `id` and `address`

Export `MAILBOT_API_KEY` in your shell, then list your inboxes:

```bash
curl https://getmail.bot/v1/inboxes \
  -H "Authorization: Bearer $MAILBOT_API_KEY"
```

Use an active inbox from the response. If you need a new one, create it:

```bash
curl -X POST https://getmail.bot/v1/inboxes \
  -H "Authorization: Bearer $MAILBOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"username":"quickstart"}'
```

Export `INBOX_ID` with the returned `data.id` so both shell and SDK examples can read it. Save `data.address` as the inbox address; shared-domain addresses include an account suffix and should not be guessed.

A provisioned inbox does not mean outbound sending is enabled. Sending is gated
separately, at send time:

- Shared sandbox sending may be paused during a security migration.
- Use your account's verified email as the recipient below. Broader recipients
  require reviewed approval or account trust.
- Start without attachments, which remain blocked pending an approved scanning
  workflow.
- For the first 7 days after signup an account is held to a lower ceiling: 50
  outbound per rolling 24 hours on the shared domain, 10 on your own domain. See
  [Rate Limits](/docs/rate-limits).

If a request is rejected, read its error code before retrying. See
[Getting Started](/docs/getting-started) to create an inbox with an explicit
verified domain, and [Security & Trust](/docs/security).

## Send your first email

Pick the interface that fits your stack. All three options call the same underlying endpoint.

<Tabs>
<TabItem value="curl" label="cURL">

```bash
curl -X POST https://getmail.bot/v1/inboxes/$INBOX_ID/messages \
  -H "Authorization: Bearer $MAILBOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": ["your@email.com"],
    "subject": "Hello from mailbot!",
    "body_text": "This is your first email sent through mailbot. Reply to this email and the reply joins the same thread.",
    idempotency_key="quickstart-first-send-001",
  }'
```

</TabItem>
<TabItem value="nodejs" label="Node.js">

Install the SDK first:

```bash
npm install @yopiesuryadi/mailbot-sdk@0.1.0-beta.3
```

```javascript

const client = new MailBot({ apiKey: process.env.MAILBOT_API_KEY, baseUrl: 'https://getmail.bot' });

const message = await client.messages.send({
  inboxId: process.env.INBOX_ID,
  to: ['your@email.com'],
  subject: 'Hello from mailbot!',
  bodyText: 'This is your first email sent through mailbot. Reply to this email and the reply joins the same thread.',
  idempotencyKey: 'quickstart-first-send-001',
});

console.log('Sent:', message.id);
```

</TabItem>
<TabItem value="python" label="Python">

Install the SDK first:

```bash
pip install mailbot-sdk==0.1.0b2
```

```python
import os
from mailbot import MailBot

client = MailBot(api_key=os.environ["MAILBOT_API_KEY"], base_url="https://getmail.bot/v1")

message = client.messages.send(
    os.environ["INBOX_ID"],
    to=["your@email.com"],
    subject="Hello from mailbot!",
    body_text="This is your first email sent through mailbot. Reply to this email and the reply joins the same thread.",
    idempotency_key="quickstart-first-send-001",
)

print("Sent:", message["id"])
```

</TabItem>
</Tabs>

The SDK versions above are prereleases. Node.js is pinned because the registry's default tag points to an older version. Python needs the explicit `base_url` to avoid its older default host. See [Node.js SDK](/docs/nodejs-sdk) and [Python SDK](/docs/python-sdk).

A successful send response records acceptance, not final delivery. Check the message state before treating it as delivered or retrying a timed-out send.

## If the send is refused

A refused send returns an HTTP status and a stable `error.code`, and nothing
leaves mailbot. The three you are most likely to meet on a first send:

| Code | Status | Fix |
|---|---|---|
| `OWNERSHIP_VERIFICATION_REQUIRED` | `403` | Sign in at getmail.bot with the email code or an OAuth provider, then retry |
| `recipient_unproven` | `403` | Until the account is trusted, the only recipient allowed is your own account address |
| `domain_unverified` or `DOMAIN_NOT_VERIFIED` | `403`, `400` | The inbox domain needs a verified domain record on your account |

[Send Authorization](/docs/concepts/send-authorization) lists every check in the
order it runs, and [Errors](/docs/errors) is the full code reference.

## Receive a reply

Reply to the email from your personal inbox. mailbot automatically threads the reply using `Message-ID` and `In-Reply-To` headers (RFC 5322). No parsing or manual matching required.

## View the thread

Read the thread back with the API. The dashboard has a read-only Inboxes page where you can look at incoming plain
text for each address, but it cannot reply, send, delete or download attachments. Every message operation runs
through the API, an SDK or the MCP server.

```bash
curl "https://getmail.bot/v1/inboxes/$INBOX_ID/threads" \
  -H "Authorization: Bearer $MAILBOT_API_KEY"
```

Select the returned thread, then retrieve its messages:

```bash
curl "https://getmail.bot/v1/inboxes/$INBOX_ID/threads/$THREAD_ID" \
  -H "Authorization: Bearer $MAILBOT_API_KEY"
```

Set `THREAD_ID` to the thread ID from the list response. See [Thread Management](/docs/thread-management).

## Next: Connect your webhook

Now that you can send and receive threaded emails, connect a webhook to get real-time notifications when events happen. See the [webhook guide](/docs/webhooks) for setup instructions and payload reference.
