Sort emails into categories with AI
POST
/api/v1/mailbox/ai/classifyLabels a batch of messages as primary, newsletter, promotion, social, notification, finance, travel, action_required or other. Only when capabilities.ai is true and the holder has accepted the AI terms (POST /ai/consent).
Errors
| Status | When |
|---|---|
401 |
No token, or the session expired or was signed out. Sign in again with POST /mailbox-auth/login. |
403 |
The account has a temporary password: until POST /security/password succeeds, every other call answers this with error_code: password_change_required. |
502 |
The AI service did not answer usefully. |
Request body
itemsarray<object>requiredThe messages to sort: each an
id, itssubjectand apreview.idstringrequiredsubjectstringpreviewstring
Request
POST
/api/v1/mailbox/ai/classifycurl -X POST 'https://courier.mailyte.com/api/v1/mailbox/ai/classify' \
-H 'Authorization: Bearer MAILBOX_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"items": [
{
"id": "INBOX:4821",
"subject": "Your invoice for October",
"preview": "Amount due: ₦84,000"
}
]
}'const response = await fetch('https://courier.mailyte.com/api/v1/mailbox/ai/classify', {
method: 'POST',
headers: {
Authorization: 'Bearer MAILBOX_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"items": [
{
"id": "INBOX:4821",
"subject": "Your invoice for October",
"preview": "Amount due: ₦84,000"
}
]
}),
});
const { data } = await response.json();import requests
response = requests.post(
"https://courier.mailyte.com/api/v1/mailbox/ai/classify",
headers={"Authorization": "Bearer MAILBOX_TOKEN"},
json={
"items": [
{
"id": "INBOX:4821",
"subject": "Your invoice for October",
"preview": "Amount due: ₦84,000"
}
]
},
)
data = response.json()["data"]<?php
$response = Http::withToken('MAILBOX_TOKEN')
->post('https://courier.mailyte.com/api/v1/mailbox/ai/classify', [
'items' => [
[
'id' => 'INBOX:4821',
'subject' => 'Your invoice for October',
'preview' => 'Amount due: ₦84,000',
],
],
]);
$data = $response->json('data');require "net/http"
require "json"
uri = URI("https://courier.mailyte.com/api/v1/mailbox/ai/classify")
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer MAILBOX_TOKEN"
request["Content-Type"] = "application/json"
request.body = {
"items": [
{
"id": "INBOX:4821",
"subject": "Your invoice for October",
"preview": "Amount due: ₦84,000"
}
]
}.to_json
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(request) }Response
Successful Response
dataobjectitemsarray<object>idstringlabelstringconfidencenumber
labelsarray<string>ai_calls_remaininginteger
200
application/json{
"type": "success",
"msg": "Messages classified",
"data": {
"items": [
{
"id": "INBOX:4821",
"label": "finance",
"confidence": 0.93
}
],
"labels": [
"primary",
"newsletter",
"promotion",
"social",
"notification",
"finance",
"travel",
"action_required",
"other"
],
"ai_calls_remaining": 44
}
}Returned inside the standard envelope.
Errors
| Status | When |
|---|---|
401 | No token, or the session expired or was signed out. Sign in again with `POST /mailbox-auth/login`. |
403 | The account has a temporary password: until `POST /security/password` succeeds, every other call answers this with `error_code: password_change_required`. |
422 | Validation Error |
502 | The AI service did not answer usefully. |
Every status, with what causes it and what to do, is on the error reference.