Skip to content

docs: add Leads list & search (FIND) API reference - #16

Merged
0xSagaCity merged 2 commits into
mainfrom
docs/leads-find-api
Aug 28, 2026
Merged

docs: add Leads list & search (FIND) API reference#16
0xSagaCity merged 2 commits into
mainfrom
docs/leads-find-api

Conversation

@vaidik2412

@vaidik2412 vaidik2412 commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Documents GET /api/v1/businesses/:urlKey/leads, the list/search endpoint added in refrens/serana#4781 with the Elasticsearch indexing fix in refrens/seeds#65.

Adds a List and Search Leads section to docs/leads.mdx, following the same structure as the existing Create and Edit sections, and updates the page intro to mention listing.

What it covers

  • Pagination and sorting$limit (default 10, max 50), $skip (max 1000), and the four sortable fields.
  • Four filter groups — structured filters matched by name, exact-match lookups, ranges, and free-text search. Multi-value syntax (comma and $in) and match-any-within / match-all-across semantics.
  • RangescreatedAt, followUpDate, budget, plus the followUpDate=none special case and its mutual exclusion with the range bounds.
  • Free-text — that it runs on Elasticsearch, that it reorders results by relevance, and that it returns SEARCH_UNAVAILABLE rather than silently degrading where ES is off.
  • Unknown values vs no matches — a table making the deliberate split explicit: an unknown pipeline or tag is a 400 naming the offending value, while an unresolved id is an empty page.
  • Query safety — the allowlist, the refusal of server-applied fields like business and isRemoved, and the $in-only operator rule.
  • FIND error codes — all twelve, with the condition for each.

Verification

Every documented behaviour was exercised live against prod using the refrens-video-demo business: 21 read-only scenarios plus 6 Elasticsearch probes, all passing. That includes the four ES scenarios serana#4781 listed as environment-blocked (free-text ORing across fields, .keyword filter matching, populate, and relevance sort), which are confirmed working.

Also verified from source that find, get and create all return through the same mapInternalToExternal, so the shape claim in the intro holds, and that optional fields are omitted when a lead has no value for them.

npm run build passes and the section renders correctly.

Review passes applied

An independent reader-effort review (second commit) fixed seven things, most importantly a factual error: the intro said filters fall into three groups while four were documented — ranges were missing from the list. Also: data[0].items is now named in the intro rather than only in the response block; the free-text and assignedTo rules are split so each sentence carries one rule; both followUpDate failure conditions are stated inline in the error table; the duplicated business/isRemoved rule is trimmed to one home; and status is now separated from the CRM-configured filters, since it is a fixed Refrens set rather than business configuration.

Vaidik and others added 2 commits August 28, 2026 15:55
Documents GET /api/v1/businesses/:urlKey/leads, added in refrens/serana#4781.

Covers pagination and sort bounds, the three filter groups (structured,
exact-match, free-text), range parameters, the unknown-value vs no-match
distinction, query-safety guarantees, and the FIND error codes.

Every documented behaviour was verified against prod with the
refrens-video-demo business.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Reader-effort review (DeepSeek):
- Intro said three filter groups but there are four; ranges were missing.
- Named data[0].items up front instead of only in the response block.
- Split the free-text and assignedTo rules so each sentence carries one rule.
- Spelled out both followUpDate failure conditions in the error table.
- Removed the business/isRemoved rule duplicated between intro and Query safety.
- Separated status (a fixed Refrens set) from the CRM-configured filters.
- Pinned the vague 'the environment' for Elasticsearch availability.

Google developer documentation style guide:
- Ampersand out of the heading.
- Dropped 'Note that' and 'simply'.
- Active voice where the actor matters.

Also noted that optional fields are omitted when a lead has no value.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@0xSagaCity
0xSagaCity merged commit 44a3596 into main Aug 28, 2026
1 check passed
@0xSagaCity
0xSagaCity deleted the docs/leads-find-api branch August 28, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants