Skip to main content

Purchase Numbers

Purchase phone numbers for your account. You can buy directly from a group or purchase a previously reserved number.

Endpoint

POST https://api.p.2chat.io/open/numbers/purchase

Authentication

Include your API key in the X-User-API-Key header. Learn more about authentication.

Parameters

These parameters should be sent as JSON payload in the request body.

FieldTypeRequiredDescription
group_idstringYesThe group ID from the Search Number Groups endpoint
numberstringNoA specific number to purchase (from the Available Numbers endpoint or a reservation). If omitted, a random number from the group is assigned.

Invocation

curl --location --request POST 'https://api.p.2chat.io/open/numbers/purchase' \
--header 'Content-Type: application/json' \
--header 'X-User-API-Key: your_api_key_here' \
--data '{
"group_id": "abc-123",
"number": "+12135551234"
}'

Response

Success (HTTP 201 Created)

{
"success": true
// Purchase result details
}

Error

{
"success": false,
"error": true,
"error_message": "Description of what went wrong"
}

Typical Purchase Flow

The complete flow for purchasing a phone number is:

  1. Find a locationGET /open/numbers/regions and GET /open/numbers/cities to narrow down by region and city
  2. Search groupsGET /open/numbers/groups to find number groups by country, region, city, or type
  3. Check requirementsGET /open/numbers/requirements to verify if regulatory documents are needed
  4. Browse numbers (optional) — GET /open/numbers/available to pick a specific number from a group
  5. PurchasePOST /open/numbers/purchase with a group_id and optionally a specific number
tip

If you need to hold a number before committing (e.g., to show it to a user before charging), you can reserve it first and then purchase before it expires.