Appearance
Drafts
Fresh 🌱AgentMail REST API reference for Drafts. Base URL
https://api.agentmail.to/v0. Authenticate withAuthorization: Bearer <API_KEY>.
Create Draft
POST https://api.agentmail.to/v0/inboxes/{inbox_id}/drafts Content-Type: application/json
CLI:
bash
agentmail inboxes:drafts create --inbox-id <inbox_id> --to recipient@example.com --subject "Draft subject" --text "Draft body"OpenAPI Specification
yaml
openapi: 3.1.0
info:
title: api
version: 1.0.0
paths:
/v0/inboxes/{inbox_id}/drafts:
post:
operationId: create
summary: Create Draft
description: >-
**CLI:**
```bash
agentmail inboxes:drafts create --inbox-id <inbox_id> --to
recipient@example.com --subject "Draft subject" --text "Draft body"
```
tags:
- subpackage_inboxes.subpackage_inboxes/drafts
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_drafts:Draft'
'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_drafts:CreateDraftRequest'
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_drafts:DraftLabels:
type: array
items:
type: string
description: Labels of draft.
title: DraftLabels
type_drafts:DraftReplyTo:
type: array
items:
type: string
description: >-
Reply-to addresses. In format `username@domain.com` or `Display Name
<username@domain.com>`.
title: DraftReplyTo
type_drafts:DraftTo:
type: array
items:
type: string
description: >-
Addresses of recipients. In format `username@domain.com` or `Display
Name <username@domain.com>`.
title: DraftTo
type_drafts:DraftCc:
type: array
items:
type: string
description: >-
Addresses of CC recipients. In format `username@domain.com` or `Display
Name <username@domain.com>`.
title: DraftCc
type_drafts:DraftBcc:
type: array
items:
type: string
description: >-
Addresses of BCC recipients. In format `username@domain.com` or `Display
Name <username@domain.com>`.
title: DraftBcc
type_drafts:DraftSubject:
type: string
description: Subject of draft.
title: DraftSubject
type_drafts:DraftText:
type: string
description: Plain text body of draft.
title: DraftText
type_drafts:DraftHtml:
type: string
description: HTML body of draft.
title: DraftHtml
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_drafts:DraftInReplyTo:
type: string
description: ID of message being replied to.
title: DraftInReplyTo
type_drafts:DraftSendAt:
type: string
format: date-time
description: Time at which to schedule send draft.
title: DraftSendAt
type_drafts:DraftClientId:
type: string
description: Client ID of draft.
title: DraftClientId
type_drafts:CreateDraftRequest:
type: object
properties:
labels:
$ref: '#/components/schemas/type_drafts:DraftLabels'
reply_to:
$ref: '#/components/schemas/type_drafts:DraftReplyTo'
to:
$ref: '#/components/schemas/type_drafts:DraftTo'
cc:
$ref: '#/components/schemas/type_drafts:DraftCc'
bcc:
$ref: '#/components/schemas/type_drafts:DraftBcc'
subject:
$ref: '#/components/schemas/type_drafts:DraftSubject'
text:
$ref: '#/components/schemas/type_drafts:DraftText'
html:
$ref: '#/components/schemas/type_drafts:DraftHtml'
attachments:
type: array
items:
$ref: '#/components/schemas/type_attachments:SendAttachment'
description: Attachments to include in draft.
in_reply_to:
$ref: '#/components/schemas/type_drafts:DraftInReplyTo'
send_at:
$ref: '#/components/schemas/type_drafts:DraftSendAt'
client_id:
$ref: '#/components/schemas/type_drafts:DraftClientId'
title: CreateDraftRequest
type_drafts:DraftId:
type: string
description: ID of draft.
title: DraftId
type_drafts:DraftPreview:
type: string
description: Text preview of draft.
title: DraftPreview
type_attachments:AttachmentId:
type: string
description: ID of attachment.
title: AttachmentId
type_attachments:AttachmentSize:
type: integer
description: Size of attachment in bytes.
title: AttachmentSize
type_attachments:Attachment:
type: object
properties:
attachment_id:
$ref: '#/components/schemas/type_attachments:AttachmentId'
filename:
$ref: '#/components/schemas/type_attachments:AttachmentFilename'
size:
$ref: '#/components/schemas/type_attachments:AttachmentSize'
content_type:
$ref: '#/components/schemas/type_attachments:AttachmentContentType'
content_disposition:
$ref: '#/components/schemas/type_attachments:AttachmentContentDisposition'
content_id:
$ref: '#/components/schemas/type_attachments:AttachmentContentId'
required:
- attachment_id
- size
title: Attachment
type_drafts:DraftAttachments:
type: array
items:
$ref: '#/components/schemas/type_attachments:Attachment'
description: Attachments in draft.
title: DraftAttachments
type_drafts:DraftSendStatus:
type: string
enum:
- scheduled
- sending
- failed
description: Schedule send status of draft.
title: DraftSendStatus
type_drafts:DraftUpdatedAt:
type: string
format: date-time
description: Time at which draft was last updated.
title: DraftUpdatedAt
type_drafts:Draft:
type: object
properties:
inbox_id:
$ref: '#/components/schemas/type_inboxes:InboxId'
draft_id:
$ref: '#/components/schemas/type_drafts:DraftId'
client_id:
$ref: '#/components/schemas/type_drafts:DraftClientId'
labels:
$ref: '#/components/schemas/type_drafts:DraftLabels'
reply_to:
$ref: '#/components/schemas/type_drafts:DraftReplyTo'
to:
$ref: '#/components/schemas/type_drafts:DraftTo'
cc:
$ref: '#/components/schemas/type_drafts:DraftCc'
bcc:
$ref: '#/components/schemas/type_drafts:DraftBcc'
subject:
$ref: '#/components/schemas/type_drafts:DraftSubject'
preview:
$ref: '#/components/schemas/type_drafts:DraftPreview'
text:
$ref: '#/components/schemas/type_drafts:DraftText'
html:
$ref: '#/components/schemas/type_drafts:DraftHtml'
attachments:
$ref: '#/components/schemas/type_drafts:DraftAttachments'
in_reply_to:
$ref: '#/components/schemas/type_drafts:DraftInReplyTo'
references:
type: array
items:
type: string
description: IDs of previous messages in thread.
send_status:
$ref: '#/components/schemas/type_drafts:DraftSendStatus'
send_at:
$ref: '#/components/schemas/type_drafts:DraftSendAt'
updated_at:
$ref: '#/components/schemas/type_drafts:DraftUpdatedAt'
created_at:
type: string
format: date-time
description: Time at which draft was created.
required:
- inbox_id
- draft_id
- labels
- updated_at
- created_at
title: Draft
type_:ErrorName:
type: string
description: Name of error.
title: ErrorName
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: bearerExamples
Request
json
{}Response
json
{
"inbox_id": "inbox_id",
"draft_id": "draft_id",
"labels": [
"labels",
"labels"
],
"updated_at": "2024-01-15T09:30:00Z",
"created_at": "2024-01-15T09:30:00Z",
"client_id": "client_id",
"reply_to": [
"reply_to",
"reply_to"
],
"to": [
"to",
"to"
],
"cc": [
"cc",
"cc"
],
"bcc": [
"bcc",
"bcc"
],
"subject": "subject",
"preview": "preview",
"text": "text",
"html": "html",
"attachments": [
{
"attachment_id": "attachment_id",
"size": 1,
"filename": "filename",
"content_type": "content_type",
"content_disposition": "inline",
"content_id": "content_id"
},
{
"attachment_id": "attachment_id",
"size": 1,
"filename": "filename",
"content_type": "content_type",
"content_disposition": "inline",
"content_id": "content_id"
}
],
"in_reply_to": "in_reply_to",
"references": [
"references",
"references"
],
"send_status": "scheduled",
"send_at": "2024-01-15T09:30:00Z"
}SDK Code
typescript
import { AgentMailClient } from "agentmail";
async function main() {
const client = new AgentMailClient({
apiKey: "YOUR_TOKEN_HERE",
});
await client.inboxes.drafts.create("inbox_id", {});
}
main();python
from agentmail import AgentMail
client = AgentMail(
api_key="YOUR_TOKEN_HERE",
)
client.inboxes.drafts.create(
inbox_id="inbox_id",
)go
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.agentmail.to/v0/inboxes/inbox_id/drafts"
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/drafts")
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_bodyjava
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/drafts")
.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/drafts', [
'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/drafts");
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/drafts")! 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()Get Draft
GET https://api.agentmail.to/v0/inboxes/{inbox_id}/drafts/{draft_id}
CLI:
bash
agentmail inboxes:drafts get --inbox-id <inbox_id> --draft-id <draft_id>OpenAPI Specification
yaml
openapi: 3.1.0
info:
title: api
version: 1.0.0
paths:
/v0/inboxes/{inbox_id}/drafts/{draft_id}:
get:
operationId: get
summary: Get Draft
description: |-
**CLI:**
```bash
agentmail inboxes:drafts get --inbox-id <inbox_id> --draft-id <draft_id>
```
tags:
- subpackage_inboxes.subpackage_inboxes/drafts
parameters:
- name: inbox_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_inboxes:InboxId'
- name: draft_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_drafts:DraftId'
- 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_drafts:Draft'
'404':
description: Error response with status 404
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ErrorResponse'
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_drafts:DraftId:
type: string
description: ID of draft.
title: DraftId
type_drafts:DraftClientId:
type: string
description: Client ID of draft.
title: DraftClientId
type_drafts:DraftLabels:
type: array
items:
type: string
description: Labels of draft.
title: DraftLabels
type_drafts:DraftReplyTo:
type: array
items:
type: string
description: >-
Reply-to addresses. In format `username@domain.com` or `Display Name
<username@domain.com>`.
title: DraftReplyTo
type_drafts:DraftTo:
type: array
items:
type: string
description: >-
Addresses of recipients. In format `username@domain.com` or `Display
Name <username@domain.com>`.
title: DraftTo
type_drafts:DraftCc:
type: array
items:
type: string
description: >-
Addresses of CC recipients. In format `username@domain.com` or `Display
Name <username@domain.com>`.
title: DraftCc
type_drafts:DraftBcc:
type: array
items:
type: string
description: >-
Addresses of BCC recipients. In format `username@domain.com` or `Display
Name <username@domain.com>`.
title: DraftBcc
type_drafts:DraftSubject:
type: string
description: Subject of draft.
title: DraftSubject
type_drafts:DraftPreview:
type: string
description: Text preview of draft.
title: DraftPreview
type_drafts:DraftText:
type: string
description: Plain text body of draft.
title: DraftText
type_drafts:DraftHtml:
type: string
description: HTML body of draft.
title: DraftHtml
type_attachments:AttachmentId:
type: string
description: ID of attachment.
title: AttachmentId
type_attachments:AttachmentFilename:
type: string
description: Filename of attachment.
title: AttachmentFilename
type_attachments:AttachmentSize:
type: integer
description: Size of attachment in bytes.
title: AttachmentSize
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:Attachment:
type: object
properties:
attachment_id:
$ref: '#/components/schemas/type_attachments:AttachmentId'
filename:
$ref: '#/components/schemas/type_attachments:AttachmentFilename'
size:
$ref: '#/components/schemas/type_attachments:AttachmentSize'
content_type:
$ref: '#/components/schemas/type_attachments:AttachmentContentType'
content_disposition:
$ref: '#/components/schemas/type_attachments:AttachmentContentDisposition'
content_id:
$ref: '#/components/schemas/type_attachments:AttachmentContentId'
required:
- attachment_id
- size
title: Attachment
type_drafts:DraftAttachments:
type: array
items:
$ref: '#/components/schemas/type_attachments:Attachment'
description: Attachments in draft.
title: DraftAttachments
type_drafts:DraftInReplyTo:
type: string
description: ID of message being replied to.
title: DraftInReplyTo
type_drafts:DraftSendStatus:
type: string
enum:
- scheduled
- sending
- failed
description: Schedule send status of draft.
title: DraftSendStatus
type_drafts:DraftSendAt:
type: string
format: date-time
description: Time at which to schedule send draft.
title: DraftSendAt
type_drafts:DraftUpdatedAt:
type: string
format: date-time
description: Time at which draft was last updated.
title: DraftUpdatedAt
type_drafts:Draft:
type: object
properties:
inbox_id:
$ref: '#/components/schemas/type_inboxes:InboxId'
draft_id:
$ref: '#/components/schemas/type_drafts:DraftId'
client_id:
$ref: '#/components/schemas/type_drafts:DraftClientId'
labels:
$ref: '#/components/schemas/type_drafts:DraftLabels'
reply_to:
$ref: '#/components/schemas/type_drafts:DraftReplyTo'
to:
$ref: '#/components/schemas/type_drafts:DraftTo'
cc:
$ref: '#/components/schemas/type_drafts:DraftCc'
bcc:
$ref: '#/components/schemas/type_drafts:DraftBcc'
subject:
$ref: '#/components/schemas/type_drafts:DraftSubject'
preview:
$ref: '#/components/schemas/type_drafts:DraftPreview'
text:
$ref: '#/components/schemas/type_drafts:DraftText'
html:
$ref: '#/components/schemas/type_drafts:DraftHtml'
attachments:
$ref: '#/components/schemas/type_drafts:DraftAttachments'
in_reply_to:
$ref: '#/components/schemas/type_drafts:DraftInReplyTo'
references:
type: array
items:
type: string
description: IDs of previous messages in thread.
send_status:
$ref: '#/components/schemas/type_drafts:DraftSendStatus'
send_at:
$ref: '#/components/schemas/type_drafts:DraftSendAt'
updated_at:
$ref: '#/components/schemas/type_drafts:DraftUpdatedAt'
created_at:
type: string
format: date-time
description: Time at which draft was created.
required:
- inbox_id
- draft_id
- labels
- updated_at
- created_at
title: Draft
type_:ErrorName:
type: string
description: Name of error.
title: ErrorName
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: bearerExamples
Response
json
{
"inbox_id": "inbox_id",
"draft_id": "draft_id",
"labels": [
"labels",
"labels"
],
"updated_at": "2024-01-15T09:30:00Z",
"created_at": "2024-01-15T09:30:00Z",
"client_id": "client_id",
"reply_to": [
"reply_to",
"reply_to"
],
"to": [
"to",
"to"
],
"cc": [
"cc",
"cc"
],
"bcc": [
"bcc",
"bcc"
],
"subject": "subject",
"preview": "preview",
"text": "text",
"html": "html",
"attachments": [
{
"attachment_id": "attachment_id",
"size": 1,
"filename": "filename",
"content_type": "content_type",
"content_disposition": "inline",
"content_id": "content_id"
},
{
"attachment_id": "attachment_id",
"size": 1,
"filename": "filename",
"content_type": "content_type",
"content_disposition": "inline",
"content_id": "content_id"
}
],
"in_reply_to": "in_reply_to",
"references": [
"references",
"references"
],
"send_status": "scheduled",
"send_at": "2024-01-15T09:30:00Z"
}SDK Code
typescript
import { AgentMailClient } from "agentmail";
async function main() {
const client = new AgentMailClient({
apiKey: "YOUR_TOKEN_HERE",
});
await client.inboxes.drafts.get("inbox_id", "draft_id");
}
main();python
from agentmail import AgentMail
client = AgentMail(
api_key="YOUR_TOKEN_HERE",
)
client.inboxes.drafts.get(
inbox_id="inbox_id",
draft_id="draft_id",
)go
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.agentmail.to/v0/inboxes/inbox_id/drafts/draft_id"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <api_key>")
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/drafts/draft_id")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <api_key>'
response = http.request(request)
puts response.read_bodyjava
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/inboxes/inbox_id/drafts/draft_id")
.header("Authorization", "Bearer <api_key>")
.asString();php
<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'https://api.agentmail.to/v0/inboxes/inbox_id/drafts/draft_id', [
'headers' => [
'Authorization' => 'Bearer <api_key>',
],
]);
echo $response->getBody();csharp
using RestSharp;
var client = new RestClient("https://api.agentmail.to/v0/inboxes/inbox_id/drafts/draft_id");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <api_key>");
IRestResponse response = client.Execute(request);swift
import Foundation
let headers = ["Authorization": "Bearer <api_key>"]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/inboxes/inbox_id/drafts/draft_id")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
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()List Drafts
GET https://api.agentmail.to/v0/inboxes/{inbox_id}/drafts
CLI:
bash
agentmail inboxes:drafts list --inbox-id <inbox_id>OpenAPI Specification
yaml
openapi: 3.1.0
info:
title: api
version: 1.0.0
paths:
/v0/inboxes/{inbox_id}/drafts:
get:
operationId: list
summary: List Drafts
description: |-
**CLI:**
```bash
agentmail inboxes:drafts list --inbox-id <inbox_id>
```
tags:
- subpackage_inboxes.subpackage_inboxes/drafts
parameters:
- name: inbox_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_inboxes:InboxId'
- name: limit
in: query
required: false
schema:
$ref: '#/components/schemas/type_:Limit'
- name: page_token
in: query
required: false
schema:
$ref: '#/components/schemas/type_:PageToken'
- name: labels
in: query
required: false
schema:
$ref: '#/components/schemas/type_:Labels'
- name: before
in: query
required: false
schema:
$ref: '#/components/schemas/type_:Before'
- name: after
in: query
required: false
schema:
$ref: '#/components/schemas/type_:After'
- name: ascending
in: query
required: false
schema:
$ref: '#/components/schemas/type_:Ascending'
- 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_drafts:ListDraftsResponse'
'404':
description: Error response with status 404
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ErrorResponse'
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_:Limit:
type: integer
description: Limit of number of items returned.
title: Limit
type_:PageToken:
type: string
description: Page token for pagination.
title: PageToken
type_:Labels:
type: array
items:
type: string
description: Labels to filter by.
title: Labels
type_:Before:
type: string
format: date-time
description: Timestamp before which to filter by.
title: Before
type_:After:
type: string
format: date-time
description: Timestamp after which to filter by.
title: After
type_:Ascending:
type: boolean
description: Sort in ascending temporal order.
title: Ascending
type_:Count:
type: integer
description: Number of items returned.
title: Count
type_drafts:DraftId:
type: string
description: ID of draft.
title: DraftId
type_drafts:DraftLabels:
type: array
items:
type: string
description: Labels of draft.
title: DraftLabels
type_drafts:DraftTo:
type: array
items:
type: string
description: >-
Addresses of recipients. In format `username@domain.com` or `Display
Name <username@domain.com>`.
title: DraftTo
type_drafts:DraftCc:
type: array
items:
type: string
description: >-
Addresses of CC recipients. In format `username@domain.com` or `Display
Name <username@domain.com>`.
title: DraftCc
type_drafts:DraftBcc:
type: array
items:
type: string
description: >-
Addresses of BCC recipients. In format `username@domain.com` or `Display
Name <username@domain.com>`.
title: DraftBcc
type_drafts:DraftSubject:
type: string
description: Subject of draft.
title: DraftSubject
type_drafts:DraftPreview:
type: string
description: Text preview of draft.
title: DraftPreview
type_attachments:AttachmentId:
type: string
description: ID of attachment.
title: AttachmentId
type_attachments:AttachmentFilename:
type: string
description: Filename of attachment.
title: AttachmentFilename
type_attachments:AttachmentSize:
type: integer
description: Size of attachment in bytes.
title: AttachmentSize
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:Attachment:
type: object
properties:
attachment_id:
$ref: '#/components/schemas/type_attachments:AttachmentId'
filename:
$ref: '#/components/schemas/type_attachments:AttachmentFilename'
size:
$ref: '#/components/schemas/type_attachments:AttachmentSize'
content_type:
$ref: '#/components/schemas/type_attachments:AttachmentContentType'
content_disposition:
$ref: '#/components/schemas/type_attachments:AttachmentContentDisposition'
content_id:
$ref: '#/components/schemas/type_attachments:AttachmentContentId'
required:
- attachment_id
- size
title: Attachment
type_drafts:DraftAttachments:
type: array
items:
$ref: '#/components/schemas/type_attachments:Attachment'
description: Attachments in draft.
title: DraftAttachments
type_drafts:DraftInReplyTo:
type: string
description: ID of message being replied to.
title: DraftInReplyTo
type_drafts:DraftSendStatus:
type: string
enum:
- scheduled
- sending
- failed
description: Schedule send status of draft.
title: DraftSendStatus
type_drafts:DraftSendAt:
type: string
format: date-time
description: Time at which to schedule send draft.
title: DraftSendAt
type_drafts:DraftUpdatedAt:
type: string
format: date-time
description: Time at which draft was last updated.
title: DraftUpdatedAt
type_drafts:DraftItem:
type: object
properties:
inbox_id:
$ref: '#/components/schemas/type_inboxes:InboxId'
draft_id:
$ref: '#/components/schemas/type_drafts:DraftId'
labels:
$ref: '#/components/schemas/type_drafts:DraftLabels'
to:
$ref: '#/components/schemas/type_drafts:DraftTo'
cc:
$ref: '#/components/schemas/type_drafts:DraftCc'
bcc:
$ref: '#/components/schemas/type_drafts:DraftBcc'
subject:
$ref: '#/components/schemas/type_drafts:DraftSubject'
preview:
$ref: '#/components/schemas/type_drafts:DraftPreview'
attachments:
$ref: '#/components/schemas/type_drafts:DraftAttachments'
in_reply_to:
$ref: '#/components/schemas/type_drafts:DraftInReplyTo'
send_status:
$ref: '#/components/schemas/type_drafts:DraftSendStatus'
send_at:
$ref: '#/components/schemas/type_drafts:DraftSendAt'
updated_at:
$ref: '#/components/schemas/type_drafts:DraftUpdatedAt'
required:
- inbox_id
- draft_id
- labels
- updated_at
title: DraftItem
type_drafts:ListDraftsResponse:
type: object
properties:
count:
$ref: '#/components/schemas/type_:Count'
limit:
$ref: '#/components/schemas/type_:Limit'
next_page_token:
$ref: '#/components/schemas/type_:PageToken'
drafts:
type: array
items:
$ref: '#/components/schemas/type_drafts:DraftItem'
description: Ordered by `updated_at` descending.
required:
- count
- drafts
title: ListDraftsResponse
type_:ErrorName:
type: string
description: Name of error.
title: ErrorName
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: bearerExamples
Response
json
{
"count": 1,
"drafts": [
{
"inbox_id": "inbox_id",
"draft_id": "draft_id",
"labels": [
"labels",
"labels"
],
"updated_at": "2024-01-15T09:30:00Z",
"to": [
"to",
"to"
],
"cc": [
"cc",
"cc"
],
"bcc": [
"bcc",
"bcc"
],
"subject": "subject",
"preview": "preview",
"attachments": [
{
"attachment_id": "attachment_id",
"size": 1,
"filename": "filename",
"content_type": "content_type",
"content_disposition": "inline",
"content_id": "content_id"
},
{
"attachment_id": "attachment_id",
"size": 1,
"filename": "filename",
"content_type": "content_type",
"content_disposition": "inline",
"content_id": "content_id"
}
],
"in_reply_to": "in_reply_to",
"send_status": "scheduled",
"send_at": "2024-01-15T09:30:00Z"
},
{
"inbox_id": "inbox_id",
"draft_id": "draft_id",
"labels": [
"labels",
"labels"
],
"updated_at": "2024-01-15T09:30:00Z",
"to": [
"to",
"to"
],
"cc": [
"cc",
"cc"
],
"bcc": [
"bcc",
"bcc"
],
"subject": "subject",
"preview": "preview",
"attachments": [
{
"attachment_id": "attachment_id",
"size": 1,
"filename": "filename",
"content_type": "content_type",
"content_disposition": "inline",
"content_id": "content_id"
},
{
"attachment_id": "attachment_id",
"size": 1,
"filename": "filename",
"content_type": "content_type",
"content_disposition": "inline",
"content_id": "content_id"
}
],
"in_reply_to": "in_reply_to",
"send_status": "scheduled",
"send_at": "2024-01-15T09:30:00Z"
}
],
"limit": 1,
"next_page_token": "next_page_token"
}SDK Code
typescript
import { AgentMailClient } from "agentmail";
async function main() {
const client = new AgentMailClient({
apiKey: "YOUR_TOKEN_HERE",
});
await client.inboxes.drafts.list("inbox_id", {});
}
main();python
from agentmail import AgentMail
client = AgentMail(
api_key="YOUR_TOKEN_HERE",
)
client.inboxes.drafts.list(
inbox_id="inbox_id",
)go
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.agentmail.to/v0/inboxes/inbox_id/drafts"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <api_key>")
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/drafts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <api_key>'
response = http.request(request)
puts response.read_bodyjava
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/inboxes/inbox_id/drafts")
.header("Authorization", "Bearer <api_key>")
.asString();php
<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'https://api.agentmail.to/v0/inboxes/inbox_id/drafts', [
'headers' => [
'Authorization' => 'Bearer <api_key>',
],
]);
echo $response->getBody();csharp
using RestSharp;
var client = new RestClient("https://api.agentmail.to/v0/inboxes/inbox_id/drafts");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <api_key>");
IRestResponse response = client.Execute(request);swift
import Foundation
let headers = ["Authorization": "Bearer <api_key>"]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/inboxes/inbox_id/drafts")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
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()Update Draft
PATCH https://api.agentmail.to/v0/inboxes/{inbox_id}/drafts/{draft_id} Content-Type: application/json
CLI:
bash
agentmail inboxes:drafts update --inbox-id <inbox_id> --draft-id <draft_id> --subject "Updated subject"OpenAPI Specification
yaml
openapi: 3.1.0
info:
title: api
version: 1.0.0
paths:
/v0/inboxes/{inbox_id}/drafts/{draft_id}:
patch:
operationId: update
summary: Update Draft
description: >-
**CLI:**
```bash
agentmail inboxes:drafts update --inbox-id <inbox_id> --draft-id
<draft_id> --subject "Updated subject"
```
tags:
- subpackage_inboxes.subpackage_inboxes/drafts
parameters:
- name: inbox_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_inboxes:InboxId'
- name: draft_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_drafts:DraftId'
- 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_drafts:Draft'
'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_drafts:UpdateDraftRequest'
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_drafts:DraftId:
type: string
description: ID of draft.
title: DraftId
type_drafts:DraftReplyTo:
type: array
items:
type: string
description: >-
Reply-to addresses. In format `username@domain.com` or `Display Name
<username@domain.com>`.
title: DraftReplyTo
type_drafts:DraftTo:
type: array
items:
type: string
description: >-
Addresses of recipients. In format `username@domain.com` or `Display
Name <username@domain.com>`.
title: DraftTo
type_drafts:DraftCc:
type: array
items:
type: string
description: >-
Addresses of CC recipients. In format `username@domain.com` or `Display
Name <username@domain.com>`.
title: DraftCc
type_drafts:DraftBcc:
type: array
items:
type: string
description: >-
Addresses of BCC recipients. In format `username@domain.com` or `Display
Name <username@domain.com>`.
title: DraftBcc
type_drafts:DraftSubject:
type: string
description: Subject of draft.
title: DraftSubject
type_drafts:DraftText:
type: string
description: Plain text body of draft.
title: DraftText
type_drafts:DraftHtml:
type: string
description: HTML body of draft.
title: DraftHtml
type_drafts:DraftSendAt:
type: string
format: date-time
description: Time at which to schedule send draft.
title: DraftSendAt
type_drafts:UpdateDraftRequest:
type: object
properties:
reply_to:
$ref: '#/components/schemas/type_drafts:DraftReplyTo'
to:
$ref: '#/components/schemas/type_drafts:DraftTo'
cc:
$ref: '#/components/schemas/type_drafts:DraftCc'
bcc:
$ref: '#/components/schemas/type_drafts:DraftBcc'
subject:
$ref: '#/components/schemas/type_drafts:DraftSubject'
text:
$ref: '#/components/schemas/type_drafts:DraftText'
html:
$ref: '#/components/schemas/type_drafts:DraftHtml'
send_at:
$ref: '#/components/schemas/type_drafts:DraftSendAt'
title: UpdateDraftRequest
type_drafts:DraftClientId:
type: string
description: Client ID of draft.
title: DraftClientId
type_drafts:DraftLabels:
type: array
items:
type: string
description: Labels of draft.
title: DraftLabels
type_drafts:DraftPreview:
type: string
description: Text preview of draft.
title: DraftPreview
type_attachments:AttachmentId:
type: string
description: ID of attachment.
title: AttachmentId
type_attachments:AttachmentFilename:
type: string
description: Filename of attachment.
title: AttachmentFilename
type_attachments:AttachmentSize:
type: integer
description: Size of attachment in bytes.
title: AttachmentSize
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:Attachment:
type: object
properties:
attachment_id:
$ref: '#/components/schemas/type_attachments:AttachmentId'
filename:
$ref: '#/components/schemas/type_attachments:AttachmentFilename'
size:
$ref: '#/components/schemas/type_attachments:AttachmentSize'
content_type:
$ref: '#/components/schemas/type_attachments:AttachmentContentType'
content_disposition:
$ref: '#/components/schemas/type_attachments:AttachmentContentDisposition'
content_id:
$ref: '#/components/schemas/type_attachments:AttachmentContentId'
required:
- attachment_id
- size
title: Attachment
type_drafts:DraftAttachments:
type: array
items:
$ref: '#/components/schemas/type_attachments:Attachment'
description: Attachments in draft.
title: DraftAttachments
type_drafts:DraftInReplyTo:
type: string
description: ID of message being replied to.
title: DraftInReplyTo
type_drafts:DraftSendStatus:
type: string
enum:
- scheduled
- sending
- failed
description: Schedule send status of draft.
title: DraftSendStatus
type_drafts:DraftUpdatedAt:
type: string
format: date-time
description: Time at which draft was last updated.
title: DraftUpdatedAt
type_drafts:Draft:
type: object
properties:
inbox_id:
$ref: '#/components/schemas/type_inboxes:InboxId'
draft_id:
$ref: '#/components/schemas/type_drafts:DraftId'
client_id:
$ref: '#/components/schemas/type_drafts:DraftClientId'
labels:
$ref: '#/components/schemas/type_drafts:DraftLabels'
reply_to:
$ref: '#/components/schemas/type_drafts:DraftReplyTo'
to:
$ref: '#/components/schemas/type_drafts:DraftTo'
cc:
$ref: '#/components/schemas/type_drafts:DraftCc'
bcc:
$ref: '#/components/schemas/type_drafts:DraftBcc'
subject:
$ref: '#/components/schemas/type_drafts:DraftSubject'
preview:
$ref: '#/components/schemas/type_drafts:DraftPreview'
text:
$ref: '#/components/schemas/type_drafts:DraftText'
html:
$ref: '#/components/schemas/type_drafts:DraftHtml'
attachments:
$ref: '#/components/schemas/type_drafts:DraftAttachments'
in_reply_to:
$ref: '#/components/schemas/type_drafts:DraftInReplyTo'
references:
type: array
items:
type: string
description: IDs of previous messages in thread.
send_status:
$ref: '#/components/schemas/type_drafts:DraftSendStatus'
send_at:
$ref: '#/components/schemas/type_drafts:DraftSendAt'
updated_at:
$ref: '#/components/schemas/type_drafts:DraftUpdatedAt'
created_at:
type: string
format: date-time
description: Time at which draft was created.
required:
- inbox_id
- draft_id
- labels
- updated_at
- created_at
title: Draft
type_:ErrorName:
type: string
description: Name of error.
title: ErrorName
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: bearerExamples
Request
json
{}Response
json
{
"inbox_id": "inbox_id",
"draft_id": "draft_id",
"labels": [
"labels",
"labels"
],
"updated_at": "2024-01-15T09:30:00Z",
"created_at": "2024-01-15T09:30:00Z",
"client_id": "client_id",
"reply_to": [
"reply_to",
"reply_to"
],
"to": [
"to",
"to"
],
"cc": [
"cc",
"cc"
],
"bcc": [
"bcc",
"bcc"
],
"subject": "subject",
"preview": "preview",
"text": "text",
"html": "html",
"attachments": [
{
"attachment_id": "attachment_id",
"size": 1,
"filename": "filename",
"content_type": "content_type",
"content_disposition": "inline",
"content_id": "content_id"
},
{
"attachment_id": "attachment_id",
"size": 1,
"filename": "filename",
"content_type": "content_type",
"content_disposition": "inline",
"content_id": "content_id"
}
],
"in_reply_to": "in_reply_to",
"references": [
"references",
"references"
],
"send_status": "scheduled",
"send_at": "2024-01-15T09:30:00Z"
}SDK Code
typescript
import { AgentMailClient } from "agentmail";
async function main() {
const client = new AgentMailClient({
apiKey: "YOUR_TOKEN_HERE",
});
await client.inboxes.drafts.update("inbox_id", "draft_id", {});
}
main();python
from agentmail import AgentMail
client = AgentMail(
api_key="YOUR_TOKEN_HERE",
)
client.inboxes.drafts.update(
inbox_id="inbox_id",
draft_id="draft_id",
)go
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.agentmail.to/v0/inboxes/inbox_id/drafts/draft_id"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("PATCH", 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/drafts/draft_id")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <api_key>'
request["Content-Type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_bodyjava
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
HttpResponse<String> response = Unirest.patch("https://api.agentmail.to/v0/inboxes/inbox_id/drafts/draft_id")
.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('PATCH', 'https://api.agentmail.to/v0/inboxes/inbox_id/drafts/draft_id', [
'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/drafts/draft_id");
var request = new RestRequest(Method.PATCH);
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/drafts/draft_id")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "PATCH"
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()Send Draft
POST https://api.agentmail.to/v0/inboxes/{inbox_id}/drafts/{draft_id}/send Content-Type: application/json
CLI:
bash
agentmail inboxes:drafts send --inbox-id <inbox_id> --draft-id <draft_id>OpenAPI Specification
yaml
openapi: 3.1.0
info:
title: api
version: 1.0.0
paths:
/v0/inboxes/{inbox_id}/drafts/{draft_id}/send:
post:
operationId: send
summary: Send Draft
description: >-
**CLI:**
```bash
agentmail inboxes:drafts send --inbox-id <inbox_id> --draft-id
<draft_id>
```
tags:
- subpackage_inboxes.subpackage_inboxes/drafts
parameters:
- name: inbox_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_inboxes:InboxId'
- name: draft_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_drafts:DraftId'
- 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:UpdateMessageRequest'
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_drafts:DraftId:
type: string
description: ID of draft.
title: DraftId
type_messages:UpdateMessageLabels:
oneOf:
- type: string
- type: array
items:
type: string
description: Label or list of labels.
title: UpdateMessageLabels
type_messages:UpdateMessageRequest:
type: object
properties:
add_labels:
$ref: '#/components/schemas/type_messages:UpdateMessageLabels'
description: Label or labels to add to message.
remove_labels:
$ref: '#/components/schemas/type_messages:UpdateMessageLabels'
description: Label or labels to remove from message.
title: UpdateMessageRequest
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_: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
type_:ValidationErrorResponse:
type: object
properties:
name:
$ref: '#/components/schemas/type_:ErrorName'
errors:
description: Validation errors.
required:
- name
- errors
title: ValidationErrorResponse
securitySchemes:
Bearer:
type: http
scheme: bearerExamples
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.drafts.send("inbox_id", "draft_id", {});
}
main();python
from agentmail import AgentMail
client = AgentMail(
api_key="YOUR_TOKEN_HERE",
)
client.inboxes.drafts.send(
inbox_id="inbox_id",
draft_id="draft_id",
)go
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.agentmail.to/v0/inboxes/inbox_id/drafts/draft_id/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/drafts/draft_id/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_bodyjava
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/drafts/draft_id/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/drafts/draft_id/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/drafts/draft_id/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/drafts/draft_id/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()Delete Draft
DELETE https://api.agentmail.to/v0/inboxes/{inbox_id}/drafts/{draft_id}
CLI:
bash
agentmail inboxes:drafts delete --inbox-id <inbox_id> --draft-id <draft_id>OpenAPI Specification
yaml
openapi: 3.1.0
info:
title: api
version: 1.0.0
paths:
/v0/inboxes/{inbox_id}/drafts/{draft_id}:
delete:
operationId: delete
summary: Delete Draft
description: >-
**CLI:**
```bash
agentmail inboxes:drafts delete --inbox-id <inbox_id> --draft-id
<draft_id>
```
tags:
- subpackage_inboxes.subpackage_inboxes/drafts
parameters:
- name: inbox_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_inboxes:InboxId'
- name: draft_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_drafts:DraftId'
- name: Authorization
in: header
description: Bearer authentication
required: true
schema:
type: string
responses:
'200':
description: Successful response
'404':
description: Error response with status 404
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ErrorResponse'
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_drafts:DraftId:
type: string
description: ID of draft.
title: DraftId
type_:ErrorName:
type: string
description: Name of error.
title: ErrorName
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: bearerExamples
SDK Code
typescript
import { AgentMailClient } from "agentmail";
async function main() {
const client = new AgentMailClient({
apiKey: "YOUR_TOKEN_HERE",
});
await client.inboxes.drafts.delete("inbox_id", "draft_id");
}
main();python
from agentmail import AgentMail
client = AgentMail(
api_key="YOUR_TOKEN_HERE",
)
client.inboxes.drafts.delete(
inbox_id="inbox_id",
draft_id="draft_id",
)go
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.agentmail.to/v0/inboxes/inbox_id/drafts/draft_id"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("Authorization", "Bearer <api_key>")
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/drafts/draft_id")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <api_key>'
response = http.request(request)
puts response.read_bodyjava
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
HttpResponse<String> response = Unirest.delete("https://api.agentmail.to/v0/inboxes/inbox_id/drafts/draft_id")
.header("Authorization", "Bearer <api_key>")
.asString();php
<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('DELETE', 'https://api.agentmail.to/v0/inboxes/inbox_id/drafts/draft_id', [
'headers' => [
'Authorization' => 'Bearer <api_key>',
],
]);
echo $response->getBody();csharp
using RestSharp;
var client = new RestClient("https://api.agentmail.to/v0/inboxes/inbox_id/drafts/draft_id");
var request = new RestRequest(Method.DELETE);
request.AddHeader("Authorization", "Bearer <api_key>");
IRestResponse response = client.Execute(request);swift
import Foundation
let headers = ["Authorization": "Bearer <api_key>"]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/inboxes/inbox_id/drafts/draft_id")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "DELETE"
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()Get Draft Attachment
GET https://api.agentmail.to/v0/inboxes/{inbox_id}/drafts/{draft_id}/attachments/{attachment_id}
CLI:
bash
agentmail inboxes:drafts get-attachment --inbox-id <inbox_id> --draft-id <draft_id> --attachment-id <attachment_id>OpenAPI Specification
yaml
openapi: 3.1.0
info:
title: api
version: 1.0.0
paths:
/v0/inboxes/{inbox_id}/drafts/{draft_id}/attachments/{attachment_id}:
get:
operationId: get-attachment
summary: Get Attachment
description: >-
**CLI:**
```bash
agentmail inboxes:drafts get-attachment --inbox-id <inbox_id> --draft-id
<draft_id> --attachment-id <attachment_id>
```
tags:
- subpackage_inboxes.subpackage_inboxes/drafts
parameters:
- name: inbox_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_inboxes:InboxId'
- name: draft_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_drafts:DraftId'
- name: attachment_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_attachments:AttachmentId'
- 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_attachments:AttachmentResponse'
'404':
description: Error response with status 404
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ErrorResponse'
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_drafts:DraftId:
type: string
description: ID of draft.
title: DraftId
type_attachments:AttachmentId:
type: string
description: ID of attachment.
title: AttachmentId
type_attachments:AttachmentFilename:
type: string
description: Filename of attachment.
title: AttachmentFilename
type_attachments:AttachmentSize:
type: integer
description: Size of attachment in bytes.
title: AttachmentSize
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:AttachmentResponse:
type: object
properties:
attachment_id:
$ref: '#/components/schemas/type_attachments:AttachmentId'
filename:
$ref: '#/components/schemas/type_attachments:AttachmentFilename'
size:
$ref: '#/components/schemas/type_attachments:AttachmentSize'
content_type:
$ref: '#/components/schemas/type_attachments:AttachmentContentType'
content_disposition:
$ref: '#/components/schemas/type_attachments:AttachmentContentDisposition'
content_id:
$ref: '#/components/schemas/type_attachments:AttachmentContentId'
download_url:
type: string
description: URL to download the attachment.
expires_at:
type: string
format: date-time
description: Time at which the download URL expires.
required:
- attachment_id
- size
- download_url
- expires_at
title: AttachmentResponse
type_:ErrorName:
type: string
description: Name of error.
title: ErrorName
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: bearerExamples
Response
json
{
"attachment_id": "attachment_id",
"size": 1,
"download_url": "download_url",
"expires_at": "2024-01-15T09:30:00Z",
"filename": "filename",
"content_type": "content_type",
"content_disposition": "inline",
"content_id": "content_id"
}SDK Code
typescript
import { AgentMailClient } from "agentmail";
async function main() {
const client = new AgentMailClient({
apiKey: "YOUR_TOKEN_HERE",
});
await client.inboxes.drafts.getAttachment("inbox_id", "draft_id", "attachment_id");
}
main();python
from agentmail import AgentMail
client = AgentMail(
api_key="YOUR_TOKEN_HERE",
)
client.inboxes.drafts.get_attachment(
inbox_id="inbox_id",
draft_id="draft_id",
attachment_id="attachment_id",
)go
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.agentmail.to/v0/inboxes/inbox_id/drafts/draft_id/attachments/attachment_id"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <api_key>")
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/drafts/draft_id/attachments/attachment_id")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <api_key>'
response = http.request(request)
puts response.read_bodyjava
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/inboxes/inbox_id/drafts/draft_id/attachments/attachment_id")
.header("Authorization", "Bearer <api_key>")
.asString();php
<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'https://api.agentmail.to/v0/inboxes/inbox_id/drafts/draft_id/attachments/attachment_id', [
'headers' => [
'Authorization' => 'Bearer <api_key>',
],
]);
echo $response->getBody();csharp
using RestSharp;
var client = new RestClient("https://api.agentmail.to/v0/inboxes/inbox_id/drafts/draft_id/attachments/attachment_id");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <api_key>");
IRestResponse response = client.Execute(request);swift
import Foundation
let headers = ["Authorization": "Bearer <api_key>"]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/inboxes/inbox_id/drafts/draft_id/attachments/attachment_id")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
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()