https://retellai.com/?utm_source=discord&utm_medium=seo logo
is it possible to create a workspace to a new clie...
# ❓・ai-evy-support
t
@AI Evy is it possible to create a workspace to a new cliet via api?
a
Thanks for tagging me @thesnowguru. I'll look through relevant sources and get back to you shortly.
### Answer Yes, you can create a workspace via the Retell AI API [(1) ]() . The API method is
retellClient.workspace.create()
. This was confirmed in a support response where a user was having trouble creating a workspace through the UI and was advised to attempt creation via the API instead .
​ To learn more, see the sources I considered: [[1] Can't Add Another Workspace (#4 Total)](https://discord.com/channels/1186424376300679209/1387514373848699080) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
t
@AI Evy is it possible to add and buy a phone number from retell via api call
a
Thanks for the follow-up, @thesnowguru. I'll get back to you soon.
### Answer Yes, you can buy a phone number from Retell via API using the Create Phone Number endpoint. [(1) ]() Example (JavaScript) :
Copy code
javascript
import Retell from 'retell-sdk';

const client = new Retell({
  apiKey: 'YOUR_RETELL_API_KEY',
}) ;

const phoneNumberResponse = await client.phoneNumber.create() ;
console.log(phoneNumberResponse.inbound_agent_id) ;
Key parameters you can specify: - `area_code`: 3-digit US area code (e.g.,
415
) - `inbound_agent_id`: Agent ID to handle inbound calls - `outbound_agent_id`: Agent ID for outbound calls - `number_provider`: Choose
"twilio"
or
"telnyx"
(defaults to Twilio) - `country_code`:
"US"
or
"CA"
(defaults to US) - `toll_free`: Set to
true
for toll-free numbers - `nickname`: For your reference Pricing: [(2) ]() - US/Canadian numbers (Twilio or Telnyx) : $2/month - US toll-free numbers (Twilio) : $5/month Phone numbers are yours once purchased and can be used indefinitely.
​ To learn more, see the sources I considered: [[1] Create Phone Number](https://docs.retellai.com/api-references/create-phone-number) [[2] Purchase phone number](https://docs.retellai.com/deploy/purchase-number) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
t
@AI Evy not clear how to buy a number get what response , how to send the call payload example beore specific and how add it to the workspace also.
a
Thanks for the follow-up, @thesnowguru. I'll get back to you soon.
### Answer ### 1. Buying a Phone Number via API When you create a phone number, you can assign agents directly: [(1) ]()
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) ;
The response will include the purchased phone number details and the assigned agent IDs. ### 2. Creating an Outbound Call Once you have a number, use the Create Phone Call API: [(2) ]()
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
  apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const phoneCallResponse = await client.call.createPhoneCall({
  from_number: '+14157774444',
  to_number: '+12137774445',
}) ;
console.log(phoneCallResponse.agent_id) ;
Required parameters: - `from_number`: Your Retell number in E.164 format (must be purchased/imported to Retell) - `to_number`: Destination number in E.164 format Optional parameters: - `override_agent_id`: Specify which agent handles the call - `retell_llm_dynamic_variables`: Inject dynamic variables like
{"customer_name": "John Doe"}
- `metadata`: Store custom data for tracking ### 3. Adding to a Workspace I don't have specific documentation on how to programmatically add a phone number to a specific workspace via API. The sources only cover purchasing numbers and making calls. For workspace-specific configuration, I'd suggest: - Check the [Create Phone Number API Reference]() for any workspace parameters [(1) ]() - Visit [Contact Sales]() for additional support Would you like me to try providing a general answer about workspace management?
​ To learn more, see the sources I considered: [[1] Purchase phone number](https://docs.retellai.com/deploy/purchase-number) [[2] Create Phone Call](https://docs.retellai.com/api-references/create-phone-call) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
t
@AI Evy again, i want to buy a number via api call, i know how to assign it, how do i buy a number from retell via api, how the payload looks like and how the response look like
a
Thanks for the follow-up, @thesnowguru. I'll get back to you soon.
### Answer --- The sources I have available don't include the Create Phone Number API reference with the full request payload and response structure. The sources cover List Phone Numbers [(1) ]() , Create Phone Call [(2) ]() , and other endpoints, but not the specific "buy/create a phone number" endpoint details. From the forum sources, I can confirm the SDK method exists: [(3) ]()
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
  apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const phoneNumberResponse = await client.phoneNumber.create() ;
console.log(phoneNumberResponse.inbound_agent_id) ;
However, I don't have the full payload options or response schema in my current sources. Check out these potentially useful sources: - [Create Phone Number API Reference]() - [Purchase phone number]() For additional support: - Visit [Contact Sales]() - Visit [) Would you like me to try providing 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] Create Phone Call](https://docs.retellai.com/api-references/create-phone-call) [[3] 404 Error on Create a Phone Call](https://retell.discourse.group/t/404-error-on-create-a-phone-call/22) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.