Outbound calls and campaigns limit concurrency
# support
c
Hi, I have some questions about outbound calls. The initial idea was to launch campaigns, since they manage concurrency limits, but the problem is that I'll have to launch calls through a webhook, so they would be campaigns with few calls, and it's not feasible to create many campaigns of 1 or 2 calls. Therefore, I would have to focus on creating calls without campaigns, which, from what I've read in the documentation and on the Discord server, I would have to manage internally to avoid reaching the concurrent limit and prevent calls from getting stuck. So far, so good. What I don't know is how to manage this. If, for example, I manage how to launch calls from a phone number, controlling the limit, and I also launch one or more campaigns of, say, 1000 calls (because the campaign already manages the calls from the same VAPI), would calls be created simultaneously and then canceled due to the concurrency limit? When I create calls through the API, do concurrency errors occur before the call is created, or can they occur after it has been created?
v
To manage concurrency when launching outbound calls via the API, implement a simple rate limiter to ensure you do not exceed your Vapi org's concurrent call limit. For example, using JavaScript:
Copy code
js
const MAX_CONCURRENCY = 10; // your Vapi org limit
let activeCalls = 0;
const queue = [];

function launchCall(callData) {
  if (activeCalls < MAX_CONCURRENCY) {
    activeCalls++;
    vapi.calls.create(callData).finally(() => {
      activeCalls--;
      if (queue.length) launchCall(queue.shift());
    });
  } else {
    queue.push(callData);
  }
}
This pattern ensures you never exceed your concurrency limit, even when mixing campaigns and direct API calls. For large campaigns, Vapi will queue calls automatically, but for direct API calls, you must manage this logic yourself to avoid errors or dropped calls. Reference: See the concurrency section in the [Outbound Campaigns Overview](https://docs.vapi.ai/outbound-campaigns/overview). Source: - [Outbound campaigns overview](https://docs.vapi.ai/outbound-campaigns/overview)