Skip to content
AI Inbx
Esc
↑↓navigate↵open⌘Jpreview

Update an email

Changes an email that has not gone out — a draft or a scheduled one: its recipients, subject, bodies, attachments or send time. Fields left out stay as they are. The email is composed again when it goes, so what is sent is what it says by then. One that has begun sending, or was canceled or discarded, returns 409 not_scheduled.

PATCH/emails/{email_id}
Authorization
AuthorizationBearer token (API key) · headerrequired

Pass an AI Inbx API key as a Bearer token.

Path parameters
email_idstringrequired

The prefixed email ID.

matches ^[a-z]+_[0-9a-f]{32}$
Header parameters
AIInbx-Workspacestring

Workspace id from GET /workspaces, for an OAuth token that reaches several.

min length 1
Request body
requiredapplication/json
tostring<email> | string<email>[]

Recipients: one address or a list, at most 100.

Show properties
Any of:
string<email>
string<email>
string<email>[]
Array of string<email>
string<email>
ccstring<email> | string<email>[]

Cc recipients: one address or a list, at most 100. An empty list clears it.

Show properties
Any of:
string<email>
string<email>
string<email>[]
Array of string<email>
string<email>
bccstring<email> | string<email>[]

Bcc recipients: one address or a list, at most 100. An empty list clears it.

Show properties
Any of:
string<email>
string<email>
string<email>[]
Array of string<email>
string<email>
reply_tostring<email> | string<email>[]

Where replies go (Reply-To): one address or a list, at most 100. An empty list clears it.

Show properties
Any of:
string<email>
string<email>
string<email>[]
Array of string<email>
string<email>
subjectstring

The subject line.

max length 998
htmlstring | null

The HTML body. Null drops it, leaving the text. The text part is not rewritten from it — send text too to keep the two alike.

Show properties
Any of:
string
string
null
null
textstring | null

The plain-text body. Null drops it, leaving the HTML.

Show properties
Any of:
string
string
null
null
attachmentsobject[]

The files it carries from now on: { id } keeps one it has, a new one is given as on send. Left out, they stay; an empty list removes them all. New files decode to at most 3 MB per request, and all the email carries to at most 7 MB.

max items 20
Show properties
Array of object
Any of:
object
filenamestringrequired
min length 1 · max length 255
content_typestringrequired
min length 1 · max length 255
contentstringrequired
max length 4000000
cidstring
max length 998
object
idstringrequired

An attachment this email has.

matches ^[a-z]+_[0-9a-f]{32}$
scheduled_atstring<date-time>

The new send time, at most 30 days out — on a draft, the time proposed for it.

matches ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z|([+-](?:[01]\d|2[0-3]):[0-5]\d)))$
Responses
200

Success.

idstringrequired
matches ^[a-z]+_[0-9a-f]{32}$
thread_idstringrequired
matches ^[a-z]+_[0-9a-f]{32}$
space_idstring | nullrequired

Which space a resource is in. Null is the workspace itself — what every resource of a workspace that has no spaces says.

Show properties
Any of:
string
string
null
null
directionstringrequired
Allowed:inboundoutbound
statusstringrequired
Allowed:draftscheduledcanceleddiscardedqueuedsendingsentdeliveredbouncedcomplainedfailedreceived
fromobjectrequired
Show properties
namestring | null
Show properties
Any of:
string
string
null
null
addressstring<email>required
matches ^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$
tostring<email>[]required
ccstring<email>[]
bccstring<email>[]
reply_tostring<email>[]
subjectstringrequired
snippetstringrequired
htmlstring | null
Show properties
Any of:
string
string
null
null
textstring | null
Show properties
Any of:
string
string
null
null
categorystring | nullrequired
Show properties
Any of:
string
string
null
null
verdictsobject | nullrequired
Show properties
Any of:
object
spamstring | nullrequired

PASS, FAIL, GRAY or PROCESSING_FAILED. Null when this check was not reported.

Show properties
Any of:
string
string
null
null
spfstring | nullrequired

PASS, FAIL, GRAY or PROCESSING_FAILED. Null when this check was not reported.

Show properties
Any of:
string
string
null
null
dkimstring | nullrequired

PASS, FAIL, GRAY or PROCESSING_FAILED. Null when this check was not reported.

Show properties
Any of:
string
string
null
null
dmarcstring | nullrequired

PASS, FAIL, GRAY or PROCESSING_FAILED. Null when this check was not reported.

