# Getting started

Send your first email with a key, a domain and one request.

## One address

Everything in OpenSend goes through one API. On our cloud it is at `https://api.opensend.sh`. On a server of your own it is at the address of that server. The dashboard, the SDK, the command line and agents all call that one address.

## Make an API key

Open [API keys](https://opensend.sh/dashboard/api-keys) in the dashboard and make a key. A key starts with `os_` and is shown once, so store it when you make it.

A key with `full` access may call every method. A key with `sending` access may only send. [Authentication](https://opensend.sh/docs/authentication) has the details.

## Set the address and the key

Every example in these docs reads two values from the environment. The SDK and the command line read the same two, and call our cloud when no address is set.

```bash
export OPENSEND_API_URL="https://api.opensend.sh"
export OPENSEND_API_KEY="os_..."
```

## Add a domain

An email is sent from an address on a domain you have verified. Add the domain, publish the DNS records the answer lists, then ask for them to be checked. [Domains](https://opensend.sh/docs/domains) walks through it.

cURL:

```bash
curl -X POST "$OPENSEND_API_URL/v1/domains" \
  -H "Authorization: Bearer $OPENSEND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "updates.example.com",
  "region": "us-east-1"
}'
```

TypeScript:

```ts
await opensend.domains.create({
  name: 'updates.example.com',
  region: 'us-east-1',
})
```

CLI:

```bash
opensend domains create --name updates.example.com --region us-east-1
```

MCP:

```json
{
  "name": "domains_create",
  "arguments": {
    "name": "updates.example.com",
    "region": "us-east-1"
  }
}
```

## Send an email

cURL:

```bash
curl -X POST "$OPENSEND_API_URL/v1/emails" \
  -H "Authorization: Bearer $OPENSEND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "from": "Acme <hello@mail.example.com>",
  "to": "ada@example.com",
  "subject": "Your receipt for November",
  "html": "<p>Thanks for your order.</p>"
}'
```

TypeScript:

```ts
await opensend.emails.send({
  from: 'Acme <hello@mail.example.com>',
  to: 'ada@example.com',
  subject: 'Your receipt for November',
  html: '<p>Thanks for your order.</p>',
})
```

CLI:

```bash
opensend emails send \
  --from 'Acme <hello@mail.example.com>' \
  --to ada@example.com \
  --subject 'Your receipt for November' \
  --html '<p>Thanks for your order.</p>'
```

MCP:

```json
{
  "name": "emails_send",
  "arguments": {
    "from": "Acme <hello@mail.example.com>",
    "to": "ada@example.com",
    "subject": "Your receipt for November",
    "html": "<p>Thanks for your order.</p>"
  }
}
```

The answer is the email as the API keeps it. Its `id` finds it again, and `status` says where it is.

emails.send:

```json
{
  "object": "email",
  "id": "em_10",
  "from": "Acme <hello@mail.example.com>",
  "to": [
    "ada@example.com"
  ],
  "subject": "Your receipt for November",
  "status": "queued",
  "mode": "live",
  "domain": "mail.example.com",
  "cc": [],
  "bcc": [],
  "replyTo": null,
  "scheduledAt": null,
  "createdAt": "2026-11-27T09:30:00.000Z",
  "html": "<p>Thanks for your order.</p>",
  "text": null,
  "headers": {},
  "tags": {},
  "attachments": [],
  "templateId": null,
  "automation": null,
  "events": [
    {
      "type": "queued",
      "at": "2026-11-27T09:30:00.000Z",
      "detail": "Accepted by the API and queued."
    }
  ]
}
```

## See what happened

An email moves from `queued` to `sent` and then `delivered`. Read it again to see where it is and what happened on the way.

cURL:

```bash
curl "$OPENSEND_API_URL/v1/emails/em_02" \
  -H "Authorization: Bearer $OPENSEND_API_KEY"
```

TypeScript:

```ts
await opensend.emails.get('em_02')
```

CLI:

```bash
opensend emails get em_02
```

MCP:

```json
{
  "name": "emails_get",
  "arguments": {
    "id": "em_02"
  }
}
```

To be told instead of asking, add a [webhook](https://opensend.sh/docs/webhooks): your address gets a signed request for each event.

## Use the SDK

In TypeScript the same request is one call. Every method of the API is a method of the client, with the same name and the same input.

```ts
import { OpenSend } from '@open-send/opensend'

const opensend = new OpenSend()

const email = await opensend.emails.send({
  from: 'Acme <hello@mail.example.com>',
  to: 'ada@example.com',
  subject: 'Your receipt for November',
  html: '<p>Thanks for your order.</p>',
})

console.log(email.id, email.status)
```

[The SDK page](https://opensend.sh/docs/sdk) covers options, errors and webhooks.

## Where to go next

- [Sending email](https://opensend.sh/docs/sending): attachments, templates, scheduling and batches.
- [Receiving email](https://opensend.sh/docs/receiving): mail that arrives on your domains.
- [Webhooks](https://opensend.sh/docs/webhooks): events, signatures and retries.
- [The API reference](https://opensend.sh/docs/api): every method, parameter and answer.
- [The command line](https://opensend.sh/docs/cli) and [MCP for agents](https://opensend.sh/docs/mcp).
