1. Create your labels once
2. Classify and assign on inbound
labels array now includes the assigned label — visible on
GET /messages/{id}, in search results, and in the dashboard. Remove a label
with POST /labels/{id}/unassign.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Classify inbound mail and apply labels automatically.
curl -X POST https://api.sentfrom.ai/v1/labels \
-H "Authorization: Bearer sf_live_…" -H "Content-Type: application/json" \
-d '{ "name": "Sales", "color": "#10b981" }'
# repeat for Support, Billing, Spam … keep the returned ids
const KEY = process.env.SENTFROMAI_API_KEY!;
const API = "https://api.sentfrom.ai/v1";
const LABELS = { Sales: "lbl_…", Support: "lbl_…", Billing: "lbl_…" };
export async function onInbound(message) {
// classify with your LLM -> one of the label names
const category = await classify(message.subject, message.body_text); // "Sales" | "Support" | ...
const labelId = LABELS[category];
if (!labelId) return;
await fetch(`${API}/labels/${labelId}/assign`, {
method: "POST",
headers: { Authorization: `Bearer ${KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({ message_id: message.id }),
});
}
import os, requests
KEY = os.environ["SENTFROMAI_API_KEY"]
API = "https://api.sentfrom.ai/v1"
LABELS = {"Sales": "lbl_…", "Support": "lbl_…", "Billing": "lbl_…"}
def on_inbound(message):
category = classify(message["subject"], message.get("body_text", "")) # your LLM
label_id = LABELS.get(category)
if not label_id:
return
requests.post(
f"{API}/labels/{label_id}/assign",
headers={"Authorization": f"Bearer {KEY}"},
json={"message_id": message["id"]},
)
labels array now includes the assigned label — visible on
GET /messages/{id}, in search results, and in the dashboard. Remove a label
with POST /labels/{id}/unassign.
message.received.