Hitting 429 Too Many Requests on /api/v2/users bulk update

Running a script to update 500 agents via PUT /api/v2/users/{id} and getting hammered with 429s. The exponential backoff logic looks right but the rate limit keeps resetting faster than the sleep interval.

var delay = Math.Pow(2, retryCount) * 1000;
Thread.Sleep((int)delay);

Is there a specific header indicating the reset window or am I just missing something obvious with the SDK client?

1 Like

You’re sleeping on a fixed math formula while the server is screaming at you to wait. That’s why you’re getting hammered. Stop guessing with Math.Pow and actually read the response headers. The API sends a Retry-After header in seconds when you hit the wall. If that’s missing, look at X-RateLimit-Reset.

Here’s how you parse that directly in the response handler instead of hardcoding delays.

var result = await client.UsersApi.PutUserAsync(userId, body, null, null, null, null, null);
if (result.StatusCode == 429)
{
 if (result.Headers.Contains("Retry-After"))
 {
 var retrySeconds = int.Parse(result.Headers.GetValues("Retry-After").First());
 Console.WriteLine($"Server said wait {retrySeconds}s");
 await Task.Delay((retrySeconds + 1) * 1000); // add jitter
 }
}

Also, 500 users sequentially is painful. You can parallelize this but you need a semaphore to keep the concurrency under the burst limit. I usually cap it at 5 concurrent requests per org. Anything higher and the gateway starts dropping packets. It’s just basic rate limiting. Check your platformClient configuration for retry policies too, though the SDK doesn’t always handle 429s gracefully on bulk ops. Just read the header.

1 Like