Buy a number
POST
/api/v1/numbers/buy
using System.Net.Http.Headers;var client = new HttpClient();var request = new HttpRequestMessage{ Method = HttpMethod.Post, RequestUri = new Uri("https://external-api.moja-ai.com/api/v1/numbers/buy"), Headers = { { "X-API-Key", "<X-API-Key>" }, }, Content = new StringContent("{ \"prefix\": \"919\", \"quantity\": 1, \"toll_free\": false, \"imported\": false, \"imported_replaced_number\": \"example\" }") { Headers = { ContentType = new MediaTypeHeaderValue("application/json") } }};using (var response = await client.SendAsync(request)){ response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body);}package main
import ( "fmt" "strings" "net/http" "io")
func main() {
url := "https://external-api.moja-ai.com/api/v1/numbers/buy"
payload := strings.NewReader("{ \"prefix\": \"919\", \"quantity\": 1, \"toll_free\": false, \"imported\": false, \"imported_replaced_number\": \"example\" }")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<X-API-Key>") req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close() body, _ := io.ReadAll(res.Body)
fmt.Println(res) fmt.Println(string(body))
}const url = 'https://external-api.moja-ai.com/api/v1/numbers/buy';const options = { method: 'POST', headers: {'X-API-Key': '<X-API-Key>', 'Content-Type': 'application/json'}, body: '{"prefix":"919","quantity":1,"toll_free":false,"imported":false,"imported_replaced_number":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://external-api.moja-ai.com/api/v1/numbers/buy \ --header 'Content-Type: application/json' \ --header 'X-API-Key: <X-API-Key>' \ --data '{ "prefix": "919", "quantity": 1, "toll_free": false, "imported": false, "imported_replaced_number": "example" }'Buy one or more numbers through the configured phone-number provider (max 10 per order). Provide prefix for a local area code or toll-free NPA; set toll_free=true for toll-free (defaults to 800 if prefix omitted). Use quantity for multiple numbers in one order. The response includes purchased numbers under numbers (and number when quantity is 1).
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
NumberBuyRequest
object
quantity
Quantity
How many numbers to purchase in this order (1–10).
integer
toll_free
Toll Free
When true, order toll-free numbers. If prefix is omitted, uses 800. If prefix is set, it must be a toll-free NPA (800, 888, 877, 866, 855, 844, 833).
boolean
imported
Imported
Internal migration flag indicating this purchased Moja number maps to a number imported from another platform.
boolean
Responses
Section titled “Responses”Successful Response
Media typeapplication/json
Examplegenerated
exampleBad Request
Media typeapplication/json
ErrorResponse
object
detail
required
ErrorBody
object
code
required
Code
string
message
required
Message
string
Examplegenerated
{ "detail": { "code": "example", "message": "example" }}Unauthorized
Media typeapplication/json
ErrorResponse
object
detail
required
ErrorBody
object
code
required
Code
string
message
required
Message
string
Examplegenerated
{ "detail": { "code": "example", "message": "example" }}Not Found
Media typeapplication/json
ErrorResponse
object
detail
required
ErrorBody
object
code
required
Code
string
message
required
Message
string
Examplegenerated
{ "detail": { "code": "example", "message": "example" }}Conflict
Media typeapplication/json
ErrorResponse
object
detail
required
ErrorBody
object
code
required
Code
string
message
required
Message
string
Examplegenerated
{ "detail": { "code": "example", "message": "example" }}Validation Error
Media typeapplication/json
HTTPValidationError
object
detail
Detail
Array<object>
ValidationErrorobject
loc
required
Location
Array
msg
required
Message
string
type
required
Error Type
string
input
Input
ctx
Context
object
Examplegenerated
{ "detail": [ { "loc": [ "example" ], "msg": "example", "type": "example", "input": "example", "ctx": {} } ]}Too Many Requests
Media typeapplication/json
ErrorResponse
object
detail
required
ErrorBody
object
code
required
Code
string
message
required
Message
string
Examplegenerated
{ "detail": { "code": "example", "message": "example" }}
