The API reads and writes your company's own Fledge database: the one the people in the company work in all day. An integration that asks too much slows Fledge down for everyone, or reaches the rate limits.
Writing code with an AI assistant? The Fledge MCP server gives it these rules as a skill, see Build with an AI assistant.
Read
- Ask for totals, not rows. Counts, sums and charts come from
$applywithgroupbyandaggregate: the API computes them, and the answer is a few rows. See Reading data. - Only the fields you use. Always
$select.$expandonly with its own$select, and a list only with a$top. - Filter in the API. Filter on the period, the status or the key you need, and always on
administration_id. Never read a table to filter it in your code. - Small pages. Follow
@odata.nextLink, or use$topup to 100 with$skipand an$orderbyon the key. - One request at a time. Wait for an answer before the next request. Don't loop over customers or articles with a request each: filter or group on them in one request.
Don't copy Fledge
There is no reliable way to read only the rows that changed since the last time. So a "sync" that copies tables and polls for changes reads everything again and again.
- Read the data a screen or a job needs, for the period it shows, when it needs it.
- Keep an answer for as long as it can't change: closed periods for a day or longer, articles and relations for hours, open work for minutes.
- A job that refreshes runs every 15 minutes at most, or at night. Never poll in a loop.
- A copy for reporting or BI is not a job for the API. Ask Fledge for an export.
Tokens and errors
- Reuse the access token until it expires or the API answers
401. See Authentication. - On
429or503, wait as long asRetry-Aftersays, else back off: one second, then double. - On a
5xx, retry at most a few times, then stop and report it. - Never retry a
4xx(except401once with a new token, and412after reading the row again): the request is wrong.
Before you go live
- Every request has
$select, and a filter onadministration_idwhere the set has it. - No loop with a request per row, and no requests in parallel.
- Answers are cached with a lifetime; no polling more often than every 15 minutes.
- The token is reused;
429,503and5xxare handled as above. - The API key is in a secret store, and its user has only the licenses the integration needs.
- The integration uses the stable version URL, and someone plans the move to each new stable version every few weeks (see Versions).