https://retellai.com/?utm_source=discord&utm_medium=seo logo
how do i do an create all api to an agent with an ...
# ❓・ai-evy-support
d
@AI Evy how do i do an create all api to an agent with an SIP number?
a
Thanks for tagging me @danielh_32629. I'll look through relevant sources and get back to you shortly.
​ To learn more, see the sources I considered: [[1] Import Phone Number](https://docs.retellai.com/api-references/import-phone-number) [[2] Create Phone Call](https://docs.retellai.com/api-references/create-phone-call) [[3] Custom Telephony Overview](https://docs.retellai.com/deploy/custom-telephony) [[4] Inquiry about "Dial to SIP Endpoint" method using cURL](https://discord.com/channels/1186424376300679209/1384155437242388633) ​
### Answer To create a call via API using a SIP number, you have two main approaches: ## Option 1: Import Your SIP Number First Import your phone number using the Import Phone Number API with your SIP trunk details: [(1) ]()
Copy code
json
{
  "phone_number": "+14157774444",
  "termination_uri": "someuri.pstn.twilio.com",
  "sip_trunk_auth_username": "username",
  "sip_trunk_auth_password": "123456",
  "outbound_agent_id": "oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD"
}
Then use the Create Phone Call API with your imported number as
from_number
. [(2) ]() ## Option 2: Dial to SIP URI (Method 2) If your provider doesn't support elastic SIP trunking, use the Register Phone Call API to get a
call_id
, then dial the SIP URI from your system: [(3) ]()
Copy code
javascript
const phoneCallResponse = await client.call.registerPhoneCall({
  agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD',
  from_number: "+12137771234",
  to_number: "+12137771235",
  direction: "inbound",
}) ;

const voiceResponse = new VoiceResponse() ;
const dial = voiceResponse.dial() ;
dial.sip(
  `sip:${phoneCallResponse.call_id}@sip.retellai.com`,
) ;
The SIP URI format is:
sip:{call_id}@sip.retellai.com
Required fields for the register call are
agent_id
and
direction
(
inbound
or
outbound
) . [(4) ]() Which method are you looking to use—elastic SIP trunking or dial to SIP URI?
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
d
using postman
@AI Evy usign postman
a
Thanks for the follow-up, @danielh_32629. I'll get back to you soon.
### Answer To create a call with a SIP number using Postman, here's how to structure your requests: ## Step 1: Import Your SIP Number Endpoint:
POST /import-phone-number
[(1) ]() Headers: - `Authorization`:
Bearer YOUR_RETELL_API_KEY
- `Content-Type`:
application/json
Body (JSON) :
Copy code
json
{
  "phone_number": "+14157774444",
  "termination_uri": "someuri.pstn.twilio.com",
  "sip_trunk_auth_username": "username",
  "sip_trunk_auth_password": "123456",
  "inbound_agent_id": "oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD",
  "outbound_agent_id": "oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD"
}
## Step 2: Create the Outbound Call Endpoint:
POST /v2/create-phone-call
[(2) ]() Headers: - `Authorization`:
Bearer YOUR_RETELL_API_KEY
- `Content-Type`:
application/json
Body (JSON) :
Copy code
json
{
  "from_number": "+14157774444",
  "to_number": "+12137774445"
}
Key notes: -
from_number
must be a number purchased from Retell or imported to Retell -
to_number
is the destination in E.164 format - You can optionally add
override_agent_id
if you want to use a different agent than what's bound to the number Make sure your termination URI is correct and matches your SIP trunk provider's settings. [(5) ]()
​ To learn more, see the sources I considered: [[1] Import Phone Number](https://docs.retellai.com/api-references/import-phone-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.