API & SDK
API Reference
HTTP API for integrating M-TEH into any application. All endpoints accept and return JSON. Authentication via M-TEH Key in the request header or body.
Authentication
Each integration has a unique M-TEH Key in the format mth_....
Pass it in the key body field or in the header:
HeaderAuthorization: Bearer mth_abc123...
The M-TEH Key is an integration key, not a provider key. Provider keys (OpenAI, Claude, etc.)
are stored server-side and never exposed to the client.
POST /api/chat
Main endpoint for sending messages. Used by the widget and direct integrations.
Request
POST /api/chat{
"key": "mth_abc123...",
"session": "nx-a1b2c3...",
"message": "Your question",
"pipeline_id": 5
}
Response
200 OK{
"reply": "Assistant response...",
"session": "nx-a1b2c3...",
"tokens": 42
}
Errors
| Code | Reason |
|---|---|
| 400 | Missing required field (key or message) |
| 401 | Invalid or inactive API Key |
| 404 | Pipeline with the given pipeline_id not found |
| 429 | Rate limit exceeded for your plan |
| 502 | Error when requesting the AI provider |
POST /api/webhook/{key}
Triggers a pipeline with a trigger_webhook trigger node on an incoming POST request.
POST /api/webhook/mth_abc123{
"event": "new_order",
"order_id": 12345,
"amount": 4990
}
Code examples
cURL
Shellcurl -X POST https://your-domain.com/api/chat \
-H "Content-Type: application/json" \
-d '{
"key": "mth_abc123...",
"session": "user-42-session-1",
"message": "What is the shipping cost?"
}'
JavaScript (fetch)
JSconst res = await fetch('https://your-domain.com/api/chat', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
key: 'mth_abc123...',
session: localStorage.getItem('nx_session') || crypto.randomUUID(),
message: userMessage
})
});
const { reply, session } = await res.json();
localStorage.setItem('nx_session', session);
Python
Pythonimport requests, uuid
resp = requests.post('https://your-domain.com/api/chat', json={
'key': 'mth_abc123...',
'session': str(uuid.uuid4()),
'message': 'Help me choose a plan'
})
print(resp.json()['reply'])
Rate Limits
| Plan | Requests/min | Requests/month |
|---|---|---|
| Free | 10 | 500 |
| Starter | 60 | 10,000 |
| Pro | 300 | 100,000 |
| Enterprise | Unlimited | Unlimited |