Error: TypeErrorMessage: A phone number must eithe...
# support
v
It looks like the error is due to the phone number field in your request not being formatted as required. When creating a phone number with Vapi, ensure you pass the phone number as a string or as an object, depending on the provider. Here’s a Python example for the correct request structure:
Copy code
python
from vapi import CreateByoPhoneNumberDto, Vapi

client = Vapi(token="YOUR_TOKEN")
client.phone_numbers.create(
    request=CreateByoPhoneNumberDto(
        credential_id="your_credential_id"
        # Add other required fields here
    )
)
Double-check your request body matches the expected format for your provider as shown in the [Vapi documentation](https://docs.vapi.ai/api-reference/phone-numbers/create). Source: - [Create Phone Number](https://docs.vapi.ai/api-reference/phone-numbers/create)
s
While creating VAPI phone number only provider required when phone number is created by vapi. I also gave provider = 'vapi' while requesting. So where is the problem?
c
Hey! For Vapi free numbers, it’s much easier to create them directly from the Dashboard → Phone Numbers page. The dashboard walks you through selecting an area code, which avoids this API formatting error entirely. I’d recommend creating the number there first 👍