https://retellai.com/?utm_source=discord&utm_medium=seo logo
Can we use retells API to buy numbers and attach t...
# ❓・ai-evy-support
j
@AI Evy Can we use retells API to buy numbers and attach them to a specific agent or we have only one option and thats the manual way?
a
Thanks for tagging me @Justin Leon. I'll look through relevant sources and get back to you shortly.
### Answer --- Yes, you can use Retell's API to purchase numbers and attach them to specific agents programmatically. [(1) ]() ## Purchasing via API Use the [Create Phone Number API]() to purchase a number and assign agents in one call:
Copy code
javascript
const phoneNumberResponse = await retell.phoneNumber.create({
 inbound_agent_id: "oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD", // replace with the agent id you want to assign
 outbound_agent_id: "oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD", // replace with the agent id you want to assign
}) ;
console.log(phoneNumberResponse) ;
You can assign different inbound and outbound agents to the number. ## Updating an Existing Number If you need to change the agent assignment later, use the Update Phone Number API: [(2) ]()
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
 apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const phoneNumberResponse = await client.phoneNumber.update('+14157774444', {
 inbound_agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD',
 nickname: 'Frontdesk Number',
 outbound_agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD',
}) ;
console.log(phoneNumberResponse.inbound_agent_id) ;
Phone numbers are yours once purchased and can be used indefinitely. [(1) ]()
​ To learn more, see the sources I considered: [[1] Purchase phone number](https://docs.retellai.com/deploy/purchase-number) [[2] Update Phone Number](https://docs.retellai.com/api-references/update-phone-number) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
j
@User Retellai numbers are only used to retell agents or can we use them outside retellai, for example connecting them to different service and using retellai system to make calls via retells numbers?
@AI Evy
a
Thanks for the follow-up, @Justin Leon. I'll get back to you soon.
### Answer Based on the available sources, I don't have explicit documentation on whether Retell-purchased numbers can be used outside of Retell's system for other services. What the documentation does show: - Phone numbers purchased through Retell (via Twilio or Telnyx) are typed as
retell-twilio
or
retell-telnyx
[(1) ]() - These numbers are designed to bind to Retell agents for inbound and outbound calls - You can use the Register Phone Call API to integrate with custom telephony setups, but this is for routing calls to Retell agents [(2) ]() For the reverse scenario—using Retell numbers with external services while still making calls through Retell—the sources don't provide clear guidance on this use case. Check out these potentially useful sources: - [Create Phone Number]() - [Register Phone Call]() - [Import Phone Number]() Would you like me to provide a general answer based on my knowledge instead?
​ To learn more, see the sources I considered: [[1] List Phone Numbers](https://docs.retellai.com/api-references/list-phone-numbers) [[2] Register Phone Call](https://docs.retellai.com/api-references/register-phone-call) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.