# Get email

URL: https://docs.hanzo.ai/docs/openapi/email/get-email-by-id

> Reads one message of the org's ledger, sent through this API or told of by its provider, with what became of it.

`GET /v1/email/{id}`

> [Email →](https://docs.hanzo.ai/docs/openapi/email) · [All API references →](https://docs.hanzo.ai/docs/openapi) · [Get started →](https://docs.hanzo.ai/docs/guides)

|               |                                        |
| ------------- | -------------------------------------- |
| **Address**   | `https://api.hanzo.ai/v1/email/{id}`   |
| **Method**    | `GET`                                  |
| **Operation** | `get_email_by_id`                      |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY` |

Reads one message of the org's ledger, sent through this API or told of
by its provider, with what became of it.

GET /v1/email/:id

## Request

1 field.

| Field | In   | Type   | Required | Description                            |
| ----- | ---- | ------ | -------- | -------------------------------------- |
| `id`  | path | string | yes      | ID is our id for the message (msg\_…). |

## Response

| Status    | Body                | Meaning |
| --------- | ------------------- | ------- |
| `200`     | email.MessageRecord | ok      |
| `default` | problem-details     | refused |

`200` body — 20 fields.

| Field             | In   | Type               | Always | Description                                                                                                                     |
| ----------------- | ---- | ------------------ | ------ | ------------------------------------------------------------------------------------------------------------------------------- |
| `bounce`          | body | string             | —      | Bounce is hard or soft, for a message that bounced.                                                                             |
| `bounced_at`      | body | string (date-time) | —      | BouncedAt is when it bounced, and Bounce whether hard or soft.                                                                  |
| `campaign`        | body | string             | —      | Campaign is the campaign the message was tagged with.                                                                           |
| `clicked_at`      | body | string (date-time) | —      | ClickedAt is when a link in it was first clicked.                                                                               |
| `complained_at`   | body | string (date-time) | —      | ComplainedAt is when its recipient reported it as spam.                                                                         |
| `created_at`      | body | string (date-time) | —      | CreatedAt is when the message was sent, or accepted to be.                                                                      |
| `delivered_at`    | body | string (date-time) | —      | DeliveredAt is when the receiving server first took it.                                                                         |
| `error`           | body | string             | —      | Error says why it failed, bounced, was deferred or was rejected.                                                                |
| `from`            | body | string             | —      | From is the sender address, when known.                                                                                         |
| `id`              | body | string             | —      | ID is our id for the message (msg\_…): every link in it carries it as from=, and the event stream names it by it.               |
| `idempotency_key` | body | string             | —      | IdempotencyKey is the key the message was sent under.                                                                           |
| `opened_at`       | body | string (date-time) | —      | OpenedAt is when it was first opened.                                                                                           |
| `org`             | body | string             | —      | Org is the organization owning this message.                                                                                    |
| `origin`          | body | string             | —      | Origin is api for a message POST /v1/email sent, provider for one the provider's events told of, sent from the org's own tools. |
| `provider`        | body | string             | —      | Provider is the rail it went by: ses or sendgrid.                                                                               |
| `provider_id`     | body | string             | —      | ProviderID is the provider's own id for the message, which its events name it by; empty until the provider answers one.         |
| `status`          | body | string             | —      | Status is queued, sent, failed, delivered, opened, clicked, bounced or complained.                                              |
| `subject`         | body | string             | —      | Subject is the message subject line, when known.                                                                                |
| `to`              | body | string\[]          | —      | To lists the recipients.                                                                                                        |
| `unsubscribed_at` | body | string (date-time) | —      | UnsubscribedAt is when its recipient unsubscribed from it.                                                                      |

Failure carries the platform error shape — see [Errors](https://docs.hanzo.ai/docs/errors).

## Examples

**CLI**

```bash
hanzo email get <id>
```

**SDK**

**.ts**

```ts
import { Configuration, EmailApi } from 'hanzoai';

const api = new EmailApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.getEmailById({ id: 'id' });
```

**.py**

```python
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import EmailApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = EmailApi(client).get_email_by_id(id='id')
```

**.go**

```go
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.EmailAPI.GetEmailById(context.Background()).Execute()
if err != nil {
	return err
}
```

**.rs**

```rust
use hanzo_client::apis::{configuration::Configuration, email_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = email_api::get_email_by_id(&cfg, Default::default()).await?;
```

**.java**

```java
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.EmailApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new EmailApi(client).getEmailById();
```

**HTTP**

```bash
curl https://api.hanzo.ai/v1/email/<id> \
  -H "Authorization: Bearer $HANZO_API_KEY"
```

**MCP**

Tool `email`, op `get_email_by_id` — POST the JSON-RPC envelope to `https://api.hanzo.ai/v1/mcp`.

```bash
curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "email",
         "arguments": {
           "op": "get_email_by_id",
           "input": {
             "id": "<id>"
           }
         }
       }
     }'
```

---

[Email API](https://docs.hanzo.ai/docs/openapi/email) · [All Hanzo APIs](https://docs.hanzo.ai/docs/openapi) · [Interactive reference](https://docs.hanzo.ai/docs/openapi/reference)
