Ship server-to-server chat, stream tokens to your own UI, and fire automations from webhooks that terminate on your FlexyAgents host. The routes below are the real Next.js handlers—copy values from Deployment after you generate a FlexyAgents API connection.
Need keys first? Create a workspace and open Settings → API Keys or the agent's connection modal.
HTTP surfaces at a glance
Paths mirror the Next.js route tree. Replace placeholders with the agent ID and host from your deployment screen.
Send a JSON body with a messages array (role + content) and optional stream flag. Bearer auth validates against the FlexyAgents API key you store on the agent connection; successful key auth resolves the organization automatically.
Published automations can expose webhook URLs that deserialize payloads and call executeAutomation—useful when your own services need to kick off flows without OAuth.
Sibling routes under /api/webhooks handle WhatsApp, Instagram, Facebook Messenger, inbound email, and similar vendor callbacks so omnichannel deployments stay on your domain.
Configure signed outbound webhooks from the dashboard when you want FlexyAgents to push conversation or system events to your SIEM, data lake, or ticketing bridge.
Minimal non-streaming call
curl -X POST "https://YOUR_APP_HOST/api/agents/AGENT_ID/chat" \
-H "Authorization: Bearer YOUR_FLEXYAGENTS_API_KEY" \
-H "Content-Type: application/json" \
-d '{"messages":[{"role":"user","content":"Hello"}],"stream":false}'Swap in the values copied from Deployment → API after you connect the FlexyAgents app on that agent.
Invoke
The deployment screen copies a curl snippet against your live host. Under the hood the handler validates API keys with the automation connection store, loads behavior + knowledge, and increments usage like any other channel.
Bodies must include at least one chat turn. The executor trims history to the latest user message for retrieval while still accepting multi-turn arrays for future use.
Set stream: true to receive NDJSON chunks (one JSON object per line) that frontends can flush to UI as tokens arrive.
Service accounts should use the FlexyAgents connection key generated per agent. Interactive testers can rely on authenticated dashboard sessions, but server-to-server calls should always use Bearer tokens.
Redis-backed rate limits return 429 when traffic spikes. Plan enforcement adds MESSAGE_LIMIT_REACHED for hosted/BYOK monthly caps and token ceilings for hosted inference.
Events
Inbound routes normalize vendor signatures while outbound configuration lives next to other integrations. Automations can also POST arbitrary HTTP within a flow.
When a flow publishes a webhook trigger, FlexyAgents stores the path segment and verifies payloads before calling executeAutomation with the parsed body.
WhatsApp, Instagram DMs, Messenger, and inbound email each register public HTTPS endpoints so Meta, Twilio, or mail providers can verify and deliver events.
Automation actions can POST or PUT to customer-owned URLs with templated bodies—think “notify Opsgenie” or “create Jira ticket” without waiting for a first-party connector.
Reference
Marketing pages stay narrative; engineers should rely on the docs site, inline OpenAPI definitions in the repo, and the deployment page snippets that always match your tenant IDs.
Start from /docs for conceptual guides, then cross-link to the developer-focused /api page for quick starts, authentication primers, and tabbed references when available.
The repository carries a comprehensive OpenAPI document describing auth schemes, chat payloads, and ancillary REST resources—generate clients or import into Postman from that file.
Not every experience needs raw REST—the embeddable script calls the same chat endpoint with visitor context. Pair API access with the widget when you want web self-service plus backend jobs.
Pair APIs with Automations, Channels, and governance on Analytics.
Next step
Generate the FlexyAgents connection key, paste it into your secret store, and aim automation webhooks at the paths you own. When you are ready, wire observability into the same analytics workspace your success team already uses.