> For a complete page index, fetch https://developer.close.com/llms.txt

# Request an internal phone number

POST https://api.close.com/api/v1/phone_number/request/internal/
Content-Type: application/json

Renting a phone number incurs a cost. The new number is assigned to you unless you name other users via `assign_to`, which requires the "Manage Team Phone Numbers" permission.

If a number was rented, a 201 response is returned with the new number. If no number was rented (4xx response code), the response contains a `status` field which may contain one of the values below. New statuses may be added in the future.

* `has-voice-only`: This country/prefix combination only has non-SMS-capable
  numbers. You can attempt renting the number by passing `with_sms` as `false`.
* `needs-more-info`: More information (such as proof of address) is needed to
  rent this number. This number can only be rented by contacting Close support.
* `billing-error`: An error related to billing has occurred. For example, the
  telephony budget has been reached, or there are not enough funds and recharging failed.
* `error`: An error has occurred while renting this number. A human-readable
  message is returned in the `error` field.

Reference: https://developer.close.com/api/resources/phone-numbers/create

## Authentication

- `Authorization` header (basic auth, required) — Use your API key as the username and leave the password empty.
- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Body (application/json)

This endpoint expects a CreatePhoneNumberRequest.

- `country` (string, required) — A two letter ISO country code (e.g. `US` for United States).
- `assign_to` (list of string, optional, nullable) — IDs of the users the new phone number is assigned to. When omitted, the number is assigned to the user making the request. Assigning it to anyone else requires the "Manage Team Phone Numbers" permission, and every user must be an active member of the organization who is allowed to make calls.
- `bundle_id` (string, optional, nullable)
- `carrier_type` (enum, optional, nullable)
  - Allowed values: `local`, `national`, `mobile`, `tollfree`
- `prefix` (string, optional, default: ) — A string with the phone number prefix or area code, not including the country code.
- `with_mms` (boolean, optional, nullable) — By default, MMS-capable numbers are rented if Close supports MMS for the given country. Renting an MMS-capable number can be forced by setting this flag to `true`. If set to `false`, certain prefixes that don't support MMS can be rented in countries where Close supports MMS. In most scenarios, this flag should not be passed. When you request an MMS number, you must set `with_sms` to `true` as well.
- `with_sms` (boolean, optional, nullable) — By default, SMS-capable numbers are rented if Close supports SMS for the given country. Renting an SMS-capable number can be forced by setting this flag to `true`. If set to `false`, certain prefixes that don't support SMS can be rented in countries where Close supports SMS. In most scenarios, this flag should not be passed unless a `has-voice-only` error status is received.
- `sharing` (enum, optional, deprecated) — Deprecated. `personal` for a number that belongs to an individual user, or `group` for a group number. The distinction between personal and group numbers is being removed, and this field will be removed in a future update. When omitted, defaults to `personal`.
  - Allowed values: `personal`, `group`

## Response

### 201

Successful response

- `address_id` (string, required, nullable)
- `bundle_id` (string, required, nullable)
- `carrier` (enum, required, nullable)
  - Allowed values: `twilio`, `plivo`
- `carrier_type` (enum, required, nullable)
  - Allowed values: `local`, `national`, `mobile`, `tollfree`, `shortcode`
- `country` (string, required, nullable)
- `date_created` (datetime, required)
- `date_updated` (datetime, required)
- `id` (string, required)
- `label` (string, required)
- `last_billed_price` (double, required, nullable) — Monthly rate of the last charge for this number. `null` before the first charge, and for numbers that Close does not bill.
- `local_presence_enabled` (boolean, required) — Whether Local Presence can pick this phone number by proximity for a call or SMS made as a user. It has no effect on a plan that doesn't include Local Presence.
- `mms_enabled` (boolean, required)
- `next_billing_on` (date, required, nullable) — Date on which the next monthly charge for this number is due. A past date means that the charge did not go through yet, for example right after Close rents the number. `null` for numbers that Close does not bill, such as external numbers.
- `non_member_caller_id_enabled` (boolean, required) — Whether users who are not members of this phone number can use it as their outbound Caller ID.
- `number` (string, required)
- `number_formatted` (string, required)
- `organization_id` (string, required)
- `participant_groups` (list of string, required) — IDs of the Groups assigned to this phone number. Members of these Groups ring on inbound calls, receive notifications for the number, and can use it as outbound Caller ID. See the Groups API.
- `participants` (list of string, required) — IDs of the users assigned directly to this phone number. Members of the Groups in `participant_groups` also ring on inbound calls, receive notifications for the number, and can use it as outbound Caller ID.
- `sms_enabled` (boolean, required)
- `supports_mms_to_countries` (list of string, required)
- `supports_sms_to_countries` (list of string, required)
- `type` (enum, required)
  - Allowed values: `internal`, `external`, `virtual`