Show properties
Any of:
string
string
null
null
null
null
suppression_keystring | nullrequired
Show properties
Any of:
string
string
null
null
message_idstringrequired

The RFC Message-ID, without angle brackets.

in_reply_tostring | nullrequired

The Message-ID of the message this one answers, without angle brackets. Null when it answers none.

Show properties
Any of:
string
string
null
null
idempotency_keystring | nullrequired
Show properties
Any of:
string
string
null
null
created_atstring<date-time>required

When it took its place in its thread. A draft's moves to when it is sent — draft.drafted_at keeps when it was written.

matches ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
scheduled_atstring<date-time> | nullrequired
Show properties
Any of:
string<date-time>
string<date-time>
null
null
sent_atstring<date-time> | nullrequired
Show properties
Any of:
string<date-time>
string<date-time>
null
null
draftobject | nullrequired
Show properties
Any of:
object
drafted_atstring<date-time>required
matches ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
edited_atstring<date-time> | nullrequired

When its content last changed before it was sent. Null when it went as written.

Show properties
Any of:
string<date-time>
string<date-time>
null
null
review_urlstring<uri> | nullrequired

Where a person reviews, edits and sends it in the console.

Show properties
Any of:
string<uri>
string<uri>
null
null
null
null
attachmentsobject[]
Show properties
Array of object
idstringrequired
matches ^[a-z]+_[0-9a-f]{32}$
filenamestringrequired
content_typestringrequired
sizeintegerrequired
min 0 · max 9007199254740991
cidstring | nullrequired
Show properties
Any of:
string
string
null
null
download_urlstring<uri> | nullrequired

Signed URL for the original bytes, good until expires_at. Opens without the API key, so treat it as a secret — and do not send the key to it: storage answers a request that carries an Authorization header with 400. To keep a reference, store the attachment id and call GET /attachments/{id}. Null when the bytes are gone.

Show properties
Any of:
string<uri>
string<uri>
null
null
expires_atstring<date-time> | nullrequired

When download_url and preparation.content_url stop working — an hour after the response. Read the email again, or call the download endpoint with the attachment ID, for fresh ones.

Show properties
Any of:
string<date-time>
string<date-time>
null
null
preparationobject | nullrequired
Show properties
Any of:
object
statusstringrequired
Allowed:readypartialunsupportedfailed
formatstring | nullrequired
Show properties
Any of:
string
string
null
null
pagesinteger | nullrequired
Show properties
Any of:
integer
integer
null
null
warningsstring[]required
content_urlstring<uri> | nullrequired

Signed URL for the prepared text, good until the attachment's expires_at. Opens without the API key — and only without it: storage answers a request that carries an Authorization header with 400. Null when there is no prepared text.

Show properties
Any of:
string<uri>
string<uri>
null
null
textstring | null
Show properties
Any of:
string
string
null
null
null
null
400

The request is invalid.

typestringrequired
titlestringrequired
statusintegerrequired
min -9007199254740991 · max 9007199254740991
detailstringrequired
codestringrequired
request_idstringrequired
issuesobject[]
Show properties
Array of object
pathstringrequired
messagestringrequired
401

The API key is missing or invalid.

typestringrequired
titlestringrequired
statusintegerrequired
min -9007199254740991 · max 9007199254740991
detailstringrequired
codestringrequired
request_idstringrequired
issuesobject[]
Show properties
Array of object
pathstringrequired
messagestringrequired
402

The workspace has no plan (plan_required), or its plan's allowance is used up (allowance_reached).

typestringrequired
titlestringrequired
statusintegerrequired
min -9007199254740991 · max 9007199254740991
detailstringrequired
codestringrequired
request_idstringrequired
issuesobject[]
Show properties
Array of object
pathstringrequired
messagestringrequired
403

The API key does not have the required scope.

typestringrequired
titlestringrequired
statusintegerrequired
min -9007199254740991 · max 9007199254740991
detailstringrequired
codestringrequired
request_idstringrequired
issuesobject[]
Show properties
Array of object
pathstringrequired
messagestringrequired
404

The requested resource does not exist.

typestringrequired
titlestringrequired
statusintegerrequired
min -9007199254740991 · max 9007199254740991
detailstringrequired
codestringrequired
request_idstringrequired
issuesobject[]
Show properties
Array of object
pathstringrequired
messagestringrequired
409

The request conflicts with the resource's current state.

