Limits & Quotas

The xander API enforces three consumption limits, to protect service stability and to give every customer fair access. This page explains what each limit does, what it is scoped to and how the API tells your application that you are approaching or exceeding a limit.

What is limited

Limit Purpose Scope
Rate limit Short-term burst protection. Caps how many calls you can issue in a sliding window of seconds and minutes. Read calls (job status) have their own, more generous window than uploads and job starts. Per Service Principal (your Client ID).
Quota Long-term consumption budget. Caps the number of calls per day. Per Service Principal (your Client ID).
Concurrency Caps how many calls may be in flight at the same time. Per Service Principal (your Client ID).

All three limits are tied to your Service Principal, specifically to the azp or appid claim in your access token, which is also the billing key. Two applications of the same organisation with their own Service Principals therefore have their own independent limits.

Where are the actual numbers?

The concrete values for rate limit, quota and concurrency differ per customer and depend on your agreement with XWare Pulse. Your current values and any increase come from your xander contact or xander@xwr.ch. The state of the rate-limit window is reported by the API on every call (see below), so you always see your headroom.

How the API tells you about your current state

Response headers on every call

Every response carries headers that let you reason about the rate-limit window without extra calls:

HeaderMeaning
RateLimit-Limit Maximum number of calls in the current window.
RateLimit-Remaining Calls left in the current window before the API throttles you.
Retry-After Only on 429: seconds until the next permitted call.

Use these headers in your client to track headroom and slow yourself down before the server has to throttle you.

Rate limit reached

Throttled calls come back as HTTP 429 Too Many Requests with a Retry-After header that says how many seconds to wait:

HTTP/1.1 429 Too Many Requests
Retry-After: 7
RateLimit-Limit: ...
RateLimit-Remaining: 0
Content-Type: application/json

{ "statusCode": 429, "message": "Rate limit is exceeded. Try again in 7 seconds." }

The correct behaviour on 429: read Retry-After, wait that many seconds, then retry. No aggressive exponential backoff that ignores the header; the server tells you exactly when it is safe to come back.

Daily quota reached

When your daily budget is exhausted, the API answers HTTP 403 Forbidden with a message saying when the quota is replenished. Unlike the rate limit, the quota does not heal in seconds, it resets at the end of the daily window. Until then your Service Principal cannot make any calls. The right reaction:

  1. Stop issuing calls for that Service Principal until the next window opens.
  2. Check whether the usage was expected (runaway loop, misconfigured schedule).
  3. If the usage is legitimate and you need more, talk to your xander contact about an increase.

Concurrency reached

Concurrency is evaluated per call. If you have N calls in flight and start another one, the gateway rejects it with HTTP 429. The right behaviour:

  • Reduce the parallelism in your application (smaller worker pool, smaller batches).
  • Or: front your calls with a semaphore that keeps in-flight calls just below your agreed concurrency.

Example: a defensive HTTP client

Minimum behaviour of a production-ready xander client, here in C#; the pattern is the same in any language:

async Task<HttpResponseMessage> CallXanderAsync(string path, object body, CancellationToken ct)
{
    while (true)
    {
        using var request = new HttpRequestMessage(HttpMethod.Post, $"{xanderBaseUrl}{path}");
        request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", await GetAccessTokenAsync(ct));
        request.Content = JsonContent.Create(body);

        var response = await http.SendAsync(request, ct);

        // Track headroom and slow down before being throttled.
        if (response.Headers.TryGetValues("RateLimit-Remaining", out var remaining)
            && int.TryParse(remaining.First(), out var left) && left < 5)
        {
            await Task.Delay(TimeSpan.FromMilliseconds(500), ct);
        }

        if (response.StatusCode == HttpStatusCode.TooManyRequests)
        {
            var wait = response.Headers.RetryAfter?.Delta ?? TimeSpan.FromSeconds(5);
            await Task.Delay(wait, ct);
            continue;
        }

        if (response.StatusCode == HttpStatusCode.Unauthorized)
        {
            // Token expired: refresh once, then retry.
            InvalidateToken();
            continue;
        }

        return response;
    }
}

Tips for staying within your limits

  • Cache your access token. A token is valid for about 60 minutes. Caching saves the token calls and reduces latency on every call.
  • Bound parallelism explicitly. A semaphore in your client keeps in-flight calls comfortably below your agreed concurrency.
  • Watch RateLimit-Remaining. If it is consistently low, you are either sized too tight or your application retries more than necessary. Investigate first, then ask for an increase.
  • Do not retry on 4xx. A 400 or 422 means the server understood your request and rejected it for content reasons. A retry gets the same answer and burns rate-limit budget. Retry only on 429 and 5xx.
  • Announce large volumes in advance. Before processing a historic backlog or running a one-off migration, talk to your xander contact so the limits are sized appropriately.