Skip to content
RSFlowHub
  1. Home
  2. APIs
  3. Email
  4. AI Email Automation & Auto-Routing Workflow API
Email API

AI Email Automation & Auto-Routing Workflow API

Automated email decision engine determining routing, forwarding, assignment, archiving, or escalation rules.

POST https://rsflowhub.com/api/v1/ai/email-workflow
  • 2 credits per call
  • X-API-Key header
  • JSON in, JSON out
POST /api/v1/ai/email-workflow
{
    "subject": "Cancel subscription",
    "email_content": "I would like to cancel my subscription from next month, please assist.",
    "allowed_actions": [
        "reply",
        "forward",
        "archive",
        "escalate"
    ],
    "allowed_departments": [
        "billing",
        "support",
        "sales"
    ],
    "workflow_first": true
}
200 OK response.json
{
    "result": {
        "action": "auto_reply",
        "department": "billing",
        "confidence": 0.9,
        "reasoning": "Clear duplicate-charge refund request covered by the standard refund policy.",
        "category": "billing",
        "intent": "refund_request",
        "priority": "high",
        "sentiment": "negative",
        "language": "en",
        "summary": "Duplicate charge on invoice INV-2041; customer requests a refund.",
        "reply_text": "Thanks for reaching out. We have refunded the duplicate payment for INV-2041.",
        "requires_human_escalation": false,
        "escalation_reason": null
    }
}
Definition

What is the AI Email Automation & Auto-Routing Workflow API?

AI Email Automation & Auto-Routing Workflow API is a REST API on RSFlowHub for web, mobile and AI agent applications. Send a JSON request to POST /api/v1/ai/email-workflow with your API key; RSFlowHub runs it on a tuned AI model, falls back to a backup provider if needed, and returns a structured JSON result, usually within 1 to 3 seconds.

Category
Email
Endpoint
POST /api/v1/ai/email-workflow
Authentication
X-API-Key header
Price
2 credits per call
Rate limit
10 to 120 requests / minute by plan
Typical response
1 to 3 seconds
Format
JSON, UTF-8

Request parameters

Send these fields as a JSON body. An invalid or missing field returns a 422 error that names the field.

FieldTypeRequiredDescription
email_content string Required The main body of the email to route (Max: 20,000 characters).
subject string Optional Optional email subject line.
allowed_actions array of strings Optional Optional strict list of allowed actions (e.g., ["reply", "forward", "archive", "escalate"]).
allowed_departments array of strings Optional Optional strict list of allowed departments (e.g., ["support", "billing", "sales", "hr"]).
workflow_first boolean Optional Optional. If true, runs in Workflow-First Mode. The API internally executes both analysis and reply drafting, returning all results (insights and drafted reply) in a single unified JSON response. Default is false.
custom_instructions string Optional Optional instructions to guide routing decisions.

Code examples

Copy, replace rfh_your_api_key with your key and run. Prefer a client library? See the official SDKs.

request.sh
curl -X POST "https://rsflowhub.com/api/v1/ai/email-workflow" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: rfh_your_api_key" \
  -d '{"subject":"Cancel subscription","email_content":"I would like to cancel my subscription from next month, please assist.","allowed_actions":["reply","forward","archive","escalate"],"allowed_departments":["billing","support","sales"],"workflow_first":true}'

Response

Every RSFlowHub endpoint uses the same envelope, so one parser handles all of them. Failed calls are not charged.

