Acquistare e rilasciare un numero
Acquistare un numero richiede due chiamate: cerca in un paese cosa è in vendita, poi ordina quello che vuoi. Tutto ciò che segue richiede una chiave API con lo scope numbers, e il primo acquisto in un'organizzazione richiede la verifica dell'identità.
Cercare in un paese
La ricerca è sempre limitata a un singolo paese, quindi country_code è obbligatorio. Restringi ulteriormente con number_type, capabilities o un prefix di cifre nazionali.
// The search is always country-scoped, so country_code is required.
const page = await bird.numbers.available.list({
country_code: "GB",
capabilities: ["sms", "voice"],
});
for (const candidate of page.data) {
console.log(candidate.number, candidate.number_type);
}# The search is always country-scoped, so country_code is required.
page = client.numbers.available.list(country_code="GB", capabilities=["sms", "voice"])
for candidate in page.data:
print(candidate.number, candidate.number_type)for candidate, err := range client.Numbers.Available.List(context.Background(), bird.NumbersAvailableListParams{
CountryCode: "GB",
Capabilities: []string{"sms", "voice"},
}) {
if err != nil {
log.Fatal(err)
}
fmt.Println(candidate.Number, candidate.NumberType)
}// The search is always country-scoped, so country_code is required.
$page = $bird->numbers->available->list([
'country_code' => 'GB',
'capabilities' => ['sms', 'voice'],
]);
foreach ($page as $candidate) {
echo $candidate->getNumber(), ' ', $candidate->getNumberType(), "\n";
}curl "https://us1.platform.bird.com/v1/numbers/available?country_code=GB" \
-H "Authorization: Bearer bk_us1_..."Usa l'host regionale che corrisponde al prefisso bk_{region}_ della tua chiave: https://us1.platform.bird.com o https://eu1.platform.bird.com.
Ogni risultato descrive il numero:
{
"data": [
{
"number": "+447700900123",
"country_code": "GB",
"number_type": "mobile",
"capabilities": ["sms", "voice"],
"pricing": {
"setup_price": { "amount": "0.00995", "currency_code": "USD" },
"recurring_price": { "amount": "0.00995", "currency_code": "USD" },
"recurring_period": { "unit": "month", "count": 1 },
"intervals_per_charge": 12
}
}
],
"next_cursor": null,
"prev_cursor": null
}Ogni risultato include anche un oggetto pricing con il prezzo per la tua organizzazione, al netto delle imposte e nella valuta di fatturazione:
setup_priceviene addebitato una sola volta quando ordini il numero. Un costo pubblicato pari a zero ha unamountdi"0". Il campo stesso ènullquando non si applica alcun costo di attivazione, e anche ogni volta cherecurring_priceènull, perché quel numero non può essere ordinato.recurring_priceè la tariffa perrecurring_period.intervals_per_chargeindica quantirecurring_periodcopre un singolo addebito. L'addebito ricorrente al netto delle imposte èrecurring_pricemoltiplicato perintervals_per_charge, prelevato quando il numero viene assegnato al tuo spazio di lavoro e a ogni rinnovo. Per un ordine che attende un operatore, l'assegnazione avviene quando l'ordine si conclude. Unrecurring_perioddi un mese conintervals_per_charge: 12fattura 12 mesi alla volta.
Il riferimento API mostra un esempio di risultato con i prezzi. Un risultato di ricerca con pricing.recurring_price: null non fornisce un prezzo ricorrente. Contatta il team commerciale per ottenere un prezzo per quel paese e tipo di numero prima di ordinare.
La dashboard e API usano lo stesso prezzo dell'organizzazione, inclusa la conversione nella valuta di fatturazione. La lettura del prezzo non blocca un preventivo: variazioni tariffarie o di cambio prima di un addebito successivo possono modificarne l'importo. Se il recupero del prezzo fallisce, la ricerca restituisce 503 con E14009. Riprova la lettura con backoff esponenziale: un errore nel recupero del prezzo non significa mai che il numero non costi nulla.
Il nostro inventario viene restituito per primo e la paginazione funziona normalmente. L'ultima pagina può includere numeri che un operatore sta offrendo in tempo reale, quindi un numero elencato un momento fa potrebbe essere già stato preso quando lo ordini.
Per verificare che un numero sia ancora disponibile prima di ordinarlo, rileggilo con GET /v1/numbers/available/{number}. Un 404 significa che al momento non è in vendita, sia che l'operatore l'abbia ritirato sia che il nostro inventario lo abbia riservato. La rilettura condivide lo stesso limite di frequenza numbers_availability della ricerca: verifica solo il candidato che stai per ordinare, non ogni risultato.
Ordinare il numero
Passa un numero dalla ricerca a POST /v1/numbers/orders. Per proteggerti in caso di nuovo tentativo, vedi Idempotenza.
const order = await bird.numbers.orders.create({ number: "+447700900201" });
// Most orders finish inside the request. One that has to wait on a carrier
// comes back without a number_id. Poll it until it is completed or failed.
if (order.status === "completed") {
console.log("allocated as", order.number_id);
} else {
console.log("still", order.status, "; poll", order.id);
}order = client.numbers.orders.create(number="+447700900201")
# Most orders finish inside the request. One that has to wait on a carrier
# comes back without a number_id. Poll it until completed or failed.
if order.status == "completed":
print("allocated as", order.number_id)
else:
print("still", order.status, "; poll", order.id)order, err := client.Numbers.Orders.Create(context.Background(), bird.NumbersOrdersCreateParams{
Number: "+447700900201",
})
if err != nil {
log.Fatal(err)
}
// An order that has to wait on a carrier comes back without a NumberId.
// Poll it until it is completed or failed.
fmt.Println(order.Status, order.Id)$order = $bird->numbers->orders->create(
(new NumbersOrderCreate())->setNumber('+447700900201'),
);
// Most orders finish inside the request. One that has to wait on a carrier
// comes back without a number_id. Poll it until it is completed or failed.
if ($order->getStatus() === 'completed') {
echo 'allocated as ', $order->getNumberId(), "\n";
} else {
echo 'still ', $order->getStatus(), '; poll ', $order->getId(), "\n";
}curl -X POST "https://us1.platform.bird.com/v1/numbers/orders" \
-H "Authorization: Bearer bk_us1_..." \
-H "Content-Type: application/json" \
-d '{"number": "+447700900123"}'La maggior parte degli ordini si conclude entro la richiesta e risponde 201 con il numero già tuo:
{
"id": "nor_01m0da22b0e39anhzyhtw3gzdg",
"number": "+447700900123",
"country_code": "GB",
"number_type": "mobile",
"status": "completed",
"number_id": "nda_7eqywfwzxwa1za9n8wp7e1xkr8",
"failure_reason": null,
"completed_at": "2026-08-19T15:25:56.479320Z",
"created_at": "2026-08-19T15:25:56.448051Z",
"updated_at": "2026-08-19T15:25:56.479320Z"
}number_id è l'identificativo per tutto ciò che segue: leggere il numero e rilasciarlo.
Interrogare un ordine non concluso
Un ordine che deve attendere un operatore risponde 202, con number_id ancora null. Rileggilo finché status non è completed o failed.
const order = await bird.numbers.orders.get("nor_01krdgeqcxet5s7t44vh8rt9mg");
// failure_reason says what went wrong, and only ever on a failed order.
console.log(order.status, order.failure_reason ?? "");order = client.numbers.orders.get("nor_01krdgeqcxet5s7t44vh8rt9mg")
# failure_reason says what went wrong, and only ever on a failed order.
print(order.status, order.failure_reason or "")order, err := client.Numbers.Orders.Get(context.Background(), "nor_01krdgeqcxet5s7t44vh8rt9mg")
if err != nil {
log.Fatal(err)
}
// FailureReason says what went wrong, and only ever on a failed order.
fmt.Println(order.Status)$order = $bird->numbers->orders->get('nor_01krdgeqcxet5s7t44vh8rt9mg');
// failure_reason says what went wrong, and only ever on a failed order.
echo $order->getStatus(), ' ', $order->getFailureReason() ?? '', "\n";curl "https://us1.platform.bird.com/v1/numbers/orders/nor_01m0da22b0e39anhzyhtw3gzdg" \
-H "Authorization: Bearer bk_us1_..."Un ordine passa attraverso charging, ordering e pending prima di stabilizzarsi. In caso di failed, failure_reason spiega cosa è andato storto in termini chiari. Un costo di attivazione già addebitato non viene rimborsato, quindi un ordine fallito può lasciare un addebito; contatta il supporto se succede.
Rilasciare un numero
Il rilascio interrompe l'addebito ricorrente e il numero smette di funzionare per te. Solo un numero dedicated può essere rilasciato, e un numero rilasciato non torna subito in vendita.
// Releasing stops the recurring charge and the number stops working for you.
// Only a dedicated number can be released; a shared one answers E14002.
await bird.numbers.release("nda_01krdgeqcxet5s7t44vh8rt9mg");# Releasing stops the recurring charge and the number stops working for you.
# Only a dedicated number can be released; a shared one answers E14002.
client.numbers.release("nda_01krdgeqcxet5s7t44vh8rt9mg")// Only a dedicated number can be released; a shared one answers E14002.
if err := client.Numbers.Release(context.Background(), "nda_01krdgeqcxet5s7t44vh8rt9mg"); err != nil {
log.Fatal(err)
}// Releasing stops the recurring charge and the number stops working for you.
// Only a dedicated number can be released; a shared one answers E14002.
$bird->numbers->release('nda_01krdgeqcxet5s7t44vh8rt9mg');curl -X POST "https://us1.platform.bird.com/v1/numbers/nda_7eqywfwzxwa1za9n8wp7e1xkr8/release" \
-H "Authorization: Bearer bk_us1_..."Un rilascio riuscito risponde 204 senza corpo. Per mantenere il numero fino alla fine del periodo già pagato, annullalo invece: Gestione dei numeri di telefono spiega entrambe le opzioni.
Quando un ordine viene rifiutato
Quattro motivi di rifiuto coprono quasi tutti gli acquisti non riusciti.
402 con E03000 significa che il saldo non copre il numero. Ricarica e ordina di nuovo. Nessun ordine viene creato, quindi nulla viene addebitato.
412 significa che l'organizzazione non ha completato la verifica dell'identità richiesta per il primo acquisto. Completala, poi riprova.
409 con E14000 significa che il numero è stato preso mentre lo sceglievi. Cerca di nuovo e scegline un altro.
409 con E14001 significa che troppi ordini sono già in corso. Lascia che uno si concluda, poi ordina di nuovo.
Prossimi passi
- Panoramica dei numeri spiega il significato dei campi di un numero.
- Riferimento API dei numeri documenta ogni operazione e campo.
- Idempotenza spiega come le chiavi rendono sicuro un ordine ripetuto.
Risorse correlate
Continua con la documentazione, le guide e gli esempi per questo argomento.