Overview¶
Note
AI Context
Complexity: Low
Cost: Free. These endpoints change settings only. A charge happens when a number is purchased through
POST https://api.voipbin.net/v1.0/numbers.Async: No. Every request returns the updated provider immediately.
Access: ProjectSuperAdmin only. Customer-level tokens, access keys and direct tokens are refused.
The Number Provider API manages the carriers that VoIPBin purchases phone numbers from. It is different from /providers, which manages the SIP trunks used to route calls.
With the Number Provider API you can:
List the carriers the platform supports and see which of them can serve now
Enable or disable a carrier for number purchase
Set the purchase order (a lower
priorityis tried first)Set the non-secret settings of the carrier (
config)See whether the carrier secret is present (the secret itself is set as an environment variable of the platform, not through this API)
How Providers Are Chosen¶
When a number is purchased, VoIPBin tries the carriers that are usable in ascending priority (ties are ordered by provider_name). A carrier is usable when it is enabled, has its secret in the environment, and has all the config keys it requires (twilio needs sid and trunk_sid).
VoIPBin falls back to the next carrier only when the current carrier definitively refused the order. If the outcome of an order is unknown (for example a timeout), the purchase stops instead of ordering from another carrier, so a number is never bought twice. To route around a failing carrier, disable it.
A fallback is useful only when the next carrier holds the same number. The available number search currently covers telnyx only.
Note
AI Implementation Hint
telnyx and twilio can purchase numbers. twilio is listed with enabled false and takes part in a purchase only after its TWILIO_AUTH_TOKEN is set on the platform, its config (sid and trunk_sid) is complete (sid can come from TWILIO_ACCOUNT_SID), and an administrator enables it. A carrier without its secret variable cannot purchase, release or search.
Sending Messages¶
SMS and MMS are sent through the carrier that owns the source number first. The carrier of a number is the provider_name of the number. The other carriers (telnyx, messagebird) only get the targets that the first carrier definitively refused. A number without a carrier, or a carrier that cannot send messages, uses the default order (telnyx, then messagebird). If the outcome of a send is unknown (for example a timeout), the target is not sent through another carrier, so a message is never delivered twice.
twilio sends messages only when TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN are both set on message-manager, and it is used for the numbers that twilio owns only (it is not a fallback of a telnyx or messagebird number). MMS through twilio is limited to +1 numbers (the United States and Canada). Delivery status comes back through the Twilio status callback (/v1.0/messages/twilio on the hook endpoint), which is verified with the Twilio signature. The priority and enabled of the settings do not apply to sending messages.
Credentials¶
The secret of a carrier is read from the environment of number-manager only: TELNYX_API_KEY for telnyx and TWILIO_AUTH_TOKEN for twilio. Change the environment variable and restart number-manager to rotate a secret.
The non-secret config of the stored setting is used first. A config key that the stored setting does not have (or has empty) is filled from the environment: connection_id from TELNYX_CONNECTION_ID, profile_id from TELNYX_PROFILE_ID and sid from TWILIO_ACCOUNT_SID. trunk_sid has no variable. An unset, empty or unresolved placeholder variable (a value that starts with [[) counts as not set. The config in a response shows the stored setting only, so a provider that is usable only through the variables shows an empty config. A config value that is stored hides a changed variable, so check the config after a change of TELNYX_CONNECTION_ID, TELNYX_PROFILE_ID or TWILIO_ACCOUNT_SID.
credential_source tells where the secret comes from:
env: the secret variable of the provider is set.none: the secret variable is not set. The carrier is not usable until it is set.
db and db_undecryptable are no longer returned, because a secret is read from the environment only. They stay in the list of values so that an older client keeps working.
has_secret tells whether the secret variable holds a value. The secret is never returned, logged or sent in an event.
Warning
Changing the account
Numbers are released through the account that purchased them. Replacing the secret variable with the token of another account (or, for twilio, the sid of another account) makes the release of the numbers bought through the previous account fail. Change the account only when no number of that provider remains, or when the new secret belongs to the same account.
Errors¶
Status |
Meaning |
|---|---|
400 |
The request is invalid: a body with none of |
401 |
The request is not authenticated. |
403 |
The caller is not a ProjectSuperAdmin, or uses a direct token. |
404 |
The provider is unknown. |
The response of an error does not say which rule failed, so check the list above when you get a 400.
Concurrent changes¶
Changes to the config of the same provider are not serialized. If two administrators change it at the same time, the last write wins.