SIP trunks don’t have fixed numbers of channels. Any such limit is a commercially applied constraint, or the result of limited bandwidth. Asterisk will have no idea of what limits apply.
If you acquired a limited amount of simultaneous channel’s, you can use GROUP_COUNT() to sum your trunk usage and check/update for every inbound/outbound trunk call.
Thanks, I used this function to build the solution. Basically I control the amount of channels hired for the SIP trunk and didn’t send more calls to it if was in the max limit.