The Dolfin AR Agent lets your users create customers, products, and invoices through natural language. Instead of calling individual endpoints, you send a single user message toDocumentation Index
Fetch the complete documentation index at: https://docs.dolfinai.co/llms.txt
Use this file to discover all available pages before exploring further.
POST /agent/ar and the agent handles the rest.
This guide walks through the same invoice flow as the Quick Start, but driven entirely through the agent.
Prerequisites
- A Dolfin API key
- An organisation already provisioned (see Client Integration)
- A valid session token or API key for authentication
All requests below require the
x-dolfin-api-key and x-dolfin-organisation-id headers. See Authentication for details.How the Agent Works
Every turn is a single POST to/agent/ar with just two body fields:
| Field | Type | Notes |
|---|---|---|
message | string, required | The user’s message for this turn |
conversationId | UUID, optional | Omit on the first turn. Supply on every subsequent turn to continue the same thread |
conversationId.
Response format
The response is atext/event-stream (SSE). Read events as they arrive:
| Event | Payload | When |
|---|---|---|
conversation | { "id": "uuid" } | Fired once, on the first turn only, before any content |
| (unnamed) | { "content": "text chunk" } | Streamed assistant text, one chunk per data frame |
action | Tool action object | When the agent runs a tool (e.g. created a customer) |
| (unnamed) | { "done": true } | Final frame — stream is complete |
{ "error": "message", "done": true }.
Persisting conversationId
On the first request, read the conversation SSE event and save its data.id. Echo that UUID back as conversationId on every follow-up POST to continue the same conversation.
Once the first response returns a
conversationId, the agent type is frozen on that conversation. Sending a request to POST /agent/ap with an AR conversation’s conversationId (or vice versa) returns 409 Conflict.Conversation scoping
Conversations are scoped by:- Organisation — always. A conversation belongs to the organisation in
x-dolfin-organisation-idand can’t be read or continued from another organisation. - User — only when the call is authenticated with a Bearer JWT. API-key calls have no user binding, so any caller with the same API key and organisation can continue an API-key conversation.
Step 1: Create a Customer
This is the first turn, so omitconversationId. The response’s conversation event gives you the ID to use for every subsequent turn.
I’d be happy to help you create a new customer! Please provide the following details: Required:Now continue the conversation by sending the sameOptional:
- Name — The customer’s full name or business name
- Email address
- Phone number
- Tax/VAT number
- Address (line 1, line 2, city, state/county, postal code, country)
conversationId back:
Here’s a summary of the customer I’ll create:Confirm, and the agent runs theShall I go ahead and create this customer?
- Name: Joe Bloggs
- Email: joebloggs@gmail.com
createCustomer tool and emits an action event:
Step 2: Create a Product
SameconversationId, next message.
Here’s a summary of the product I’ll create:After confirmation:Before I proceed, could you confirm:
- Name: Silver Mirror
- Price: £100.00 GBP
- Type: Product
- Is the type correct as Product (rather than Service)?
- Would you like to add a description?
The Silver Mirror product has been created successfully!
Step 3: Create an Invoice
The agent remembers the customer and product from earlier in the conversation — you don’t need to pass any IDs.Here’s a summary of the invoice I’ll create:After confirmation:Shall I go ahead and create this invoice?
- Customer: Joe Bloggs
- Product: Silver Mirror x5
- Total: £500.00 GBP
The invoice has been created successfully!Would you like me to send the invoice to Joe at joebloggs@gmail.com?
- Invoice Number: INV-92631974
- Customer: Joe Bloggs
- Items: Silver Mirror x5
- Total: £500.00 GBP
- Status: Draft
Because the conversation history is loaded server-side from
conversationId, the agent resolves “Joe” and “silver mirrors” to the correct customer and product without you having to track IDs client-side.Step 4: Send the Invoice
Invoice sent successfully!
- Invoice: INV-92631974
- Sent to: joebloggs@gmail.com
- Amount: £500.00 GBP
- Due Date: 14th May 2026
Full Conversation Flow
Here’s the complete exchange from start to finish:| Turn | conversationId sent? | User message |
|---|---|---|
| 1 | No (first turn) | “can you help me create a customer?“ |
| 2 | Yes | ”Joe Bloggs with email joebloggs@gmail.com” |
| 3 | Yes | ”now create me a product called “silver mirror” of price 100 GBP” |
| 4 | Yes | ”create an invoice for Joe with 5x silver mirrors” |
| 5 | Yes | ”Sure, lets send it!” |
Managing Conversations
| Endpoint | Purpose |
|---|---|
GET /agent/conversations?agentType=Ar | List the caller’s AR conversations |
GET /agent/conversations/{id} | Get metadata for a single conversation |
GET /agent/conversations/{id}/messages | Paged message history |
PATCH /agent/conversations/{id} | Rename a conversation |
DELETE /agent/conversations/{id} | Delete a conversation and its messages |
Agent vs Direct API
| Direct API | AR Agent | |
|---|---|---|
| Interface | Individual REST endpoints | Conversational messages |
| ID management | You track and pass IDs between calls | Agent resolves names from conversation history |
| Confirmation | Immediate execution | Agent confirms before acting |
| Best for | Programmatic automation | Interactive user experiences |
Next Steps
Quick Start (Direct API)
See the same flow using direct API calls.
API Reference
Explore the full API reference for all endpoints.