> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developer.jelliu.co/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developer.jelliu.co/_mcp/server.

# Send an email

POST https://api.jelliu.co/api/email/send
Content-Type: application/json

Sends an email to an existing contact from the workspace's **own connected mailbox**
(Gmail, Outlook or Zoho Mail), then records it in the contact's email conversation. There is
no platform sender. A workspace that has not connected a mailbox and selected it under
Settings → Account → Email gets `409`.

**Replying in a thread.** Pass `inReplyTo` with the provider's thread id (Gmail) or message id
(Outlook, Zoho) to answer inside a thread the customer is already reading. The mailbox's
reply action is used, so the provider threads the message and `subject` is not applied.
Without `inReplyTo` a new email is sent. `inReplyTo` changes how the email goes out, never
whether: every check below still runs.

**Checks, in order:** the contact exists in the workspace and has an email address, a usable
mailbox is configured, compliance rules pass (do-not-contact list, suppression list, blocked
prefixes; quiet hours are **not** applied to email), the contact has not opted out, and the
daily email cap has room. The subject is trimmed and line breaks in it are replaced with
spaces.

After a successful send the email is written into the contact's latest email conversation,
or a new one if none exists, without reopening a closed thread. That way the agent handling
the reply knows what was sent. Recording is best-effort and never fails the request.

**Side effects.** Sends a real email from the customer's mailbox through its provider
connection. Consumes one unit of the daily email send cap: 1,000 per UTC day by default,
25,000 on plans with no monthly limit. The unit is refunded on any delivery failure. A
retryable transport error is retried once, only when the provider guarantees nothing was
delivered. Does not draw on the AI-message allowance. Writes a message to the thread and an
audit entry.

**Idempotency.** Not idempotent. A retry after a timeout can send the email twice.

**Webhook events.** `audit.log_recorded` for subscribers that selected it explicitly. See [Webhooks](/webhooks).

**Access**
- **Required scope:** `write`.
- **Rate limit:** Outbound — 20 requests/min per workspace, fail-closed, counted on every `/api/email` request **and** the configuration-mutations limiter — 10 requests/min per workspace, shared with other configuration mutations. See [Rate limits](/rate-limits).
- **Plan:** Available on every plan. Requires a connected Gmail, Outlook or Zoho Mail mailbox selected as the sending mailbox.


Reference: https://developer.jelliu.co/api-reference/email/post-email-send

## Authentication

- `Authorization` header (bearer token, required) — Workspace API key: `jl_` followed by 64 lowercase hex characters, created by the workspace owner in the dashboard (**Settings → API Keys**) and sent as `Authorization: Bearer jl_...`. The plaintext is shown once, at creation; Jelliu stores only a SHA-256 hash. A workspace can hold up to 25 active keys. | Scope | GET / HEAD | POST / PUT / PATCH / DELETE | Admin-only routes | | --- | --- | --- | --- | | `read` | Yes | No | No | | `write` | Yes | Yes | No | | `full` | Yes | Yes | Yes | Operations restricted to admins or owners reject keys without the `full` scope with `403`, and say so in their description. No key, whatever its scope, can mint or revoke API keys or rotate a webhook secret — that requires a signed-in owner session. A revoked key stops authenticating within about 10 seconds. See [Authentication](/authentication).

## Request

### Body (application/json)

This endpoint expects an object.

- `contactId` (string, required) — Contact to email. Must belong to the workspace and have an email address; otherwise 400 `Contact has no email address`.
- `subject` (string, required) — Subject line. Trimmed; CR/LF characters are replaced by spaces. Not applied when `inReplyTo` threads the reply.
- `message` (string, required) — Plain-text body, trimmed before sending.
- `inReplyTo` (string, optional) — Provider thread id (Gmail) or message id (Outlook, Zoho Mail) to reply within. Opaque, not a UUID.

## Response

### 200

Email sent.

- `data` (object, required)
  - `sent` (true, required) — Always `true`.
  - `to` (string, required) — The contact address the email was sent to.