response.json
{
    "success": true,
    "request_id": "req_3f9a2c7e-5b1d-4e8a-9c2f-7d6e1a0b4c8d",
    "data": {
        "result": {
            "action": "auto_reply",
            "department": "billing",
            "confidence": 0.9,
            "reasoning": "Clear duplicate-charge refund request covered by the standard refund policy.",
            "category": "billing",
            "intent": "refund_request",
            "priority": "high",
            "sentiment": "negative",
            "language": "en",
            "summary": "Duplicate charge on invoice INV-2041; customer requests a refund.",
            "reply_text": "Thanks for reaching out. We have refunded the duplicate payment for INV-2041.",
            "requires_human_escalation": false,
            "escalation_reason": null
        }
    },
    "meta": {
        "version": "v1",
        "timestamp": "2026-10-05T09:30:00Z"
    }
}
Envelope fields
FieldTypeMeaning
successbooleantrue when the call worked, false on any error.
request_idstringUnique id for this call. Quote it when you contact support.
data.resultobjectThe result of this endpoint (see the example).
errorobjectOnly on failure: code, message and details per field.
metaobjectAPI version and server timestamp.

All error codes: Errors reference

Features

Automated Next-Best Action Engine

Evaluates incoming email content to choose the optimal action: "reply", "forward", "archive", "assign", or "escalate".

Department & Team Auto-Routing

Automatically routes emails to correct team queues like billing, technical support, sales, or legal.

Escalation Risk Detection

Detects urgent legal threats, executive complaints, or chargebacks requiring immediate human intervention.

Workflow-First Priority Mode

Evaluates routing rules before drafting reply text to deliver lightning-fast routing execution.

Use cases

How teams use the AI Email Automation & Auto-Routing Workflow API in production.

Enterprise Email

Automated Enterprise Inbox Routing

Route incoming main company contact email inquiries automatically to Billing, Sales, or Legal queues.

Input
I would like to cancel my subscription from next month, please assist.
Output
{"action": "assign", "department": "billing", "priority": "high", "reason": "subscription_cancellation"}

Sorts every incoming email by category and priority the moment it arrives.

Customer Support

Helpdesk Escalation Automation

Instantly escalate emails containing chargeback threats or legal complaints to senior retention leads.

Input
Your system leak exposed our data. We are contacting our legal counsel today.
Output
{"action": "escalate", "department": "legal_security", "priority": "critical"}

Protects enterprise accounts through immediate escalation.

Sales Automation

Lead Qualification & CRM Assignment

Assign incoming qualified sales demo requests to regional account executives based on company location.

Input
Looking for enterprise pricing for our London office team of 100.
Output
{"action": "forward", "department": "sales_emea", "priority": "high"}

Accelerates sales representative outreach speed.

AI Email Automation & Auto-Routing Workflow API vs building it yourself

The same job done three ways.

TopicRSFlowHub APIRaw LLM promptsRules / regex
Output Validated JSON fieldsFree text you have to parseFixed patterns only
Setup One POST request, no promptsWrite and maintain prompts and parsingWrite and maintain rule lists
Provider outage Automatic fallback to a backup modelYou build retries and a second vendorNot applicable
Pricing 2 credits per call, failed calls freePer token, per vendorYour own servers and upkeep
Understands context Yes, AI modelYes, AI modelNo, keywords only

Frequently asked questions

How does the Email Workflow API decide which action to take?
The API evaluates sender intent, sentiment, urgency keywords, and allowed business departments to determine the optimal next workflow action.
Can I specify allowed departments and workflow actions?
Yes! You can pass allowed_actions and allowed_departments to restrict decisions to your company CRM workflow.
How does escalation detection work?
The engine flags high-risk keywords (e.g. legal action, security breach, chargeback) to trigger immediate escalation actions.
How fast is the Email Workflow API?
Email Workflow requests usually complete in 1 to 3 seconds, depending on input length and the AI model. Identical repeat requests are served from cache and return faster.
How many credits does each request consume?
Standard Email Workflow API calls consume 2 base credits per request.

Start using the AI Email Automation & Auto-Routing Workflow API

Free plan with 100 credits/month + 1,000 bonus credits when you sign in before 23 Nov. Test it in the playground first, no code needed.

RSFlowHub

Sign in to continue

You'll come straight back to this page.

Forgot password?

New to RSFlowHub? Create a free account