Build your integration / Manage the AI Knowledge Base
GUIDE

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

  1. Send only the settings you want to change. Send null to clear a business field that accepts it.
  2. Optional: to avoid overwriting someone else's edit, also send the data.version from your last read as expectedVersion. If the settings changed since, the save returns 409 VERSION_CONFLICT and nothing changes. Leave it out to save over the latest settings.
  3. Use data.historyChangeId to find the change in AI Behavior History, where it can be undone. This ID is null when 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 serviceAreas replaces 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 includes isServiceable and any matching rules. If the account has no rules, the check returns NO_SERVICE_AREAS.
  • When you send businessHoursSettings, include the exposeToAi setting 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 calendarTimezoneSync when 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.

Guides & API endpoints Esc to close