> For the complete documentation index, see [llms.txt](https://kasplo.gitbook.io/kasplo-doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kasplo.gitbook.io/kasplo-doc/channels/email-api/send-via-api/api-send.md). Agents can also search and read this documentation through its [MCP server](https://kasplo.gitbook.io/kasplo-doc/~gitbook/mcp).

# API Send

Submit transactional and marketing emails over HTTPS using the Kasplo Email API.

***

## Endpoint & Headers

```http
POST https://api.kasplo.com/v1/send-email
Content-Type: application/json
api-key: YOUR_API_KEY
```

> You can also supply your key via `Authorization: Bearer YOUR_API_KEY`.

***

## Request Payload Specification

A complete request consists of the core `email` object, recipient configuration, routing options, and optional application metadata.

```json
{
  "type": "transactional",
  "email": {
    "from": "sender@yourdomain.com",
    "fromName": "Customer Support",
    "replyTo": [
      "support@yourdomain.com"
    ],
    "subject": "Order #48291 Confirmed",
    "html": "<h2>Thank you for your order!</h2><p>Your items are being packed.</p>",
    "text": "Thank you for your order! Your items are being packed.",
    "recipients": {
      "to": [
        {
          "name": "Alice Smith",
          "email": "alice@example.com"
        }
      ]
    },
    "customid": "order-48291",
    "tags": "ecommerce-orders"
  },
  "metadata": {
    "order_id": "48291",
    "customer_tier": "gold"
  }
}
```

***

## Field Reference

### Core Request Fields

| Field      | Type   | Required | Description                                                                                                                                  |
| ---------- | ------ | :------: | -------------------------------------------------------------------------------------------------------------------------------------------- |
| `type`     | string |    No    | Routing classification. Set to `"transactional"` for OTPs, receipts, and alerts. Omit or set to `"marketing"` for campaigns and newsletters. |
| `email`    | object |  **Yes** | Root container for email attributes, content, and recipients.                                                                                |
| `metadata` | object |    No    | Arbitrary key-value pairs returned in webhook payloads for application tracing.                                                              |

### `email` Object Fields

| Field         | Type             |   Required  | Description                                                                                                                                                       |
| ------------- | ---------------- | :---------: | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `from`        | string           |   **Yes**   | Sender email address. Must be a verified sending domain in Kasplo.                                                                                                |
| `fromName`    | string           |      No     | Friendly sender display name (e.g., `"Kasplo Store"`).                                                                                                            |
| `replyTo`     | array of strings |      No     | Array of Reply-To email addresses (e.g., `["support@yourdomain.com"]`).                                                                                           |
| `subject`     | string           |   **Yes**   | Email subject line (UTF-8 supported).                                                                                                                             |
| `html`        | string           | Conditional | Rich HTML email body. Required unless `text` is supplied.                                                                                                         |
| `text`        | string           | Conditional | Plain-text email body fallback.                                                                                                                                   |
| `amp`         | string           |      No     | Interactive AMP for Email markup. (Alternative field: `amp_html`).                                                                                                |
| `recipients`  | object           |   **Yes**   | Container for recipient definitions (`to`, `toList`, `cc`, `bcc`).                                                                                                |
| `attachments` | array of objects |      No     | Array of Base64 or URL-hosted attachment objects.                                                                                                                 |
| `send_at`     | integer          |      No     | UNIX timestamp (in seconds) for scheduled delivery. Minimum 5 minutes ahead, up to 6 months.                                                                      |
| `customid`    | string           |      No     | User-defined tracking ID (up to 200 printable ASCII characters). Returned in webhooks.                                                                            |
| `tags`        | string           |      No     | Category tag used for grouping and webhook reporting.                                                                                                             |
| `unsubscribe` | object           |      No     | Unsubscribe settings (e.g. `{"enabled": true}`). See [Unsubscribe Management](https://kasplo.gitbook.io/kasplo-doc/channels/email-api/unsubscribe-management.md). |
| `headers`     | object           |      No     | Custom RFC headers (e.g. `List-Unsubscribe`, `List-Unsubscribe-Post`).                                                                                            |

### `email.recipients` Object Fields

| Field    | Type             | Description                                                                          |
| -------- | ---------------- | ------------------------------------------------------------------------------------ |
| `to`     | array of objects | Primary recipient list. Each object contains `email` (required) and optional `name`. |
| `toList` | array of objects | Grouped recipient list variation. Do not combine with `to`.                          |
| `cc`     | array of strings | Carbon copy email addresses. Processed as independent billable recipients.           |
| `bcc`    | array of strings | Blind carbon copy email addresses. Hidden from recipient message headers.            |

***

## Response Structure

### 1. Successful Acceptance (`200 OK`)

When a request passes authentication and validation, Kasplo returns HTTP status `200` with application `statusCode: 1000`.

```json
{
  "statusCode": 1000,
  "status": "SUCCESS",
  "message": "Message accepted successfully.",
  "clickTrackingId": "a32993b8-cf2e-4ba7-beca-5297868478b3"
}
```

* **`clickTrackingId`**: A globally unique identifier assigned to this submission. Store this token in your system to cross-reference with Live Feed, message searches, and incoming Webhook events.
* **Important**: A `1000 SUCCESS` response confirms that the message was **accepted for processing**. It does not guarantee final inbox delivery. Subsequent delivery attempts and bounce outcomes are communicated asynchronously via [Webhooks](https://kasplo.gitbook.io/kasplo-doc/channels/email-api/webhooks.md) and [Monitoring](https://kasplo.gitbook.io/kasplo-doc/channels/email-api/monitoring.md).

### 2. Validation Error (`400 Bad Request`)

If required fields are missing or invalid:

```json
{
  "statusCode": 9005,
  "status": "ERROR",
  "message": "From address is required.",
  "errors": []
}
```

For a complete directory of error codes and retry strategies, see [API Responses & Errors](https://kasplo.gitbook.io/kasplo-doc/channels/email-api/send-via-api/api-responses-and-errors.md).

***

## Production cURL Example

```bash
curl --request POST "https://api.kasplo.com/v1/send-email" \
  --header "api-key: YOUR_API_KEY" \
  --header "Content-Type: application/json" \
  --data-raw '{
    "type": "transactional",
    "email": {
      "from": "sender@yourdomain.com",
      "fromName": "Kasplo Notifications",
      "replyTo": ["support@yourdomain.com"],
      "subject": "Security Alert: New Sign-in",
      "html": "<p>A new sign-in was detected on your account.</p>",
      "text": "A new sign-in was detected on your account.",
      "recipients": {
        "to": [
          {
            "name": "Jane",
            "email": "jane@example.com"
          }
        ]
      },
      "customid": "auth-alert-991"
    }
  }'
```
