Manage the AI Knowledge Base
Use the Knowledge Base API to update what LeadTruffle agents know about the business, where it works, and when it is open. See the Knowledge Base reference for every field and its limits.
| Task | Endpoint | Scope |
|---|---|---|
| Read business details | GET /v2/pub/knowledge-base/business |
knowledge:read |
| Edit business details | PATCH /v2/pub/knowledge-base/business |
knowledge:write |
| Read ZIP rules | GET /v2/pub/knowledge-base/service-areas |
knowledge:read |
| Replace ZIP rules | PATCH /v2/pub/knowledge-base/service-areas |
knowledge:write |
| Check a ZIP code | POST /v2/pub/knowledge-base/service-areas/check |
knowledge:read |
| Read hours and timezone | GET /v2/pub/knowledge-base/business-hours |
knowledge:read |
| Edit hours and timezone | PATCH /v2/pub/knowledge-base/business-hours |
knowledge:write |
Use the X-API-Key header. Unrestricted keys have both scopes. Both scopes are needed to read and edit with a restricted key.
Edit settings
- Send only the settings you want to change. Send
nullto clear a business field that accepts it. - Optional: to avoid overwriting someone else's edit, also send the
data.versionfrom your last read asexpectedVersion. If the settings changed since, the save returns409 VERSION_CONFLICTand nothing changes. Leave it out to save over the latest settings. - Use
data.historyChangeIdto find the change in AI Behavior History, where it can be undone. This ID isnullwhen nothing changed.
curl --request PATCH \
--url 'https://pub-api.leadtruffle.com/api/v2/pub/knowledge-base/business' \
--header 'X-API-Key: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"companyProductOfferings": "We clear drains and repair water heaters."
}'
ZIP rules and hours
- Sending
serviceAreasreplaces the whole list, up to 500 rules. Send[]to clear the list. A ZIP rule can include or exclude an exact US ZIP code or cover a radius up to 500 miles. Exclusions take precedence when both match. - To check a ZIP, send
{"customerZipcode":"02139"}. The result includesisServiceableand any matching rules. If the account has no rules, the check returnsNO_SERVICE_AREAS. - When you send
businessHoursSettings, include theexposeToAisetting and one entry for each day. These hours tell agents when the business is open. Appointment availability comes from the booking calendar. - Changing the timezone also updates active LeadTruffle calendars and applicable availability settings for connected CRMs in LeadTruffle. The response includes counts in
calendarTimezoneSyncwhen the timezone changes.
| HTTP | What to do |
|---|---|
| 400 | Check the named fields or add ZIP rules before checking a service area. |
| 401 or 403 | Check that the key is active and has the scope for the operation. |
409 VERSION_CONFLICT |
Only when you sent expectedVersion: read the settings again and reapply the edit. error.currentVersion identifies the version that rejected your edit. |
| 429 | Wait for Retry-After. Knowledge Base edits count toward both the 600 API requests and the 120 shared write requests allowed per company per 10 minutes. |
| 503 | Retry a read. For an edit, read the settings first to see whether it was saved. |