> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://docs.agentmail.to/llms.txt. For full content including API reference and SDK examples, see https://docs.agentmail.to/llms-full.txt.

# Send Message

POST https://api.agentmail.to/v0/inboxes/{inbox_id}/messages/send
Content-Type: application/json

**CLI:**
```bash
agentmail inboxes:messages send --inbox-id <inbox_id> --to recipient@example.com --subject "Hello" --text "Body"
```

Reference: https://docs.agentmail.to/api-reference/inboxes/messages/send

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: api
  version: 1.0.0
paths:
  /v0/inboxes/{inbox_id}/messages/send:
    post:
      operationId: send
      summary: Send Message
      description: >-
        **CLI:**

        ```bash

        agentmail inboxes:messages send --inbox-id <inbox_id> --to
        recipient@example.com --subject "Hello" --text "Body"

        ```
      tags:
        - subpackage_inboxes.subpackage_inboxes/messages
      parameters:
        - name: inbox_id
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/type_inboxes:InboxId'
        - name: Authorization
          in: header
          description: Bearer authentication
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Response with status 200
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_messages:SendMessageResponse'
        '400':
          description: Error response with status 400
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_:ValidationErrorResponse'
        '403':
          description: Error response with status 403
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_:ErrorResponse'
        '404':
          description: Error response with status 404
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_:ErrorResponse'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/type_messages:SendMessageRequest'
servers:
  - url: https://api.agentmail.to
    description: prod
  - url: https://x402.api.agentmail.to
    description: prod-x402
  - url: https://mpp.api.agentmail.to
    description: prod-mpp
  - url: https://api.agentmail.eu
    description: eu-prod
