GET /emails/_search
Example:
curl "http://localhost:9200/emails/_search?q=subject:meeting&size=10"
GET /emails/_doc/{id}
Example:
curl "http://localhost:9200/emails/_doc/email-12345"
POST /emails/_doc
Content-Type: application/json
Example:
curl -X POST "http://localhost:9200/emails/_doc" \
-H "Content-Type: application/json" \
-d '{
"from": "sender@example.com",
"to": "recipient@example.com",
"subject": "Meeting Request",
"body": "Can we schedule a meeting for tomorrow?",
"date": "2024-01-20T10:30:00Z"
}'
POST /emails/_search
Content-Type: application/json
Example:
curl -X POST "http://localhost:9200/emails/_search" \
-H "Content-Type: application/json" \
-d '{
"query": {
"bool": {
"must": [
{"match": {"subject": "meeting"}},
{"range": {"date": {"gte": "2024-01-01T00:00:00Z"}}}
]
}
},
"sort": [{"date": {"order": "desc"}}]
}'
GET /flows
Example:
curl "http://localhost:1880/flows"
POST /flows
Content-Type: application/json
Example:
curl -X POST "http://localhost:1880/flows" \
-H "Content-Type: application/json" \
-d @flows.json
POST /inject/{node-id}
Example:
curl -X POST "http://localhost:1880/inject/email-processor"
GET /api/tags
Example:
curl "http://localhost:11435/api/tags"
POST /api/generate
Content-Type: application/json
Example:
curl -X POST "http://localhost:11435/api/generate" \
-H "Content-Type: application/json" \
-d '{
"model": "llama2:13b",
"prompt": "Analyze this email: Subject: Urgent Meeting, From: boss@company.com, Body: We need to discuss the project status immediately. Classify as URGENT/BUSINESS/SPAM/PERSONAL.",
"stream": false
}'
POST /api/pull
Content-Type: application/json
Example:
curl -X POST "http://localhost:11435/api/pull" \
-H "Content-Type: application/json" \
-d '{"name": "llama2:7b"}'
GET /api/v1/query
Example:
curl "http://localhost:9090/api/v1/query?query=node_red_emails_processed_total"
GET /api/v1/query_range
Example:
curl "http://localhost:9090/api/v1/query_range?query=node_red_emails_processed_total&start=2024-01-01T00:00:00Z&end=2024-01-02T00:00:00Z&step=1h"
GET /api/dashboards
Authorization: Bearer API_KEY
Example:
curl "http://localhost:3000/api/dashboards" \
-H "Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk"
GET /api/dashboards/uid/{uid}
Authorization: Bearer API_KEY
Example:
curl "http://localhost:3000/api/dashboards/uid/email-metrics" \
-H "Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk"
# Get all keys
redis-cli -h localhost -p 6379 KEYS "*"
# Get email statistics
redis-cli -h localhost -p 6379 HGETALL "email:stats"
# Get classification counts
redis-cli -h localhost -p 6379 HGETALL "email:classifications"
POST /api/email/check
Content-Type: application/json
Example:
curl -X POST "http://localhost:1880/api/email/check" \
-H "Content-Type: application/json" \
-d '{
"force": true
}'
GET /api/email/stats
Example:
curl "http://localhost:1880/api/email/stats"
Response:
{
"total_processed": 1250,
"classifications": {
"URGENT": 125,
"BUSINESS": 850,
"PERSONAL": 200,
"SPAM": 75
},
"processing_time_avg_ms": 1200,
"last_check": "2024-01-20T10:30:00Z"
}
POST /api/email/process
Content-Type: application/json
Example:
curl -X POST "http://localhost:1880/api/email/process" \
-H "Content-Type: application/json" \
-d '{
"from": "sender@example.com",
"to": "recipient@example.com",
"subject": "Meeting Request",
"body": "Can we schedule a meeting for tomorrow?",
"date": "2024-01-20T10:30:00Z"
}'
Response:
{
"id": "email-12345",
"classification": "BUSINESS",
"confidence": 0.92,
"processing_time_ms": 850,
"auto_reply": true,
"timestamp": "2024-01-20T10:30:05Z"
}
GET /api/email/{id}
Example:
curl "http://localhost:1880/api/email/email-12345"
PUT /api/email/{id}/classification
Content-Type: application/json
Example:
curl -X PUT "http://localhost:1880/api/email/email-12345/classification" \
-H "Content-Type: application/json" \
-d '{
"classification": "URGENT",
"reason": "Time-sensitive content"
}'
GET /api/system/status
Example:
curl "http://localhost:1880/api/system/status"
Response:
{
"status": "healthy",
"services": {
"node-red": "running",
"ollama": "running",
"redis": "running",
"prometheus": "running",
"grafana": "running"
},
"uptime": 86400,
"version": "1.2.0",
"last_update": "2024-01-15T00:00:00Z"
}
POST /api/system/service/{service}/restart
Example:
curl -X POST "http://localhost:1880/api/system/service/node-red/restart"
GET /api/system/metrics
Example:
curl "http://localhost:1880/api/system/metrics"
Response:
{
"cpu_usage": 25.5,
"memory_usage": 1250000000,
"disk_usage": 45.2,
"network": {
"rx_bytes": 1024000,
"tx_bytes": 512000
},
"timestamp": "2024-01-20T10:30:00Z"
}
In .env:
WEBHOOK_URL=https://hooks.slack.com/services/your-webhook-url
WEBHOOK_ENABLED=true
{
"text": "New URGENT email received",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*New URGENT email received*\nFrom: sender@example.com\nSubject: Critical Issue"
}
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "View Email"
},
"url": "http://localhost:1880/email/view/email-12345"
}
]
}
]
}
const axios = require('axios');
class HubMailClient {
constructor(baseUrl = 'http://localhost:1880') {
this.baseUrl = baseUrl;
}
async getEmailStats() {
const response = await axios.get(`${this.baseUrl}/api/email/stats`);
return response.data;
}
async processEmail(emailData) {
const response = await axios.post(`${this.baseUrl}/api/email/process`, emailData);
return response.data;
}
async getSystemStatus() {
const response = await axios.get(`${this.baseUrl}/api/system/status`);
return response.data;
}
}
module.exports = HubMailClient;
import requests
class HubMailClient:
def __init__(self, base_url='http://localhost:1880'):
self.base_url = base_url
def get_email_stats(self):
response = requests.get(f"{self.base_url}/api/email/stats")
return response.json()
def process_email(self, email_data):
response = requests.post(
f"{self.base_url}/api/email/process",
json=email_data
)
return response.json()
def get_system_status(self):
response = requests.get(f"{self.base_url}/api/system/status")
return response.json()