typestringrequired
titlestringrequired
statusintegerrequired
min -9007199254740991 · max 9007199254740991
detailstringrequired
codestringrequired
request_idstringrequired
issuesobject[]
Show properties
Array of object
pathstringrequired
messagestringrequired
413

The request body or attachments are too large.

typestringrequired
titlestringrequired
statusintegerrequired
min -9007199254740991 · max 9007199254740991
detailstringrequired
codestringrequired
request_idstringrequired
issuesobject[]
Show properties
Array of object
pathstringrequired
messagestringrequired
415

The request body is not JSON.

typestringrequired
titlestringrequired
statusintegerrequired
min -9007199254740991 · max 9007199254740991
detailstringrequired
codestringrequired
request_idstringrequired
issuesobject[]
Show properties
Array of object
pathstringrequired
messagestringrequired
422

The request body failed validation.

typestringrequired
titlestringrequired
statusintegerrequired
min -9007199254740991 · max 9007199254740991
detailstringrequired
codestringrequired
request_idstringrequired
issuesobject[]
Show properties
Array of object
pathstringrequired
messagestringrequired
429

The organisation's request budget is spent (too_many_requests), or an upstream mail provider is throttling (rate_limited).

typestringrequired
titlestringrequired
statusintegerrequired
min -9007199254740991 · max 9007199254740991
detailstringrequired
codestringrequired
request_idstringrequired
issuesobject[]
Show properties
Array of object
pathstringrequired
messagestringrequired
500

An internal error occurred.

typestringrequired
titlestringrequired
statusintegerrequired
min -9007199254740991 · max 9007199254740991
detailstringrequired
codestringrequired
request_idstringrequired
issuesobject[]
Show properties
Array of object
pathstringrequired
messagestringrequired
502

An upstream mail provider failed.

typestringrequired
titlestringrequired
statusintegerrequired
min -9007199254740991 · max 9007199254740991
detailstringrequired
codestringrequired
request_idstringrequired
issuesobject[]
Show properties
Array of object
pathstringrequired
messagestringrequired
503

The service is temporarily unavailable.

typestringrequired
titlestringrequired
statusintegerrequired
min -9007199254740991 · max 9007199254740991
detailstringrequired
codestringrequired
request_idstringrequired
issuesobject[]
Show properties
Array of object
pathstringrequired
messagestringrequired
Request
curl -X PATCH 'https://api.aiinbx.com/api/v2/emails/string' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
  "to": "user@example.com",
  "cc": "user@example.com",
  "bcc": "user@example.com",
  "reply_to": "user@example.com",
  "subject": "string",
  "html": "string",
  "text": "string",
  "attachments": [
    {
      "filename": "string",
      "content_type": "string",
      "content": "string",
      "cid": "string"
    }
  ],
  "scheduled_at": "2019-08-24T14:15:22Z"
}'
Response
{
  "id": "string",
  "thread_id": "string",
  "space_id": "string",
  "direction": "inbound",
  "status": "draft",
  "from": {
    "name": "string",
    "address": "user@example.com"
  },
  "to": [
    "user@example.com"
  ],
  "cc": [
    "user@example.com"
  ],
  "bcc": [
    "user@example.com"
  ],
  "reply_to": [
    "user@example.com"
  ],
  "subject": "string",
  "snippet": "string",
  "html": "string",
  "text": "string",
  "category": "human",
  "verdicts": {
    "spam": "string",
    "spf": "string",
    "dkim": "string",
    "dmarc": "string"
  },
  "suppression_key": "string",
  "message_id": "string",
  "in_reply_to": "string",
  "idempotency_key": "string",
  "created_at": "2019-08-24T14:15:22Z",
  "scheduled_at": "2019-08-24T14:15:22Z",
  "sent_at": "2019-08-24T14:15:22Z",
  "draft": {
    "drafted_at": "2019-08-24T14:15:22Z",
    "edited_at": "2019-08-24T14:15:22Z",
    "review_url": "http://example.com"
  },
  "attachments": [
    {
      "id": "string",
      "filename": "string",
      "content_type": "string",
      "size": 0,
      "cid": "string",
      "download_url": "http://example.com",
      "expires_at": "2019-08-24T14:15:22Z",
      "preparation": {
        "status": "ready",
        "format": "markdown",
        "pages": -9007199254740991,
        "warnings": [
          "string"
        ],
        "content_url": "http://example.com",
        "text": "string"
      }
    }
  ]
}