> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.pinnacle.sh/v-2/api-reference/phone-numbers/buy/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.pinnacle.sh/_mcp/server. # Buy Phone Numbers POST https://api.pinnacle.sh/phone-numbers/buy Content-Type: application/json Purchase one or more phone numbers found through the [search endpoint](./search). Billing uses your account credits and the numbers are ready for immediate use. Reference: https://docs.pinnacle.sh/api-reference/phone-numbers/buy ## Authentication - `PINNACLE-API-KEY` header (required) — API Key authentication via header ## Request ### Body (application/json) This endpoint expects a buySchema. - `numbers` (list of string, required) — List of phone numbers you want to purchase, each in international E.164 format. All specified numbers must be currently available and will be validated for availability before processing the purchase. If any number in the request is unavailable or invalid, no purchases will be made and the request will be voided. ## Response ### 200 Successfully purchased the number(s). - `list of BuyResponse` ## Errors ### 400 Bad Request Error Validation failed. The payload has missing required fields and/or invalid types. See [https://zod.dev/error-formatting](https://zod.dev/error-formatting) for more information. - `description` (string, required) — Human-readable summary of validation failures. - `errors` (ZodErrorErrors, required) — Structured dictionary of issues containing two main sections: - `errors`: Array of global validation errors not tied to specific fields - `properties`: Object mapping field names to their specific validation errors, where each field contains an `errors` array ### 401 Unauthorized Error The request lacks valid authentication credentials or the provided credentials are invalid. Ensure you're including a valid API key in the request headers and that your account has the necessary permissions to access this endpoint. - `error` (string, required) — Human-readable description of the error that occurred, corresponding to the HTTP status code. ### 402 Payment Required Error Insufficient credits to complete this request. This occurs when your account balance is below the required amount for processing the operation. Please add credits to your account to continue using the service. - `error` (string, required) — Human-readable description of the error that occurred, corresponding to the HTTP status code. ### 403 Forbidden Error Your subscription does not include access to this feature. This occurs when attempting to use functionality that requires a higher subscription tier. Please upgrade your subscription to access this feature. - `error` (string, required) — Human-readable description of the error that occurred, corresponding to the HTTP status code. ### 404 Not Found Error The requested resource could not be found. This may occur if the identifier is incorrect, the resource has been deleted, or you don't have permission to access it. - `error` (string, required) — Human-readable description of the error that occurred, corresponding to the HTTP status code. ### 500 Internal Server Error An unexpected error occurred on Pinnacle's servers while processing your request. If this error persists, please contact support with the request details. - `error` (string, required) — Human-readable description of the error that occurred, corresponding to the HTTP status code. ## Types ### BuyResponse Details of a phone number that has been successfully purchased and provisioned. Includes all communication capabilities currently enabled for immediate use. - `number` (string, required) — Purchased phone number in E.164 format. - `capabilities` (BuyResponseCapabilities, required) — Enabled communication features for the phone number. ### ZodErrorErrors Structured dictionary of issues containing two main sections: - `errors`: Array of global validation errors not tied to specific fields - `properties`: Object mapping field names to their specific validation errors, where each field contains an `errors` array ### BuyResponseCapabilities Enabled communication features for the phone number. - `sms` (boolean, required) — Indicates if SMS messaging is enabled and functional. - `mms` (boolean, required) — Indicates if multimedia messaging (images, videos, files) is enabled and functional. - `voice` (boolean, required) — Indicates if voice calling is enabled and functional. ## Examples **Request** ```json { "numbers": [ "+18559491727" ] } ``` **Response** ```json [ { "number": "+18559491727", "capabilities": { "sms": true, "mms": true, "voice": true } } ] ``` **SDK Code** ```python Purchased Numbers import requests url = "https://api.pinnacle.sh/phone-numbers/buy" payload = { "numbers": ["+18559491727"] } headers = { "PINNACLE-API-KEY": "", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript Purchased Numbers const url = 'https://api.pinnacle.sh/phone-numbers/buy'; const options = { method: 'POST', headers: {'PINNACLE-API-KEY': '', 'Content-Type': 'application/json'}, body: '{"numbers":["+18559491727"]}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Purchased Numbers package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.pinnacle.sh/phone-numbers/buy" payload := strings.NewReader("{\n \"numbers\": [\n \"+18559491727\"\n ]\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("PINNACLE-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)) } ``` ```ruby Purchased Numbers require 'uri' require 'net/http' url = URI("https://api.pinnacle.sh/phone-numbers/buy") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["PINNACLE-API-KEY"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"numbers\": [\n \"+18559491727\"\n ]\n}" response = http.request(request) puts response.read_body ``` ```java Purchased Numbers import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.pinnacle.sh/phone-numbers/buy") .header("PINNACLE-API-KEY", "") .header("Content-Type", "application/json") .body("{\n \"numbers\": [\n \"+18559491727\"\n ]\n}") .asString(); ``` ```php Purchased Numbers request('POST', 'https://api.pinnacle.sh/phone-numbers/buy', [ 'body' => '{ "numbers": [ "+18559491727" ] }', 'headers' => [ 'Content-Type' => 'application/json', 'PINNACLE-API-KEY' => '', ], ]); echo $response->getBody(); ``` ```csharp Purchased Numbers using RestSharp; var client = new RestClient("https://api.pinnacle.sh/phone-numbers/buy"); var request = new RestRequest(Method.POST); request.AddHeader("PINNACLE-API-KEY", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"numbers\": [\n \"+18559491727\"\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift Purchased Numbers import Foundation let headers = [ "PINNACLE-API-KEY": "", "Content-Type": "application/json" ] let parameters = ["numbers": ["+18559491727"]] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.pinnacle.sh/phone-numbers/buy")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` > One API for RCS, iMessage, MMS, and SMS. Build, test, and scale every channel — send your first message in minutes, not weeks.