Add chat to your app
Chat calls use a tenant chat key (see Platform tenants). Keep that key on your server and call UAVCrew from your backend; never ship a key to the browser.
Create a conversation
Section titled “Create a conversation”POST /v1/chat/conversationsX-API-Key: uav_...Content-Type: application/json
{ "title": "N482SK pre-flight", "agent_slugs": ["concord"], "context": { "focus": { "entity": "aircraft", "id": "8f1c...", "name": "N482SK" } }}agent_slugs adds agents to the conversation. Add more than one and they can hand the conversation to each other; you will see a handoff_announce event when that happens.
Send a message
Section titled “Send a message”POST /v1/chat/conversations/{conversation_id}/messages
{ "content": "Is this aircraft ready to fly tomorrow?", "tenant_id": "acct_4821", "agent": "concord", "client_message_id": "msg_01J9...", "context": { "source": "https://app.example.com/aircraft/8f1c", "page": { "title": "Aircraft detail", "description": "Registration, inspections and flight history for one aircraft", "actions": ["Edit aircraft", "Log inspection"] }, "focus": { "entity": "aircraft", "id": "8f1c...", "name": "N482SK" } }}| Field | Notes |
|---|---|
content |
Required. The user’s text. |
tenant_id |
Required. Must equal the external_id of the tenant your key belongs to. |
agent |
Which agent replies. Required unless automatic routing is enabled for your organization. |
ai_mode |
chat (read only, default) or agentic (may propose changes). |
client_message_id |
Your own ID, echoed back so you can match optimistic UI to the stored message. |
context |
What the user is looking at. Agents use it to resolve “this aircraft” or “this mission”. |
The response is your stored message. The agent’s reply arrives on the event stream.
Give the crew page context
Section titled “Give the crew page context”Context is the difference between a generic answer and a useful one:
focus— the one record the page is about. Omitidfor the company record.related— other records on screen, such as the pilot assigned to a flight.page.actions— what the user can do on this page, so the agent can point them to the right button.attachments— files the user wants the agent to consider.
Load history
Section titled “Load history”GET /v1/chat/conversations/{conversation_id}/messages returns the conversation’s messages, oldest first. Use it to render a conversation when the user reopens it, then subscribe to the stream for new messages.
Collect feedback
Section titled “Collect feedback”POST /v1/chat/conversations/{conversation_id}/messages/{message_id}/feedback
{ "thumbs": false, "comment": "It missed the expired Part 107 certificate." }Send thumbs, a rating from 1 to 5, or both. Feedback appears in the dashboard and helps us tune the crew.
Generated documents
Section titled “Generated documents”Agents can produce PDF or DOCX files, such as a compliance summary. The message’s tool_data carries the document ID. Request a short-lived link when the user clicks download:
POST /v1/documents/{doc_id}/download-urlThe response has url, filename, format and expires_in (seconds). Documents expire; an expired one returns 410.
