curl --request POST \
--url https://api.goyappr.com/phone-numbers/purchase \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"phone_number": "+972551234567"
}
'import requests
url = "https://api.goyappr.com/phone-numbers/purchase"
payload = { "phone_number": "+972551234567" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({phone_number: '+972551234567'})
};
fetch('https://api.goyappr.com/phone-numbers/purchase', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.goyappr.com/phone-numbers/purchase",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'phone_number' => '+972551234567'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.goyappr.com/phone-numbers/purchase"
payload := strings.NewReader("{\n \"phone_number\": \"+972551234567\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.goyappr.com/phone-numbers/purchase")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"phone_number\": \"+972551234567\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.goyappr.com/phone-numbers/purchase")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"phone_number\": \"+972551234567\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"phoneNumber": "<string>",
"monthlyPrice": 123,
"currency": "<string>",
"status": "pending_requirements",
"message": "<string>"
}{
"error": "<string>",
"code": "<string>",
"issues": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>"
}
]
}{
"error": "<string>",
"code": "<string>",
"issues": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>"
}
]
}Purchase Number
Purchase an available Israeli number. Requires a payment method. Only Israeli numbers are supported — a non-Israeli phone_number is rejected with 400 {"error":"Only Israeli phone numbers are supported"}.
curl --request POST \
--url https://api.goyappr.com/phone-numbers/purchase \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"phone_number": "+972551234567"
}
'import requests
url = "https://api.goyappr.com/phone-numbers/purchase"
payload = { "phone_number": "+972551234567" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({phone_number: '+972551234567'})
};
fetch('https://api.goyappr.com/phone-numbers/purchase', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.goyappr.com/phone-numbers/purchase",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'phone_number' => '+972551234567'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.goyappr.com/phone-numbers/purchase"
payload := strings.NewReader("{\n \"phone_number\": \"+972551234567\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.goyappr.com/phone-numbers/purchase")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"phone_number\": \"+972551234567\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.goyappr.com/phone-numbers/purchase")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"phone_number\": \"+972551234567\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"phoneNumber": "<string>",
"monthlyPrice": 123,
"currency": "<string>",
"status": "pending_requirements",
"message": "<string>"
}{
"error": "<string>",
"code": "<string>",
"issues": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>"
}
]
}{
"error": "<string>",
"code": "<string>",
"issues": [
{
"code": "<string>",
"message": "<string>",
"path": "<string>"
}
]
}phone_numbers:purchase.
This call charges the workspace’s card and starts a monthly subscription for
the number, so it is the one step of the number journey that is not free to
repeat. A saved payment method is required — add one with
Set up payment first.
curl --request POST "$YAPPR_API_URL/phone-numbers/purchase" \
--header "Authorization: Bearer $YAPPR_API_KEY" \
--header "Content-Type: application/json" \
--data '{"phone_number":"+972551234567"}'
| Field | Required | Notes |
|---|---|---|
phone_number | yes | Exactly as search returned it, in E.164. Israeli numbers only. |
Retrying safely
Send anIdempotency-Key header — 16 to 128 letters, digits, underscores or
hyphens — and a retry of the same purchase charges once and orders one number.
Make a new random key, such as a UUID, for each number you decide to buy, and
reuse it only to retry that purchase.
A retry with the same key and the same number answers what the first request
did: the same success body once the purchase went through,
409 PURCHASE_IN_PROGRESS while it is still going through, or
409 PURCHASE_FAILED when it did not go through. After PURCHASE_FAILED or
any other error, send a new key. Retry within 24 hours: after that a key may be
forgotten, and the request is then a new purchase.
A key belongs to one number. The same key sent with a different number is a
separate purchase: that number is bought and charged too. Without the header,
every request is a new purchase.
IDEMPOTENCY_KEY=$(uuidgen) # once per number you decide to buy
curl --request POST "$YAPPR_API_URL/phone-numbers/purchase" \
--header "Authorization: Bearer $YAPPR_API_KEY" \
--header "Idempotency-Key: $IDEMPOTENCY_KEY" \
--header "Content-Type: application/json" \
--data '{"phone_number":"+972551234567"}'
GET /billing/invoices.
Response
{
"success": true,
"phoneNumber": "+972551234567",
"monthlyPrice": 1500,
"currency": "USD",
"status": "pending_requirements",
"message": "Number purchased and awaiting regulatory review."
}
active at purchase time. It starts at
pending_requirements while the regulator’s paperwork clears — usually one to
three business days — and a background job promotes it when it does. Until
then it appears in the list with that
status, and an attempt to bind an agent to it is refused. Poll the list, or
check the dashboard, rather than waiting on this response.
monthlyPrice is in cents and matches the finalPriceCents the search showed. message is free text for a person to read — do not branch on it.
What happens if it fails
The subscription is created before the number is reserved, and is cancelled again if the reservation does not go through — a failed purchase does not leave you paying for a number you do not have.Errors
| HTTP | Body | When |
|---|---|---|
400 | {"error":"phone_number is required"} | The field is missing. |
400 | {"error":"Only Israeli phone numbers are supported"} | The number is not +972…. |
400 | {"error":"…","code":"IDEMPOTENCY_KEY_INVALID"} | The Idempotency-Key header is not 16 to 128 letters, digits, underscores or hyphens, or was sent more than once. Nothing was bought. |
402 | {"error":"Payment method required","code":"PAYMENT_METHOD_REQUIRED"} | No card on file, or the saved card is no longer usable. Add one and try again; nothing was bought. |
403 | {"error":"This key does not hold …","code":"INSUFFICIENT_SCOPE"} | The key does not hold phone_numbers:purchase. |
409 | {"error":"This purchase is still being processed. Check your numbers in a minute.","code":"PURCHASE_IN_PROGRESS"} | A request with the same Idempotency-Key has not finished. Nothing new was bought; check the list in a minute. |
409 | {"error":"The earlier attempt to buy this number did not go through. Try again.","code":"PURCHASE_FAILED"} | The purchase an earlier request with this Idempotency-Key made did not go through (the card was declined, or it was rolled back). Nothing new was bought; send a new key to try again. |
409 | {"error":"This Idempotency-Key was already used for a different purchase. Use a new key.","code":"IDEMPOTENCY_KEY_REUSED"} | The same key and number came back, but the purchase no longer matches the first one (for example, the workspace’s payment account changed in between). Nothing was charged a second time; use a new key. |
Authorizations
Your Yappr API key (e.g. ypr_live_...). Generate one in the dashboard under Settings → API Keys. No key is 401 MISSING_KEY; a key that is not one of ours, or is revoked, is 401 INVALID_KEY; an expired one is 401 EXPIRED_KEY. A valid key without the scope an operation needs is 403 INSUFFICIENT_SCOPE on every operation, and the message names the scope. Every response, a 401 included, carries X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset: the budget is 60 requests a minute per API key. Every 429, whatever its code, carries Retry-After (whole seconds, never zero): the per-key budget's RATE_LIMIT asks for what is left of the minute, a route's daily cap (RATE_LIMITED) for the time until that cap resets. All four headers are listed in Access-Control-Expose-Headers, so a browser can read them. A path the API does not serve (an unknown sub-path, an id left empty) is 404 ROUTE_NOT_FOUND, and a method a served path does not take is 405 METHOD_NOT_ALLOWED with an Allow header; both are answered before any scope check, and nothing is read or changed. A trailing slash is ignored where it cannot be an id left empty (POST /calls/ is POST /calls) and refused where it can (GET /calls/). A doubled slash inside a path is merged into one before the request reaches the API (GET //calls is GET /calls).
Headers
Makes the purchase safe to retry. A repeat with the same key, for the same number, charges once and orders one number: it answers the finished purchase with 200, 409 PURCHASE_IN_PROGRESS while the first request is still completing it, or 409 PURCHASE_FAILED when the first request's purchase did not go through. After PURCHASE_FAILED or any other error, send a new key. Without the header every request is a new purchase.
^[A-Za-z0-9_-]{16,128}$Response
Purchase result. Israeli numbers always start as pending_requirements — they are never active at purchase time. Activation happens later, once regulatory requirements clear (usually 1–3 business days), promoted by a background job.