components:
  schemas:
    type_inboxes:InboxId:
      type: string
      description: The ID of the inbox.
      title: InboxId
    type_messages:MessageLabels:
      type: array
      items:
        type: string
      description: Labels of message.
      title: MessageLabels
    type_messages:Addresses:
      oneOf:
        - type: string
        - type: array
          items:
            type: string
      title: Addresses
    type_messages:SendMessageReplyTo:
      $ref: '#/components/schemas/type_messages:Addresses'
      description: Reply-to address or addresses.
      title: SendMessageReplyTo
    type_messages:SendMessageTo:
      $ref: '#/components/schemas/type_messages:Addresses'
      description: Recipient address or addresses.
      title: SendMessageTo
    type_messages:SendMessageCc:
      $ref: '#/components/schemas/type_messages:Addresses'
      description: CC recipient address or addresses.
      title: SendMessageCc
    type_messages:SendMessageBcc:
      $ref: '#/components/schemas/type_messages:Addresses'
      description: BCC recipient address or addresses.
      title: SendMessageBcc
    type_messages:MessageSubject:
      type: string
      description: Subject of message.
      title: MessageSubject
    type_messages:MessageText:
      type: string
      description: Plain text body of message.
      title: MessageText
    type_messages:MessageHtml:
      type: string
      description: HTML body of message.
      title: MessageHtml
    type_attachments:AttachmentFilename:
      type: string
      description: Filename of attachment.
      title: AttachmentFilename
    type_attachments:AttachmentContentType:
      type: string
      description: Content type of attachment.
      title: AttachmentContentType
    type_attachments:AttachmentContentDisposition:
      type: string
      enum:
        - inline
        - attachment
      description: Content disposition of attachment.
      title: AttachmentContentDisposition
    type_attachments:AttachmentContentId:
      type: string
      description: Content ID of attachment.
      title: AttachmentContentId
    type_attachments:SendAttachment:
      type: object
      properties:
        filename:
          $ref: '#/components/schemas/type_attachments:AttachmentFilename'
        content_type:
          $ref: '#/components/schemas/type_attachments:AttachmentContentType'
        content_disposition:
          $ref: '#/components/schemas/type_attachments:AttachmentContentDisposition'
        content_id:
          $ref: '#/components/schemas/type_attachments:AttachmentContentId'
        content:
          type: string
          description: Base64 encoded content of attachment.
        url:
          type: string
          description: URL to the attachment.
      title: SendAttachment
    type_messages:SendMessageAttachments:
      type: array
      items:
        $ref: '#/components/schemas/type_attachments:SendAttachment'
      description: Attachments to include in message.
      title: SendMessageAttachments
    type_messages:SendMessageHeaders:
      type: object
      additionalProperties:
        type: string
      description: Headers to include in message.
      title: SendMessageHeaders
    type_messages:SendMessageRequest:
      type: object
      properties:
        labels:
          $ref: '#/components/schemas/type_messages:MessageLabels'
        reply_to:
          $ref: '#/components/schemas/type_messages:SendMessageReplyTo'
        to:
          $ref: '#/components/schemas/type_messages:SendMessageTo'
        cc:
          $ref: '#/components/schemas/type_messages:SendMessageCc'
        bcc:
          $ref: '#/components/schemas/type_messages:SendMessageBcc'
        subject:
          $ref: '#/components/schemas/type_messages:MessageSubject'
        text:
          $ref: '#/components/schemas/type_messages:MessageText'
        html:
          $ref: '#/components/schemas/type_messages:MessageHtml'
        attachments:
          $ref: '#/components/schemas/type_messages:SendMessageAttachments'
        headers:
          $ref: '#/components/schemas/type_messages:SendMessageHeaders'
      title: SendMessageRequest
    type_messages:MessageId:
      type: string
      description: ID of message.
      title: MessageId
    type_threads:ThreadId:
      type: string
      description: ID of thread.
      title: ThreadId
    type_messages:SendMessageResponse:
      type: object
      properties:
        message_id:
          $ref: '#/components/schemas/type_messages:MessageId'
        thread_id:
          $ref: '#/components/schemas/type_threads:ThreadId'
      required:
        - message_id
        - thread_id
      title: SendMessageResponse
    type_:ErrorName:
      type: string
      description: Name of error.
      title: ErrorName
    type_:ValidationErrorResponse:
      type: object
      properties:
        name:
          $ref: '#/components/schemas/type_:ErrorName'
        errors:
          description: Validation errors.
      required:
        - name
        - errors
      title: ValidationErrorResponse
    type_:ErrorMessage:
      type: string
      description: Error message.
      title: ErrorMessage
    type_:ErrorResponse:
      type: object
      properties:
        name:
          $ref: '#/components/schemas/type_:ErrorName'
        message:
          $ref: '#/components/schemas/type_:ErrorMessage'
      required:
        - name
        - message
      title: ErrorResponse
  securitySchemes:
    Bearer:
      type: http
      scheme: bearer

```

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "message_id": "message_id",
  "thread_id": "thread_id"
}
```

**SDK Code**

```typescript
import { AgentMailClient } from "agentmail";

async function main() {
    const client = new AgentMailClient({
        apiKey: "YOUR_TOKEN_HERE",
    });
    await client.inboxes.messages.send("inbox_id", {});
}
main();

```

```python
from agentmail import AgentMail

client = AgentMail(
    api_key="YOUR_TOKEN_HERE",
)

client.inboxes.messages.send(
    inbox_id="inbox_id",
)

```

```go
package main

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

func main() {

	url := "https://api.agentmail.to/v0/inboxes/inbox_id/messages/send"

	payload := strings.NewReader("{}")

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

	req.Header.Add("Authorization", "Bearer <api_key>")
	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
require 'uri'
require 'net/http'

url = URI("https://api.agentmail.to/v0/inboxes/inbox_id/messages/send")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <api_key>'
request["Content-Type"] = 'application/json'
request.body = "{}"

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

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

HttpResponse<String> response = Unirest.post("https://api.agentmail.to/v0/inboxes/inbox_id/messages/send")
  .header("Authorization", "Bearer <api_key>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.agentmail.to/v0/inboxes/inbox_id/messages/send', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <api_key>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.agentmail.to/v0/inboxes/inbox_id/messages/send");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <api_key>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <api_key>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/inboxes/inbox_id/messages/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()
```