API (gql? rest?) "get next available extension"?

is anyone aware of an existing GraphQL or Rest API that would do something similar to:
a) given a starting extension number, return the next available/unassigned extension?
— given 2100, check 2100…in use. 2101? in use. 2102? in use. 2103? Free!

b) fetch/return all extensions WITHIN A RANGE.
i know there’s a fetchAllExtensions graphql API, but I don’t see limits on there. our departments are boxed to specific ranges, so i’d love to return (2100-2199), so I can filter those locally for the next free extension.

Trying to speed up / automate our new user onboarding and getting frustrated.

Need to check other things also like ring groups, queues, etc.

true…
for a logical layout, i would argue you should keep non-human extensions in a different range than human extensions (i.e. 1xxx are queues, 2xxx are attendants, 3xxx-9xxx are humans…) but thats a very good point.

For a logical layout to others, the Parts queue is 5150, and the parts department extensions are 5151-5059, the Service queue is 5160, etc.

good point. any API for this would definitely have to check all of the various types of things that can use an Extension number.