BookbagBookbag

Get leads (v1)

POST /agents/:id/leads to capture a lead and GET /agents/:id/leads to read the inbox. Capture fires the lead.created webhook.

View as Markdown

Capture and read leads collected by an agent. Capturing a lead fires the lead.created webhook so your CRM or automation can pick it up.

POST /agents/:id/leads

Public capture endpoint (used by the widget runtime, and callable from your backend). At least one of email, phone, or name is required.

FieldInTypeNotes
idpathintegerThe agent id.
fieldsbodyobjectA free-form object of lead fields. If omitted, top-level email / name / phone are used to build it.
emailbodystringConvenience field, folded into fields. One of email/phone/name required.
namebodystringConvenience field.
phonebodystringConvenience field.
conversationIdbodyintegerOptional conversation this lead came from.
curl https://app.bookbag.ai/agents/123/leads \
  -H "Authorization: Bearer $BOOKBAG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "fields": { "email": "sam@acme.com", "name": "Sam" }, "conversationId": 456 }'

GET /agents/:id/leads

Read the lead inbox for an agent (newest first). Each lead's captured fields are returned as a parsed object.

curl https://app.bookbag.ai/agents/123/leads \
  -H "Authorization: Bearer $BOOKBAG_API_KEY"
tip

A CSV export of all leads is available at GET /agents/:id/leads/export and downloads a file with one column per field seen across leads.

Status codes

StatusMeaning
200Success.
400No usable lead field provided. Body: { success:false, error:{ code:"validation_error", message } }.
401Missing or invalid credentials (reads).
404Agent not found.

See Errors.