---
title: "Send computer email"
description: "Immediately sends a real email from the computer's stable inbox address."
canonical: "https://www.cool.computer/docs/api-reference/email/send-computer-email"
---
# Send computer email

> Immediately sends a real email from the computer's stable inbox address.

```http
POST https://api.cool.computer/api/computers/{id}/emails/send
```

Immediately sends a real email from the computer's stable inbox address. Call this only after the user approves the recipient and content, and send an Idempotency-Key so a network retry cannot send it twice. A published site's functions cannot call it, since their fetch() to this API is refused; they send with env.EMAIL.send instead (see POST /api/publish).

## Authorization

- A Cool Computers API key, user access token, or claimed agent access token in the Authorization header. Follow https://www.cool.computer/auth.md for agent registration and https://www.cool.computer/authentication.md for direct user credentials.

## Parameters

- `id` (path, string, at least 1 characters, required): The computer's name, such as agent-atlas, or its id (cmp_…). Every caller may use either, the computer's own runtime token included.
- `Idempotency-Key` (header, string, pattern `^[!-~]+$`, 1 to 128 characters): A caller-generated key for safely retrying this side effect. The server retains the key and response for 24 hours. Reusing it with the same request replays the original response, except after a failure that proves nothing happened: that is kept for one minute, and one that sets Retry-After is not kept, so a retry after it runs the request again; reusing it with different input returns 409.

## Request body

Required.

- `application/json` (object)
  - `to` (string, email, required)
  - `subject` (string, pattern `\S`, required): Subject line, limited to 998 bytes.
  - `text` (string): Plain-text body. The text and HTML bodies together are at most 128 KiB of UTF-8, without surrounding white space; a larger one is 413 email_body_too_large, whose context.field names the body to shorten.
  - `html` (string): HTML body. The text and HTML bodies together are at most 128 KiB of UTF-8, without surrounding white space; a larger one is 413 email_body_too_large, whose context.field names the body to shorten.
  - At least one of: `text` (pattern `\S`); `html` (pattern `\S`)

## Responses

- `201`: One inbound or outbound email.
  - `application/json` (object)
    - `id` (string, required)
    - `direction` ("inbound" or "outbound", required)
    - `status` ("received" or "pending" or "sent" or "failed" or "ambiguous" or "rejected", required)
    - `from` (string, required)
    - `envelope_from` (string, required)
    - `sender_authentication` (string)
    - `authenticated_sender` (string)
    - `to` (array of string, required)
    - `subject` (string, required)
    - `text` (string)
    - `html` (string)
    - `message_id` (string)
    - `in_reply_to` (string)
    - `references` (string): The References header: the thread's ancestor Message-IDs, oldest first.
    - `error` (string)
    - `intake_outcome` ("started" or "continued" or "started_after_thread_conflict" or "rejected_unauthenticated_sender" or "rejected_sender_not_owner" or "rejected_owner_domain_unsigned"): What Pi did with an inbound email: started or continued a chat, or rejected it. rejected_owner_domain_unsigned is email from the account owner's verified address whose domain doesn't sign it with DKIM; the owner is sent the steps to turn DKIM signing on, at most once an hour per computer. Absent on outbound email.
    - `intake_detail` (string): For a rejected inbound email, why Pi didn't act on it and what to do next.
    - `created_at` (string, date-time, required)
- `400`: Bad Request.
- `401`: Unauthorized.
- `402`: Payment Required. `pro_required`: this computer has a VM and the account is not Pro, which fences it; a site without a VM works on Free. Start Pro with cool billing upgrade, or fix a lapsed subscription with cool billing portal, or use the Account page.
- `403`: Forbidden.
- `404`: Not Found. `computer_not_found`: the computer does not exist or is not yours.
- `409`: The idempotency key is in progress, has an unknown outcome, or was used for a different request.
- `413`: Payload Too Large. `email_body_too_large`: the text and HTML bodies together are larger than 128 KiB; context.field names the larger body, the one to shorten. Nothing was sent.
- `422`: Unprocessable Content. `email_recipient_unavailable`: the address is on the computers' own mail domain but can't receive mail (for example a computer published without an account and not yet claimed), so the message would be dropped; nothing is sent.
- `429`: Too Many Requests. `email_send_limit`: the computer sent 1000 emails in the last 24 hours, or the account's computers sent 2000, so nothing was sent; send it again tomorrow. `api_request_rate_exceeded`: wait for Retry-After seconds.
- `500`: Internal Server Error.
- `503`: Service Unavailable. `email_gateway_unreachable`: the mail gateway could not be reached and nothing was sent; send it again, with a new Idempotency-Key.
- `default`: A machine-readable API error with a stable code and recovery instruction.

An error is an `application/problem+json` document with a stable `code`; [API errors](/docs/api-reference/errors) says how to handle one.

## Example

```sh
curl -X POST "https://api.cool.computer/api/computers/$PARAM_ID/emails/send" \
  -H "authorization: Bearer $TOKEN" \
  -H "content-type: application/json" \
  --data '{"to":"ana@example.com","subject":"string","text":"string"}'
```