## Errors

### 400 Bad Request Error

Body failed validation (`Invalid email input`, field map in `details`), or the contact is unknown or has no email address.

- `error` (object, required) — The error object. Always has `code` and `message`.
  - `code` (string, required) — Stable machine-readable error code (for example `VALIDATION_FAILED`, `UNAUTHORIZED`, `FORBIDDEN`, `NOT_FOUND`, `BILLING_ERROR`, `COMPLIANCE_BLOCKED`, `RATE_LIMIT_EXCEEDED`, `INTERNAL_ERROR`). Switch on this, not on `message`. See [Errors](/errors).
  - `message` (string, required) — Human-readable explanation. English or Spanish depending on the route; may change without notice.
  - `details` (object or list of object, optional) — Present on `VALIDATION_FAILED` only. Its shape depends on how the route validates: * a field map, either Zod's `flatten()` output (`{ "formErrors": [], "fieldErrors": { "name": ["..."] } }`) or just its `fieldErrors` part (`{ "name": ["..."] }`); * an issue list, where each issue has at least `path`, `message` and `code`. `path` is a dot-separated string on routes that let the schema throw, and an array of keys on routes that forward Zod's raw issues (those also carry Zod's extra issue fields).
    - Field map
      - `formErrors` (list of string, optional)
      - `fieldErrors` (map from string to list of string, optional)
  - `metadata` (map from string to any, optional) — Structured detail exposed for a small allowlist of codes only — for example `BILLING_ERROR` carries `limit`, `current` and `tier` (resource caps) or `tier` and `feature` (feature gates).

### 401 Unauthorized Error

No usable credential. Either the `Authorization` header is missing or is not a well-formed `Bearer jl_…` key, or the key is unknown, revoked or expired. Do not retry with the same key. See [Authentication](/authentication#401-unauthorized).

- `error` (object, required) — The error object. Always has `code` and `message`.
  - `code` (string, required) — Stable machine-readable error code (for example `VALIDATION_FAILED`, `UNAUTHORIZED`, `FORBIDDEN`, `NOT_FOUND`, `BILLING_ERROR`, `COMPLIANCE_BLOCKED`, `RATE_LIMIT_EXCEEDED`, `INTERNAL_ERROR`). Switch on this, not on `message`. See [Errors](/errors).
  - `message` (string, required) — Human-readable explanation. English or Spanish depending on the route; may change without notice.
  - `details` (object or list of object, optional) — Present on `VALIDATION_FAILED` only. Its shape depends on how the route validates: * a field map, either Zod's `flatten()` output (`{ "formErrors": [], "fieldErrors": { "name": ["..."] } }`) or just its `fieldErrors` part (`{ "name": ["..."] }`); * an issue list, where each issue has at least `path`, `message` and `code`. `path` is a dot-separated string on routes that let the schema throw, and an array of keys on routes that forward Zod's raw issues (those also carry Zod's extra issue fields).
    - Field map
      - `formErrors` (list of string, optional)
      - `fieldErrors` (map from string to list of string, optional)
  - `metadata` (map from string to any, optional) — Structured detail exposed for a small allowlist of codes only — for example `BILLING_ERROR` carries `limit`, `current` and `tier` (resource caps) or `tier` and `feature` (feature gates).

### 403 Forbidden Error

The contact opted out or is marked do-not-contact, or the API key lacks the `write` scope.

- `error` (object, required) — The error object. Always has `code` and `message`.
  - `code` (string, required) — Stable machine-readable error code (for example `VALIDATION_FAILED`, `UNAUTHORIZED`, `FORBIDDEN`, `NOT_FOUND`, `BILLING_ERROR`, `COMPLIANCE_BLOCKED`, `RATE_LIMIT_EXCEEDED`, `INTERNAL_ERROR`). Switch on this, not on `message`. See [Errors](/errors).
  - `message` (string, required) — Human-readable explanation. English or Spanish depending on the route; may change without notice.
  - `details` (object or list of object, optional) — Present on `VALIDATION_FAILED` only. Its shape depends on how the route validates: * a field map, either Zod's `flatten()` output (`{ "formErrors": [], "fieldErrors": { "name": ["..."] } }`) or just its `fieldErrors` part (`{ "name": ["..."] }`); * an issue list, where each issue has at least `path`, `message` and `code`. `path` is a dot-separated string on routes that let the schema throw, and an array of keys on routes that forward Zod's raw issues (those also carry Zod's extra issue fields).
    - Field map
      - `formErrors` (list of string, optional)
      - `fieldErrors` (map from string to list of string, optional)
  - `metadata` (map from string to any, optional) — Structured detail exposed for a small allowlist of codes only — for example `BILLING_ERROR` carries `limit`, `current` and `tier` (resource caps) or `tier` and `feature` (feature gates).

### 409 Conflict Error

The workspace has no mailbox of its own to send from. Connect one under Integrations and select it in Settings.

- `error` (object, required) — The error object. Always has `code` and `message`.
  - `code` (string, required) — Stable machine-readable error code (for example `VALIDATION_FAILED`, `UNAUTHORIZED`, `FORBIDDEN`, `NOT_FOUND`, `BILLING_ERROR`, `COMPLIANCE_BLOCKED`, `RATE_LIMIT_EXCEEDED`, `INTERNAL_ERROR`). Switch on this, not on `message`. See [Errors](/errors).
  - `message` (string, required) — Human-readable explanation. English or Spanish depending on the route; may change without notice.
  - `details` (object or list of object, optional) — Present on `VALIDATION_FAILED` only. Its shape depends on how the route validates: * a field map, either Zod's `flatten()` output (`{ "formErrors": [], "fieldErrors": { "name": ["..."] } }`) or just its `fieldErrors` part (`{ "name": ["..."] }`); * an issue list, where each issue has at least `path`, `message` and `code`. `path` is a dot-separated string on routes that let the schema throw, and an array of keys on routes that forward Zod's raw issues (those also carry Zod's extra issue fields).
    - Field map
      - `formErrors` (list of string, optional)
      - `fieldErrors` (map from string to list of string, optional)
  - `metadata` (map from string to any, optional) — Structured detail exposed for a small allowlist of codes only — for example `BILLING_ERROR` carries `limit`, `current` and `tier` (resource caps) or `tier` and `feature` (feature gates).

### 423 Locked Error

Blocked by compliance rules (do-not-contact list, suppression list, blocked prefix).

- `error` (object, required) — The error object. Always has `code` and `message`.
  - `code` (string, required) — Stable machine-readable error code (for example `VALIDATION_FAILED`, `UNAUTHORIZED`, `FORBIDDEN`, `NOT_FOUND`, `BILLING_ERROR`, `COMPLIANCE_BLOCKED`, `RATE_LIMIT_EXCEEDED`, `INTERNAL_ERROR`). Switch on this, not on `message`. See [Errors](/errors).
  - `message` (string, required) — Human-readable explanation. English or Spanish depending on the route; may change without notice.
  - `details` (object or list of object, optional) — Present on `VALIDATION_FAILED` only. Its shape depends on how the route validates: * a field map, either Zod's `flatten()` output (`{ "formErrors": [], "fieldErrors": { "name": ["..."] } }`) or just its `fieldErrors` part (`{ "name": ["..."] }`); * an issue list, where each issue has at least `path`, `message` and `code`. `path` is a dot-separated string on routes that let the schema throw, and an array of keys on routes that forward Zod's raw issues (those also carry Zod's extra issue fields).
    - Field map
      - `formErrors` (list of string, optional)
      - `fieldErrors` (map from string to list of string, optional)
  - `metadata` (map from string to any, optional) — Structured detail exposed for a small allowlist of codes only — for example `BILLING_ERROR` carries `limit`, `current` and `tier` (resource caps) or `tier` and `feature` (feature gates).

### 429 Too Many Requests Error

A request limiter was exceeded, or the daily email send cap is used up.

- `error` (object, required) — The error object. Always has `code` and `message`.
  - `code` (string, required) — Stable machine-readable error code (for example `VALIDATION_FAILED`, `UNAUTHORIZED`, `FORBIDDEN`, `NOT_FOUND`, `BILLING_ERROR`, `COMPLIANCE_BLOCKED`, `RATE_LIMIT_EXCEEDED`, `INTERNAL_ERROR`). Switch on this, not on `message`. See [Errors](/errors).
  - `message` (string, required) — Human-readable explanation. English or Spanish depending on the route; may change without notice.
  - `details` (object or list of object, optional) — Present on `VALIDATION_FAILED` only. Its shape depends on how the route validates: * a field map, either Zod's `flatten()` output (`{ "formErrors": [], "fieldErrors": { "name": ["..."] } }`) or just its `fieldErrors` part (`{ "name": ["..."] }`); * an issue list, where each issue has at least `path`, `message` and `code`. `path` is a dot-separated string on routes that let the schema throw, and an array of keys on routes that forward Zod's raw issues (those also carry Zod's extra issue fields).
    - Field map
      - `formErrors` (list of string, optional)
      - `fieldErrors` (map from string to list of string, optional)
  - `metadata` (map from string to any, optional) — Structured detail exposed for a small allowlist of codes only — for example `BILLING_ERROR` carries `limit`, `current` and `tier` (resource caps) or `tier` and `feature` (feature gates).

### 500 Internal Server Error

The mailbox provider failed to deliver. The daily cap unit is refunded, and the email may or may not have been sent.

- `error` (object, required) — The error object. Always has `code` and `message`.
  - `code` (string, required) — Stable machine-readable error code (for example `VALIDATION_FAILED`, `UNAUTHORIZED`, `FORBIDDEN`, `NOT_FOUND`, `BILLING_ERROR`, `COMPLIANCE_BLOCKED`, `RATE_LIMIT_EXCEEDED`, `INTERNAL_ERROR`). Switch on this, not on `message`. See [Errors](/errors).
  - `message` (string, required) — Human-readable explanation. English or Spanish depending on the route; may change without notice.
  - `details` (object or list of object, optional) — Present on `VALIDATION_FAILED` only. Its shape depends on how the route validates: * a field map, either Zod's `flatten()` output (`{ "formErrors": [], "fieldErrors": { "name": ["..."] } }`) or just its `fieldErrors` part (`{ "name": ["..."] }`); * an issue list, where each issue has at least `path`, `message` and `code`. `path` is a dot-separated string on routes that let the schema throw, and an array of keys on routes that forward Zod's raw issues (those also carry Zod's extra issue fields).
    - Field map
      - `formErrors` (list of string, optional)
      - `fieldErrors` (map from string to list of string, optional)
  - `metadata` (map from string to any, optional) — Structured detail exposed for a small allowlist of codes only — for example `BILLING_ERROR` carries `limit`, `current` and `tier` (resource caps) or `tier` and `feature` (feature gates).

## Examples

### Email_postEmailSend_example

**Request**

```json
undefined
```

**Response**

```json
{
  "data": {
    "sent": true,
    "to": "maria.rojas@correo.co"
  }
}
```

**SDK Code**

```python Email_postEmailSend_example
import requests

url = "https://api.jelliu.co/api/email/send"

headers = {"Authorization": "Bearer <token>"}

response = requests.post(url, headers=headers)

print(response.json())
```

```javascript Email_postEmailSend_example
const url = 'https://api.jelliu.co/api/email/send';
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Email_postEmailSend_example
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.jelliu.co/api/email/send"

	req, _ := http.NewRequest("POST", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Email_postEmailSend_example
require 'uri'
require 'net/http'

url = URI("https://api.jelliu.co/api/email/send")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java Email_postEmailSend_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.jelliu.co/api/email/send")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php Email_postEmailSend_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.jelliu.co/api/email/send', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp Email_postEmailSend_example
using RestSharp;

var client = new RestClient("https://api.jelliu.co/api/email/send");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift Email_postEmailSend_example
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.jelliu.co/api/email/send")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### New email

**Request**

```json
{
  "contactId": "7d6c5b4a-3f2e-4d1c-8b9a-0e1f2a3b4c5d",
  "subject": "Cotización solicitada",
  "message": "Hola María, te comparto el detalle de la cotización para 40 unidades que conversamos. Quedo atenta, Laura."
}
```

**Response**

```json
{
  "data": {
    "sent": true,
    "to": "maria.rojas@correo.co"
  }
}
```

**SDK Code**

```python New email
import requests

url = "https://api.jelliu.co/api/email/send"

payload = {
    "contactId": "7d6c5b4a-3f2e-4d1c-8b9a-0e1f2a3b4c5d",
    "subject": "Cotización solicitada",
    "message": "Hola María, te comparto el detalle de la cotización para 40 unidades que conversamos. Quedo atenta, Laura."
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript New email
const url = 'https://api.jelliu.co/api/email/send';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"contactId":"7d6c5b4a-3f2e-4d1c-8b9a-0e1f2a3b4c5d","subject":"Cotización solicitada","message":"Hola María, te comparto el detalle de la cotización para 40 unidades que conversamos. Quedo atenta, Laura."}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go New email
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.jelliu.co/api/email/send"

	payload := strings.NewReader("{\n  \"contactId\": \"7d6c5b4a-3f2e-4d1c-8b9a-0e1f2a3b4c5d\",\n  \"subject\": \"Cotización solicitada\",\n  \"message\": \"Hola María, te comparto el detalle de la cotización para 40 unidades que conversamos. Quedo atenta, Laura.\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby New email
require 'uri'
require 'net/http'

url = URI("https://api.jelliu.co/api/email/send")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"contactId\": \"7d6c5b4a-3f2e-4d1c-8b9a-0e1f2a3b4c5d\",\n  \"subject\": \"Cotización solicitada\",\n  \"message\": \"Hola María, te comparto el detalle de la cotización para 40 unidades que conversamos. Quedo atenta, Laura.\"\n}"

response = http.request(request)
puts response.read_body
```

```java New email
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.jelliu.co/api/email/send")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"contactId\": \"7d6c5b4a-3f2e-4d1c-8b9a-0e1f2a3b4c5d\",\n  \"subject\": \"Cotización solicitada\",\n  \"message\": \"Hola María, te comparto el detalle de la cotización para 40 unidades que conversamos. Quedo atenta, Laura.\"\n}")
  .asString();
```

```php New email
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.jelliu.co/api/email/send', [
  'body' => '{
  "contactId": "7d6c5b4a-3f2e-4d1c-8b9a-0e1f2a3b4c5d",
  "subject": "Cotización solicitada",
  "message": "Hola María, te comparto el detalle de la cotización para 40 unidades que conversamos. Quedo atenta, Laura."
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp New email
using RestSharp;

var client = new RestClient("https://api.jelliu.co/api/email/send");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"contactId\": \"7d6c5b4a-3f2e-4d1c-8b9a-0e1f2a3b4c5d\",\n  \"subject\": \"Cotización solicitada\",\n  \"message\": \"Hola María, te comparto el detalle de la cotización para 40 unidades que conversamos. Quedo atenta, Laura.\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift New email
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "contactId": "7d6c5b4a-3f2e-4d1c-8b9a-0e1f2a3b4c5d",
  "subject": "Cotización solicitada",
  "message": "Hola María, te comparto el detalle de la cotización para 40 unidades que conversamos. Quedo atenta, Laura."
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.jelliu.co/api/email/send")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Reply inside an existing Gmail thread

**Request**

```json
{
  "contactId": "7d6c5b4a-3f2e-4d1c-8b9a-0e1f2a3b4c5d",
  "subject": "Re: Cotización solicitada",
  "message": "Hola María, sí, el precio incluye el envío a Medellín.",
  "inReplyTo": "191e4c2a7b3d5f80"
}
```

**Response**

```json
{
  "data": {
    "sent": true,
    "to": "maria.rojas@correo.co"
  }
}
```

**SDK Code**

```python Reply inside an existing Gmail thread
import requests

url = "https://api.jelliu.co/api/email/send"

payload = {
    "contactId": "7d6c5b4a-3f2e-4d1c-8b9a-0e1f2a3b4c5d",
    "subject": "Re: Cotización solicitada",
    "message": "Hola María, sí, el precio incluye el envío a Medellín.",
    "inReplyTo": "191e4c2a7b3d5f80"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Reply inside an existing Gmail thread
const url = 'https://api.jelliu.co/api/email/send';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"contactId":"7d6c5b4a-3f2e-4d1c-8b9a-0e1f2a3b4c5d","subject":"Re: Cotización solicitada","message":"Hola María, sí, el precio incluye el envío a Medellín.","inReplyTo":"191e4c2a7b3d5f80"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Reply inside an existing Gmail thread
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.jelliu.co/api/email/send"

	payload := strings.NewReader("{\n  \"contactId\": \"7d6c5b4a-3f2e-4d1c-8b9a-0e1f2a3b4c5d\",\n  \"subject\": \"Re: Cotización solicitada\",\n  \"message\": \"Hola María, sí, el precio incluye el envío a Medellín.\",\n  \"inReplyTo\": \"191e4c2a7b3d5f80\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Reply inside an existing Gmail thread
require 'uri'
require 'net/http'

url = URI("https://api.jelliu.co/api/email/send")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"contactId\": \"7d6c5b4a-3f2e-4d1c-8b9a-0e1f2a3b4c5d\",\n  \"subject\": \"Re: Cotización solicitada\",\n  \"message\": \"Hola María, sí, el precio incluye el envío a Medellín.\",\n  \"inReplyTo\": \"191e4c2a7b3d5f80\"\n}"

response = http.request(request)
puts response.read_body
```

```java Reply inside an existing Gmail thread
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.jelliu.co/api/email/send")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"contactId\": \"7d6c5b4a-3f2e-4d1c-8b9a-0e1f2a3b4c5d\",\n  \"subject\": \"Re: Cotización solicitada\",\n  \"message\": \"Hola María, sí, el precio incluye el envío a Medellín.\",\n  \"inReplyTo\": \"191e4c2a7b3d5f80\"\n}")
  .asString();
```

```php Reply inside an existing Gmail thread
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.jelliu.co/api/email/send', [
  'body' => '{
  "contactId": "7d6c5b4a-3f2e-4d1c-8b9a-0e1f2a3b4c5d",
  "subject": "Re: Cotización solicitada",
  "message": "Hola María, sí, el precio incluye el envío a Medellín.",
  "inReplyTo": "191e4c2a7b3d5f80"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Reply inside an existing Gmail thread
using RestSharp;

var client = new RestClient("https://api.jelliu.co/api/email/send");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"contactId\": \"7d6c5b4a-3f2e-4d1c-8b9a-0e1f2a3b4c5d\",\n  \"subject\": \"Re: Cotización solicitada\",\n  \"message\": \"Hola María, sí, el precio incluye el envío a Medellín.\",\n  \"inReplyTo\": \"191e4c2a7b3d5f80\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Reply inside an existing Gmail thread
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "contactId": "7d6c5b4a-3f2e-4d1c-8b9a-0e1f2a3b4c5d",
  "subject": "Re: Cotización solicitada",
  "message": "Hola María, sí, el precio incluye el envío a Medellín.",
  "inReplyTo": "191e4c2a7b3d5f80"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.jelliu.co/api/email/send")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```