- `voice_agents_local_presence_enabled` (boolean, required) — Whether Local Presence can pick this phone number for calls and SMS that voice agents make in Auto Caller ID mode.
- `is_group_number` (boolean, required, deprecated) — This field is deprecated and will be removed in a future update. Until then, it is set to `false` when `participants` has exactly one user and the phone number doesn't have any of the "shared" configuration set up (e.g. a phone menu, lead-based routing, a dial-out list, an assigned Group, a non-default ring order, etc.), and `true` otherwise.
- `is_premium` (boolean, required, deprecated) — This field is deprecated and will be removed in a future update. Until then, it is always `false`.
- `user_id` (string, required, nullable, deprecated) — This field is deprecated. See the `participants` and `participant_groups` fields instead to learn who's assigned to this phone number. This `user_id` field will be removed in a future update. Until then, it is set to a specific user ID *only if* the given phone number has a single participant and no additional "shared" configuration (e.g. a phone menu, lead-based routing, a dial-out list, an assigned Group, a non-default ring order, etc.).
- `forward_to` (string, optional, nullable)
- `forward_to_enabled` (boolean, optional)
- `forward_to_formatted` (string, optional, nullable)
- `inbound_ring_duration` (integer, optional, nullable) — Number of seconds we ring this number on inbound calls before moving on (e.g. to voicemail). `null` means the default of 30 seconds is used.
- `phone_numbers` (list of string, optional) — Present unless `participants` has exactly one user and the phone number has no shared-number configuration (a phone menu, lead-based routing, a dial-out list, an assigned Group, or a non-default ring order).
- `phone_numbers_formatted` (list of string, optional) — Present under the same condition as `phone_numbers`, with each value formatted for display.
- `press_1_to_accept` (boolean, optional)
- `voicemail_greeting_url` (string, optional, nullable)
- `was_ported` (boolean, optional)

## Errors

### 400 Bad Request Error

Bad request, such as a validation error.

- `Phone_numbers_createRequestBadRequestError`
  - ErrorMessage: ErrorMessage
  - ValidationErrors: ValidationErrors
  - NestedValidationErrors: NestedValidationErrors

### 401 Unauthorized Error

Authentication is missing or invalid.

- `error` (string, required) — Error message.

### 403 Forbidden Error

Forbidden. Also returned when the API key lacks the required scope (`error_code` is `insufficient_scope`) or is inactive (`error_code` is `inactive_api_key`).

- `Phone_numbers_createRequestForbiddenError`
  - ErrorMessage: ErrorMessage
  - ApiKeyError: ApiKeyError

### 429 Too Many Requests Error

Too many requests. The global API rate limiter returns an empty body. Other rate and operation limits return a `RateLimitError` body. Wait for the number of seconds in the `retry-after` header before retrying.

- `error` (RateLimitErrorError, required)

## Types

### ErrorMessage

Error with a message.

- `error` (string, required) — Error message.

### ValidationErrors

Validation errors with the path of each invalid field.

- `errors` (list of ValidationErrorsErrorsItems, required)

### NestedValidationErrors

Validation errors nested by field. Some endpoints return only `errors` or only `field-errors`.

- `errors` (list of string, optional) — Errors that don't apply to a single field.
- `field-errors` (map from string to any, optional) — Errors keyed by field name. Each value is a message, a list of messages, or a nested object of the same shape for nested fields.

### ApiKeyError

The API key lacks the scope the request requires, or is inactive.

- `error` (string, required)
- `error_code` (enum, required)
  - Allowed values: `insufficient_scope`, `inactive_api_key`
- `required_scope` (string, optional) — API key scope the request requires. Present when `error_code` is `insufficient_scope`.

### RateLimitErrorError

- `message` (string, required, nullable)
- `rate_reset` (string, required) — Number of seconds until the rate limit resets.
- `allowed_limit` (integer, optional) — Maximum number of bulk actions allowed. Present when the bulk action limit was hit.
- `bulk_action_count` (integer, optional) — Number of bulk actions running. Present when the bulk action limit was hit.

