Skip to main content
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 to 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 a text/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-id and 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 omit conversationId. The response’s conversation event gives you the ID to use for every subsequent turn.
SSE stream (excerpt):
The agent asks for details:
I’d be happy to help you create a new customer! Please provide the following details: Required:
  • Name — The customer’s full name or business name
Optional:
  • Email address
  • Phone number
  • Tax/VAT number
  • Address (line 1, line 2, city, state/county, postal code, country)
Now continue the conversation by sending the same conversationId back:
The agent confirms before creating:
Here’s a summary of the customer I’ll create: Shall I go ahead and create this customer?
Confirm, and the agent runs the createCustomer tool and emits an action event:

Step 2: Create a Product

Same conversationId, next message.
The agent confirms the details:
Here’s a summary of the product I’ll create:
  • Name: Silver Mirror
  • Price: £100.00 GBP
  • Type: Product
Before I proceed, could you confirm:
  1. Is the type correct as Product (rather than Service)?
  2. Would you like to add a description?
After confirmation:
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.
The agent looks up the customer and product, then confirms:
Here’s a summary of the invoice I’ll create:
  • Customer: Joe Bloggs
  • Product: Silver Mirror x5
  • Total: £500.00 GBP
Shall I go ahead and create this invoice?
After confirmation:
The invoice has been created successfully!
  • Invoice Number: INV-92631974
  • Customer: Joe Bloggs
  • Items: Silver Mirror x5
  • Total: £500.00 GBP
  • Status: Draft
Would you like me to send the invoice to Joe at [email protected]?
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

The agent sends the invoice and confirms:
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.