Retrieval

Answer repeated customer questions from approved sources.

Use a retrieval source bucket to draft or support email answers for common customer questions without creating a separate chat surface.

Token first

Make sure the agent has these scopes.

Create a new token or update the agent's current token before trying the calls below.

Required token scopes

email:read email:send retrieval:read retrieval:write retrieval:run contacts:read files:read

Outcome

What this gives you.

Agents answer recurring customer questions with citations from approved company, inbox, and file context.

Use when

The operational shape.

  • Customers ask the same policy, pricing, onboarding, billing, or operational questions by email.
  • A support or success inbox needs consistent answers without moving the conversation out of email.
  • You want retrieval evidence attached before an agent drafts or a human approves a reply.

API sequence

The calls to make.

01

Create the source bucket

POST/v1/retrieval/source-buckets/

Define the approved sources the answer may use. This can combine public pages, email history, Files folders, contacts, calendar context, and configured intelligence records.

Default example
Keep the bucket narrow enough that answers come from sources the team actually approves.
{
  "name": "Customer answer base",
  "bucket_type": "support_class",
  "owner_type": "tenant",
  "owner_id": "ten_123",
  "sources": [
    {
      "type": "public_web",
      "seed_urls": ["https://example.com/help"],
      "allowed_domains": ["example.com"],
      "max_pages": 50
    },
    {
      "type": "email",
      "inbox_id": "inb_support",
      "label_id": "lbl_answered"
    },
    {
      "type": "files",
      "folder_id": "fld_support_docs",
      "include_children": true
    }
  ]
}
02

Estimate and index

POST/v1/retrieval/source-buckets/{bucket_id}/estimate/

Show expected indexing size and AI cost before queueing the indexing job.

Default example
Use this as the default shape for this step.
{
  "force": false,
  "sensitive_source_approved": false
}
Queue indexing
Run this only after the estimate is acceptable.
{
  "force": true,
  "sensitive_source_approved": true,
  "chunks": [
    {
      "source_type": "email",
      "text": "Customer support policy and onboarding notes."
    }
  ]
}
03

Run retrieval for a customer email

POST/v1/retrieval/runs/

Ask against the source bucket using the current email and contact as context.

Default example
Use this as the default shape for this step.
{
  "bucket_id": "rb_support_answers",
  "query": "What should we tell this customer about invoice payment timing?",
  "task": "email_answer",
  "inbox_id": "inb_support",
  "context": {
    "message_id": "msg_123",
    "thread_id": "thr_123",
    "contact_id": "ctc_123",
    "subject": "Invoice timing question"
  },
  "output_type": "evidence"
}
04

Send or hold the reply

POST/v1/messages/

Use the retrieval answer as evidence for a reply. Tokens configured with approval requirements will hold the send for review.

Default example
Keep answer delivery in email. There is no separate retrieval chat primitive in v1.
{
  "reply_to_message_id": "msg_123",
  "to": [{"email": "customer@example.com"}],
  "text_body": "Thanks for asking. Based on our payment policy, invoices are due within 15 days unless the agreement says otherwise."
}

Controls

Review points.

  • Source buckets are configured independently, then referenced by retrieval runs and workflows.
  • Retrieval runs have zero direct retrieval-unit cost; answer generation and embeddings are billed through the normal AI usage model.
  • Use approval-gated sending when answers affect contracts, billing, legal commitments, or sensitive customer state.