POST /v1/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:
You do not send the full message history — Dolfin persists the conversation server-side and the agent loads it automatically from
conversationId.
Response format
The response is atext/event-stream (SSE). Read events as they arrive:
On error, the final frame is
{ "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 /v1/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: [email protected]
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 [email protected]?
- 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: [email protected]
- Amount: £500.00 GBP
- Due Date: 14th May 2026
Full Conversation Flow
Here’s the complete exchange from start to finish:Managing Conversations
Agent vs Direct API
Next Steps
Quick Start (Direct API)
See the same flow using direct API calls.
API Reference
Explore the full API reference for all endpoints.