### ValidationErrorsErrorsItems

- `field` (list of ValidationErrorsErrorsItemsFieldItems, required) — Path of the invalid field. Empty for errors that don't apply to a field.
- `msg` (string, required)

### ValidationErrorsErrorsItemsFieldItems

- integer
- string

## Examples

**Request**

```json
{
  "country": "US",
  "prefix": "650",
  "sharing": "personal"
}
```

**Response**

```json
{
  "address_id": null,
  "bundle_id": null,
  "carrier": "twilio",
  "carrier_type": "local",
  "country": "US",
  "date_created": "2021-03-17T11:45:56.651000+00:00",
  "date_updated": "2021-03-17T11:45:56.651000+00:00",
  "id": "phon_MiLNdBqo8utNOf1U78RaZgQB1Iq6rRGftiDW5C8B9uL",
  "label": "+1 650-333-5555",
  "last_billed_price": null,
  "local_presence_enabled": true,
  "mms_enabled": true,
  "next_billing_on": "2021-03-16",
  "non_member_caller_id_enabled": false,
  "number": "+16503335555",
  "number_formatted": "+1 650-333-5555",
  "organization_id": "orga_RbREgmiiwcr1w2b4cOnCMQaQPSIFxMqAD2Dh243uxcH",
  "participant_groups": [],
  "participants": [
    "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA"
  ],
  "sms_enabled": true,
  "supports_mms_to_countries": [
    "CA",
    "US"
  ],
  "supports_sms_to_countries": [
    "CA",
    "PR",
    "US"
  ],
  "type": "internal",
  "voice_agents_local_presence_enabled": false,
  "is_group_number": false,
  "is_premium": false,
  "user_id": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA",
  "forward_to": null,
  "forward_to_enabled": false,
  "forward_to_formatted": null,
  "inbound_ring_duration": null,
  "press_1_to_accept": true,
  "voicemail_greeting_url": null
}
```

**SDK Code**

```python phone_numbers_create_example
import requests

url = "https://api.close.com/api/v1/phone_number/request/internal/"

payload = {
    "country": "US",
    "prefix": "650",
    "sharing": "personal"
}
headers = {
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers, auth=("<CLOSE_API_KEY>", ""))

print(response.json())
```

```javascript phone_numbers_create_example
const url = 'https://api.close.com/api/v1/phone_number/request/internal/';
const credentials = btoa("<CLOSE_API_KEY>:");

const options = {
  method: 'POST',
  headers: {Authorization: `Basic ${credentials}`, 'Content-Type': 'application/json'},
  body: '{"country":"US","prefix":"650","sharing":"personal"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go phone_numbers_create_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.close.com/api/v1/phone_number/request/internal/"

	payload := strings.NewReader("{\n  \"country\": \"US\",\n  \"prefix\": \"650\",\n  \"sharing\": \"personal\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.SetBasicAuth("<CLOSE_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 phone_numbers_create_example
require 'uri'
require 'net/http'

url = URI("https://api.close.com/api/v1/phone_number/request/internal/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request.basic_auth("<CLOSE_API_KEY>", "")
request["Content-Type"] = 'application/json'
request.body = "{\n  \"country\": \"US\",\n  \"prefix\": \"650\",\n  \"sharing\": \"personal\"\n}"

response = http.request(request)
puts response.read_body
```

```java phone_numbers_create_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.close.com/api/v1/phone_number/request/internal/")
  .basicAuth("<CLOSE_API_KEY>", "")
  .header("Content-Type", "application/json")
  .body("{\n  \"country\": \"US\",\n  \"prefix\": \"650\",\n  \"sharing\": \"personal\"\n}")
  .asString();
```

```php phone_numbers_create_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.close.com/api/v1/phone_number/request/internal/', [
  'body' => '{
  "country": "US",
  "prefix": "650",
  "sharing": "personal"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
    'auth' => ['<CLOSE_API_KEY>', ''],
]);

echo $response->getBody();
```

```csharp phone_numbers_create_example
using RestSharp;
using RestSharp.Authenticators;

var client = new RestClient("https://api.close.com/api/v1/phone_number/request/internal/");
client.Authenticator = new HttpBasicAuthenticator("<CLOSE_API_KEY>", "");
var request = new RestRequest(Method.POST);

request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"country\": \"US\",\n  \"prefix\": \"650\",\n  \"sharing\": \"personal\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```