Skip to main content

Rent DID

This request assigns a DID to a partner.

tip

Refer to our Rent a Phone Number quick start guide for a complete guide on how to rent phone numbers through CarrierX portal and API.

post /phonenumber/dids

Sample​

A sample POST request to assign a DID to a partner:

curl -X POST \
'https://api.carrierx.com/core/v2/phonenumber/dids' \
-H 'Content-Type: application/json' \
--data-binary '{"phonenumber":"15162065575", "callback_url":null}' \
-H 'Authorization: Bearer 5ebc03d6-8b2b-44ad-bf65-72d4f1491dda'

Response​

200 status code with a serialized copy of the DID object:

{
"active_capabilities": 4,
"attributes": {},
"callback_url": null,
"campaign_sid": null,
"capabilities": 31,
"classification_sid": "17f4d954-d635-4cda-912b-c2a2fa3a6860",
"country_code": "USA",
"did_group_sid": null,
"did_sid": "f448e2c3-88c1-4cd1-8cf2-3567c16e0794",
"in_country_format": "(516) 206-5575",
"international_format": "+1 516-206-5575",
"lata": null,
"line_type": null,
"locality": "NEW YORK",
"lrn_sid": null,
"name": "(516) 206-5575",
"ocn": "251F",
"partner_sid": "e00430c3-a7d0-4666-ab5c-f7202448382f",
"pending_port_in": null,
"phonenumber": "15162065575",
"porting_pin": null,
"price": "0.6",
"state": "NY",
"status": "assigned",
"string_key_1": null,
"string_key_2": null,
"transformations": [],
"trunk_group_sid": null,
"underlying_carrier_sid": "40a8c9cf-8b08-4c21-a3e3-952c65ee892d",
"wireless_handset_messaging_approval": null,
"wireless_iccid": null,
"wireless_product": null
}

The status of the DID you have ordered will depend on whether it is an internal DID from CarrierX or an externally-sourced one managed by CarrierX.

In case it is an internal DID, it will immediately get the assigned status.

If you have ordered an externally-sourced DID, its initial status is pending_assignment meaning that an external order for the DID has been created but not completed yet. After a while it changes to assigned. CarrierX will send you a callback on the external order completion, i.e. when a phone number changes its state from pending_assignment to assigned. The callback is identified as phonenumber_order and is configured by the partner on the Partner object. Please be aware that you cannot use your DID until its status changes to assigned.

note

Note, that as a rule, by default SMS/MMS messaging is disabled for all rented DIDs. Therefore, to be able to send SMS/MMS using the DID you have rented, you need to make sure that messaging is enabled, and if not, enable it by sending a POST request to the API.

Required Scopes​

To create a DID object, the partner must have one of the following scopes enabled:

  • phonenumber.manage
  • phonenumber.create

Body Arguments​

JSON representation of the fields and values of the DID object to be created.

No fields are required to rent a DID, an empty object can be passed.

If you do not specify a phone number, the system will assign the first available phone number to you.

If you want to rent a specific phone number, you need to pass it as a value for the phonenumber body attribute.

note

Note that once the phone number has been rented, it must be assigned a trunk group to be usable.

Query Arguments​

ParameterData TypeDescription
include_external
deprecated
boolean

This argument is ignored. The source of the phone number depends on the country_code and line_type filter parameters. Refer to DID Sources for details.

filter
string

Restricts the phone number to be rented by some parameters (e.g., capabilities, state, country_code, etc.) and returns the first available phone number matching the filter when you do not specify any body arguments. The country_code and line_type parameters also decide where the system looks for the phone number. Refer to DID Sources for details.

Refer to this table to view all fields that appear in the DID object.

DID Sources​

The system looks for the phone number in the CarrierX inventory first. For some countries, CarrierX can also order the phone number from an external provider. The country_code and line_type parameters in the filter query argument decide where the system looks.

If the filter has no country_code eq parameter, the system uses only the CarrierX inventory. This also applies when you pass a specific phone number in the phonenumber body argument.

If the filter has country_code eq with a country where CarrierX uses an external provider, and the CarrierX inventory has no matching phone number, the system orders a phone number from the external provider. To rent a specific phone number from the external provider, pass it in the phonenumber body argument and add country_code eq to the filter. The external provider supports only these filter parameters and operators:

  • country_code eq, which must be followed by a 3-letter country code, for example country_code eq "GBR".
  • phonenumber like, for example phonenumber like "%555%".
  • capabilities, which must be followed by either bit or eq operator. Please note that externally-sourced DIDs often have limited capabilities. In most cases, only SMS and voice are supported (capabilities bit 1, 2, and 4; and their combinations), so if you are using a capabilities filter with an externally-sourced DID, you may need to make sure its number does not exceed 7, otherwise you may get very limited results.

A phone number from the external provider first gets the pending_assignment status. The status changes to assigned when the external order is complete. You cannot use the DID before that.

The line_type parameter selects the type of phone number to rent. The default value is local. To rent a wireless DID, use line_type eq "wireless" as described in the next section.

Rent a Wireless DID​

To rent a wireless DID, add line_type eq "wireless" to the filter query argument. The filter must also contain:

  • country_code eq "USA"
  • phonenumber nearby npa:<npa> or phonenumber nearby zip:<zip>

For example: line_type eq "wireless" and country_code eq "USA" and phonenumber nearby npa:516

A sample POST request to rent a wireless DID with a physical SIM card:

curl -X POST \
'https://api.carrierx.com/core/v2/phonenumber/dids?filter=line_type+eq+%22wireless%22+and+country_code+eq+%22USA%22+and+phonenumber+nearby+npa%3A516' \
-H 'Content-Type: application/json' \
--data-binary '{"wireless_iccid":"8901260123456789012"}' \
-H 'Authorization: Bearer 5ebc03d6-8b2b-44ad-bf65-72d4f1491dda'

The following body arguments are used only when renting a wireless DID. They are ignored for other line types. You cannot change them after the DID is rented.

ParameterData TypeDescription
wireless_iccid
string

The 19-20 digit ICCID of the physical SIM card to use with the DID. If you do not send it, an eSIM is used, and the wireless_iccid field of the rented DID contains the vendor activation link for the eSIM.

wireless_product
string

The vendor product to use with the DID. If you do not send it, the vendor default product is used. The products available to you depend on your account.

The rented wireless DID gets the assigned status right away, and its line_type is wireless.

The request to rent a wireless DID returns an error in these cases:

  • 400: the filter has no phonenumber nearby npa: or phonenumber nearby zip: parameter, or it has other parameters than line_type, country_code, and phonenumber nearby npa: or zip:.
  • 400: the body has a specific phonenumber or did_sid. The vendor selects the phone number for a wireless DID.
  • 409: your rate plan does not include wireless DIDs, or wireless DID ordering is not configured.
  • 422: the vendor rejects the wireless_product value. CarrierX does not check this value. It sends the value to the vendor.

Two Types of External DIDs​

CarrierX supports two distinct categories of phone numbers that are referred to as “external”:

  • Externally-sourced DIDs mentioned above in this chapter, which can be rented through CarrierX with a POST request to the /phonenumber/dids endpoint and a country_code filter, as described in DID Sources.

  • External DIDs, which are customer-owned, not rented through CarrierX and can be registered for messaging purposes only. These DIDs cannot be rented using the above endpoint. Instead, they have their own registration process described in the External DID documentation.