Partner API
For platforms that run aichat.md for their own customers: create workspaces, build the agent, connect Facebook/Instagram and sign the owner in.
Two kinds of keys
A partner key (aik_partner_…, issued by aichat.md) works only on /partner/* and only for workspaces that partner created; any other workspace answers 404. A workspace key (aik_live_…) is returned once when you create a workspace and works with the normal API of that workspace.
1. Create a workspace
curl https://aichat.md/api/public/v1/partner/workspaces \
-H "Authorization: Bearer $AICHAT_PARTNER_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: agency-1842" \
-d '{"company_name": "Agentia Soare", "email": "owner@soare.example", "phone": "+373 69 000 111",
"locale": "ro", "external_ref": "agency-1842"}'- The owner gets our invitation e-mail and sets their own password on aichat.md. You never see or set passwords.
external_refis unique per partner (409 workspace_exists);Idempotency-Keymakes retries safe.GET /partner/workspaces,GET|PATCH /partner/workspaces/{id}(name,external_ref,sso_login),POST …/invitation(resend),POST …/api_keys.
2. Agent from the travel agency template
curl https://aichat.md/api/public/v1/agents \
-H "Authorization: Bearer $AICHAT_WORKSPACE_KEY" \
-H "Content-Type: application/json" \
-d '{"template": "travel_agency", "locale": "ro",
"variables": {"company_name": "Agentia Soare", "phone": "+373 22 000 000",
"hours": "L-V 9-18", "price_tool": "get_prices"}}'RO or RU. Asks destination, dates, people and departure city in one message, takes name and phone first, never invents hotels or conditions, quotes prices only from your price tool and sets price_policy: tool_only. Knowledge (address, hours, FAQ): POST /knowledge/sources.
3. Price tool with a secret header
curl https://aichat.md/api/public/v1/agents/agt_…/tools \
-H "Authorization: Bearer $AICHAT_WORKSPACE_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "get_prices", "description": "Live trip price: destination, dates, adults, children ages.",
"parameters": {"type": "object", "properties": {"destination": {"type": "string"},
"date_from": {"type": "string"}, "adults": {"type": "integer"}}, "required": ["destination"]},
"url": "https://api.partner.example/agencies/1842/prices",
"headers": {"Authorization": "Bearer <per-agency token>"}}'https on a public host only (checked at save and on every call). Header values are stored encrypted and never returned. PATCH merges headers: a string sets, null removes.
4. Price guard
With price_policy: tool_only every amount in a reply must come from a tool result of the same turn. Otherwise the reply is regenerated once; if it still has an unbacked amount, that sentence is removed and the agent offers to send the exact price. Widget, Messenger and Instagram.
5. Facebook / Instagram and panel sign-in
curl https://aichat.md/api/public/v1/partner/workspaces/ws_…/connect_links \
-H "Authorization: Bearer $AICHAT_PARTNER_KEY" \
-H "Content-Type: application/json" \
-d '{"channel": "facebook", "return_url": "https://app.partner.example/aichat/connected"}'- Connect link: one use, 15 minutes;
return_urlmust be on your registered domains; the customer comes back withaichat_status=connected|error,channel,workspace_id. - Login link: one use, 60 seconds; only after the owner accepted the invitation and allowed partner sign-in (checkbox on the invitation page, revocable), with SSO enabled and no two-factor sign-in on the account. Every use is audit-logged.
A sandbox partner never e-mails customers, never calls Meta and gets capped credits.