API Token Quota and Usage Measurements

Each request to the Infusionsoft REST API is returned with a number of informational headers to allow you to tune your frequency of requests and determine your remaining quota for a period. You can use these header values to determine how many concurrent calls you should be making to the API, even if operating a stateless cluster with many instances making calls via the same ClientId.

The quota-descriptive headers are:

Header NameTypeExDescription
X-Apigee-Product-Quota-LimitInteger“150000”The maximum bucket size of requests before they will begin to be rejected.
X-Apigee-Product-Quota-Time-UnitString“day”The rolling period over which the bucket applies, currently “day” for all packages.
X-Apigee-Product-Quota-IntervalInteger“1”The rolling period over which the bucket applies, currently “1” for all packages.
X-Apigee-Product-Quota-AvailableInteger“149999”The total remaining calls in your quota for the rolling period.
X-Apigee-Product-Quota-UsedInteger“1”The number of calls that have been made against the bucket during the period.
X-Apigee-Product-Quota-Expiry-TimeInteger“158663200”The timecode at which the quota bucket will be fully drained.

The spike-throttling descriptive headers are:

Header NameTypeExDescription
X-Apigee-Product-Throttle-LimitInteger“1500”The maximum number of calls that may be made inside the throttle period.
X-Apigee-Product-Throttle-Time-UnitString“minute”The time unit for the reset period of the throttle. Currently “minute” for all consumers.
X-Apigee-Product-Throttle-IntervalInteger “1”The reset period for the throttle. Currently “1” for all consumers.
X-Apigee-Product-Throttle-AvailableInteger “1499”The number of calls remaining during the throttled period.
X-Apigee-Product-Throttle-UsedInteger “1”The number of calls that have been made against the throttle during the period.

By capturing the above returned Headers (specifically “X-Apigee-Product-Throttle-Available” and “X-Apigee-Product-Quota-Available”) on each request it is possible to slow the rate of requests based on how close you are to hitting throttle limits or to generate internal log events to warn that spikes or quota limit hits are occurring.

Many HTTP client libraries support extending their request mechanisms to patch in functions to do this. An example for Axios, a popular Javascript framework would be similar to:

const axios = require("axios");
axios.interceptors.response.use((response) => {  
  if(Number(response.headers["X-Apigee-Product-Throttle-Available"]) < 100){
    // Set whatever triggers/variables are necessary
  return response;
}, (error) => {
  return Promise.reject(error);

axios.get(url).then(function (response) {
  // Go about your normal processing