# Retell with Asterisk AGI

**URL:** <https://community.retellai.com/t/retell-with-asterisk-agi/551>\
**Category:** Support Help\
**Created:** [January 21, 2026, 2:31pm UTC](https://community.retellai.com/t/retell-with-asterisk-agi/551 "2026-01-21T14:31:39Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![paksaaibaan](https://avatars.discourse-cdn.com/v4/letter/p/ebca7d/32.png) [@paksaaibaan](https://community.retellai.com/u/paksaaibaan)\
**Post date:** [January 21, 2026, 2:31pm UTC](https://community.retellai.com/t/retell-with-asterisk-agi/551/1 "2026-01-21T14:31:39Z")

</div>

Hello Retell Team,

We are integrating Retell with Asterisk AGI (Phase 2 – Production).

**Workspace:** PAK SAIBAAN  
**Billing:** Pay-As-You-Go (Active)  
**Agents:** Multi-State (Inbound & Outbound enabled)  
**Phone Number:** +1 (201) 379-9352 (Telnyx)

### Issue

All POST requests to create calls fail with:

```auto
HTTP 404 – Cannot POST /v1/create-phone-call

```

and also via `/v2/create-phone-call`.

This is confirmed via:

- CURL

- Asterisk AGI logs

- Retell Community forum (multiple reports)

### Request

Please **enable PSTN / Phone Calls API at the workspace level** for:

- Outbound PSTN calls

- AGI / API-initiated calls

This is currently **blocking production** , while all other components are verified working.

### Architecture

Asterisk → AGI → Retell API  
Telecom via Telnyx (US primary), Telecard local deferred.

Please confirm once PSTN permissions are enabled so we can retest immediately.

Regards,  
PAK SAIBAAN Workspace

---

<div class="post-metadata">

**Author:** ![support2](https://yyz2.discourse-cdn.com/flex008/user_avatar/community.retellai.com/support2/32/15_2.png) [@support2](https://community.retellai.com/u/support2)\
**Post date:** [January 21, 2026, 2:32pm UTC](https://community.retellai.com/t/retell-with-asterisk-agi/551/2 "2026-01-21T14:32:04Z")

</div>

* * *

The 404 error you’re encountering is most commonly caused by an improperly configured phone number in your Retell AI account[(1)](https://retell.discourse.group/t/404-error-on-create-a-phone-call/22). The endpoint path itself appears correct (`/v2/create-phone-call` is the current endpoint), so the issue is likely with your phone number setup or payload structure[(1)](https://retell.discourse.group/t/404-error-on-create-a-phone-call/22).

## Key Points to Verify

**Phone Number Configuration** : Your `from_number` (+1 (201) 379-9352) must be properly configured in Retell AI with an `outbound_agent_id`, or you need to use the `override_agent_id` parameter in your request[(1)](https://retell.discourse.group/t/404-error-on-create-a-phone-call/22).

**Correct Payload Structure** : Ensure you’re using the correct parameter names[(1)](https://retell.discourse.group/t/404-error-on-create-a-phone-call/22):

```typescript
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);

```

[(1)](https://retell.discourse.group/t/404-error-on-create-a-phone-call/22)

Use `override_agent_id` instead of `agent_id`, and `retell_llm_dynamic_variables` instead of `custom_data`[(1)](https://retell.discourse.group/t/404-error-on-create-a-phone-call/22):

```json
{
  "from_number": "+16504144521",
  "to_number": "your_target_number",
  "override_agent_id": "agent_71724df7636716ceb3a7e244c8",
  "retell_llm_dynamic_variables": {
    "name": "Sarah"
  }
}

```

[(1)](https://retell.discourse.group/t/404-error-on-create-a-phone-call/22)

## Phone Number Setup

If your Telnyx number isn’t properly imported into Retell AI, you’ll need to configure it[(1)](https://retell.discourse.group/t/404-error-on-create-a-phone-call/22). To update an existing phone number for outbound calls[(1)](https://retell.discourse.group/t/404-error-on-create-a-phone-call/22):

```typescript
const phoneNumberResponse = await client.phoneNumber.update('+14157774444', {
 inbound_agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD',
 nickname: 'Frontdesk Number',

```

[(1)](https://retell.discourse.group/t/404-error-on-create-a-phone-call/22)

Verify that your phone number has been purchased/imported and configured through Retell AI—you cannot use arbitrary numbers for the `from_number` parameter[(1)](https://retell.discourse.group/t/404-error-on-create-a-phone-call/22).

For further assistance with workspace-level permissions or Telnyx integration specifics, visit [Contact Sales](https://retellai.octolane.com/), ask questions on [Discord](https://discord.com/invite/wxtjkjj2zp), or visit [https://github.com/RetellAI/](https://github.com/RetellAI/).

---

<div class="post-metadata">

**Author:** ![Omar\_Ashraf](https://yyz2.discourse-cdn.com/flex008/user_avatar/community.retellai.com/omar_ashraf/32/102_2.png) [@Omar\_Ashraf](https://community.retellai.com/u/Omar_Ashraf)\
**Post date:** [January 21, 2026, 5:00pm UTC](https://community.retellai.com/t/retell-with-asterisk-agi/551/3 "2026-01-21T17:00:48Z")

</div>

Hello @paksaaibaan  
Please share the request you are making that gives you 404

and share your org id

---

<div class="post-metadata">

**Author:** ![paksaaibaan](https://avatars.discourse-cdn.com/v4/letter/p/ebca7d/32.png) [@paksaaibaan](https://community.retellai.com/u/paksaaibaan)\
**Post date:** [January 21, 2026, 6:11pm UTC](https://community.retellai.com/t/retell-with-asterisk-agi/551/5 "2026-01-21T18:11:51Z")

</div>

org\_ht8FyON99nTaQfQ0

---

<div class="post-metadata">

**Author:** ![support2](https://yyz2.discourse-cdn.com/flex008/user_avatar/community.retellai.com/support2/32/15_2.png) [@support2](https://community.retellai.com/u/support2)\
**Post date:** [January 21, 2026, 6:12pm UTC](https://community.retellai.com/t/retell-with-asterisk-agi/551/6 "2026-01-21T18:12:12Z")

</div>

The workspace ID `org_ht8FyON99nTaQfQ0` appears to be a Retell AI workspace identifier.[(1)](https://docs.retellai.com/accounts/workspace)

You can find your workspace ID in your workspace settings page.[(1)](https://docs.retellai.com/accounts/workspace) To access it:

1. Navigate to the system settings page and access your workspace settings[(1)](https://docs.retellai.com/accounts/workspace)
2. Retrieve the workspace id from the settings interface[(1)](https://docs.retellai.com/accounts/workspace)

The workspace ID (also referred to as org ID) is sometimes requested when debugging issues related to your account.[(1)](https://docs.retellai.com/accounts/workspace)

---

<div class="post-metadata">

**Author:** ![paksaaibaan](https://avatars.discourse-cdn.com/v4/letter/p/ebca7d/32.png) [@paksaaibaan](https://community.retellai.com/u/paksaaibaan)\
**Post date:** [January 21, 2026, 6:16pm UTC](https://community.retellai.com/t/retell-with-asterisk-agi/551/7 "2026-01-21T18:16:48Z")

</div>

Hello,

Yes, that is correct.

The workspace ID (organization ID) for our account is:  
org\_ht8FyON99nTaQfQ0

It was retrieved from System Settings → Workspace Settings.  
Please let me know if you also need the specific request or endpoint that is returning the 404 error.

Thanks.

---

<div class="post-metadata">

**Author:** ![paksaaibaan](https://avatars.discourse-cdn.com/v4/letter/p/ebca7d/32.png) [@paksaaibaan](https://community.retellai.com/u/paksaaibaan)\
**Post date:** [January 21, 2026, 6:22pm UTC](https://community.retellai.com/t/retell-with-asterisk-agi/551/8 "2026-01-21T18:22:44Z")

</div>

Hello Team,

Thank you for your response.

Below are the details you requested regarding the 404 error we are receiving from Retell during live call execution.

**Environment**

- Platform: Asterisk 20 (Ubuntu)

- Integration Method: AGI (Python)

- Call Source: SIP trunk (Telecard IP-based inbound)

- AGI Script: retell\_agi.py (executed successfully)

**Organization ID**

- Org ID: **{{org\_ht8FyON99nTaQfQ0}}**

**Request Being Made**  
The AGI script is making the following HTTP request to Retell when a live call is received:

- Method: POST

- URL: **{{PASTE\_EXACT\_RETELL\_API\_ENDPOINT\_HERE}}**

- Headers:

- Agent ID Used:

**Observed Behavior**

- The AGI script executes correctly.

- The HTTP request is sent during an active inbound call.

- Retell responds with **HTTP 404 (HTML response)**.

- The call then exits AGI and hangs up cleanly on Asterisk.

**Request**  
Kindly confirm:

1. Whether the endpoint URL being used is correct for live call handling.

2. Whether this agent ID is valid and active for our organization.

3. If any additional parameters or a different endpoint is required for SIP / Asterisk AGI integrations.

We are happy to share sanitized request payloads or logs if required.

Looking forward to your guidance.

Best regards,  
**paksaaibaan**

---

<div class="post-metadata">

**Author:** ![paksaaibaan](https://avatars.discourse-cdn.com/v4/letter/p/ebca7d/32.png) [@paksaaibaan](https://community.retellai.com/u/paksaaibaan)\
**Post date:** [January 22, 2026, 8:03am UTC](https://community.retellai.com/t/retell-with-asterisk-agi/551/10 "2026-01-22T08:03:37Z")

</div>

Hello Retell Team,

We are actively deploying a hybrid PSTN architecture using Telecard (local DID) and Asterisk.

Our current blocker is that inbound and outbound PSTN calls are not functioning because the Phone Calls / PSTN API does not appear to be enabled at the workspace level.

We confirm:

- Correct endpoint in use: `/v2/create-phone-call`

- API key is valid

- Agent is active

- Telecard & Telnyx numbers are available and routable

- Asterisk SIP and dialplan are stable

Request:  
Please enable **PSTN / Phone Calls API (Call Sessions)** for our workspace so that:

1. Inbound calls from Telecard via Asterisk can reach the Retell agent

2. Outbound calls can use our local Telecard number as caller ID

Workspace: PAK SAAIBAAN  
Plan: Pay-As-You-Go (ready to upgrade if required)

We are blocked only due to this enablement.

Best regards,  
paksaaibaan

---

<div class="post-metadata">

**Author:** ![Omar\_Ashraf](https://yyz2.discourse-cdn.com/flex008/user_avatar/community.retellai.com/omar_ashraf/32/102_2.png) [@Omar\_Ashraf](https://community.retellai.com/u/Omar_Ashraf)\
**Post date:** [January 22, 2026, 3:47pm UTC](https://community.retellai.com/t/retell-with-asterisk-agi/551/11 "2026-01-22T15:47:19Z")

</div>

Hello @paksaaibaan  
I need the exact request that is returning 404 for you, and also remove your API key from the response. This is a public channel.

---

<div class="post-metadata">

**Author:** ![paksaaibaan](https://avatars.discourse-cdn.com/v4/letter/p/ebca7d/32.png) [@paksaaibaan](https://community.retellai.com/u/paksaaibaan)\
**Post date:** [January 22, 2026, 6:36pm UTC](https://community.retellai.com/t/retell-with-asterisk-agi/551/13 "2026-01-22T18:36:46Z")

</div>

Hello Team,

Thank you for the response. I’d like to clarify and correct one point and share updated findings after reviewing the call logs.

---

<div class="post-metadata">

**Author:** ![paksaaibaan](https://avatars.discourse-cdn.com/v4/letter/p/ebca7d/32.png) [@paksaaibaan](https://community.retellai.com/u/paksaaibaan)\
**Post date:** [January 22, 2026, 6:37pm UTC](https://community.retellai.com/t/retell-with-asterisk-agi/551/14 "2026-01-22T18:37:16Z")

</div>

Hello Team,

Thank you for the response. I’d like to clarify and correct one point and share updated findings after reviewing the call logs.

* * *

### ![🔄](https://canada1.discourse-cdn.com/flex008/uploads/retell1/original/1X/93d3278f03c13ae7ede83207b6f224eb040084e8.png) Correction

We have tested outbound calls to **multiple different international numbers** (US and other regions as well), and the issue is **not limited to a single country**.

* * *

### ![📞](https://canada1.discourse-cdn.com/flex008/uploads/retell1/original/1X/da00f4060862a709cf9baee55e4c0b6852672411.png) Observed Behavior (From Call History)

From the Retell dashboard **Call History** :

- Outbound calls are being **initiated successfully**

- Calls appear with:

- No successful outbound call has connected to the destination number so far

Inbound calls, however, are working correctly and reach the assigned agent without issue.

* * *

### ![🧪](https://canada1.discourse-cdn.com/flex008/uploads/retell1/original/1X/5f7b3acf3e4bf6209b1f55c3d7aa1f871fef9321.png) Example API Test Used (Key Removed)

```auto
curl -i https://api.retellai.com/v2/create-phone-call \
  -H "Authorization: Bearer <REDACTED>" \
  -H "Content-Type: application/json" \
  -d '{
    "from_number": "+12013799352",
    "to_number": "+1XXXXXXXXXX"
  }'

```

The request is accepted and logged, but the call does not connect successfully.

* * *

### ![🔍](https://canada1.discourse-cdn.com/flex008/uploads/retell1/original/1X/83a848f047efd29b880999e39b3cd5c306dee4a3.png) Workspace & Number Configuration

- Workspace: **PAK SAAIBAAN**

- Plan: **Pay As You Go**

- Phone Number: `+1 (201) 379-9352` (Telnyx – visible in Retell dashboard)

- Inbound Call Agent: Assigned

- Outbound Call Agent: Assigned

- Allowed Outbound Countries: **All countries allowed**

Despite this, outbound calls consistently fail to connect.

* * *

### ![❓](https://canada1.discourse-cdn.com/flex008/uploads/retell1/original/1X/3009d34af2ae80e3cd3f9c84e29f957ce58dff18.png) Clarification Needed

Could you please confirm:

1. Whether outbound calling is **fully enabled** for Pay-As-You-Go workspaces using Telnyx-backed numbers.

2. If any **additional enablement, verification, or plan upgrade** is required for outbound PSTN calls to connect.

3. Whether the “dial no answer / not connected” outcome indicates a provider-level block or a workspace-level restriction.

* * *

Inbound calling is stable on our side; outbound connectivity is the only remaining blocker before we proceed further.

Looking forward to your guidance.

Best regards,  
**paksaaibaan**

---

<div class="post-metadata">

**Author:** ![home.tore](https://yyz2.discourse-cdn.com/flex008/user_avatar/community.retellai.com/home.tore/32/1626_2.png) [@home.tore](https://community.retellai.com/u/home.tore)\
**Post date:** [April 21, 2026, 6:50pm UTC](https://community.retellai.com/t/retell-with-asterisk-agi/551/15 "2026-04-21T18:50:27Z")

</div>

I wanted to share a working example of integrating Asterisk with Retell AI using **AGI + PJSIP + register-phone-call** for inbound PSTN calls.

This took some trial and error, so hopefully this saves someone else time.

## Final Working Call Flow

```auto
Carrier DID (BulkVS / Telnyx / etc)
→ Asterisk inbound trunk
→ Dialplan matches AI DID
→ AGI script calls Retell register-phone-call API
→ Retell returns call_id
→ Asterisk dials dynamic SIP URI
→ Retell agent answers

```

## Important Discovery

For **PJSIP dynamic SIP URI dialing** , the correct syntax is:

```auto
PJSIP/<endpoint>/sip:user@domain

```

This matches official Asterisk community guidance. ([Asterisk Community](https://community.asterisk.org/t/how-to-dial-dynamic-sip-uri-with-pjsip-in-asterisk-retell-ai-integration/108031?utm_source=chatgpt.com "How to Dial Dynamic SIP URI with PJSIP in Asterisk (Retell ..."))

So in this use case:

```auto
Dial(PJSIP/retell-direct/sip:${RETELL_CALL_ID}@sip.retellai.com,60)

```

That was the breakthrough.

* * *

# Example `pjsip.conf`

```auto
[transport-tcp]
type=transport
protocol=tcp
bind=0.0.0.0:5060

[retell-direct]
type=endpoint
transport=transport-tcp
disallow=all
allow=ulaw
aors=retell-direct
direct_media=no
rewrite_contact=yes
rtp_symmetric=yes
force_rport=yes
from_domain=sip.retellai.com
outbound_proxy=sip:sip.retellai.com\;lr

[retell-direct]
type=aor
max_contacts=1
contact=sip:sip.retellai.com:5060
qualify_frequency=60

```

* * *

# Example `extensions.conf`

```auto
[from-carrier]

exten => +1XXXXXXXXXX,1,NoOp(Inbound call to Retell AI DID)
 same => n,Set(CALLER_E164=${IF($["${CALLERID(num):0:1}" = "+"]?${CALLERID(num)}:+1${CALLERID(num)})})
 same => n,Set(DID_E164=+1XXXXXXXXXX)

 same => n,AGI(retell_register.py,${CALLER_E164},${DID_E164})

 same => n,NoOp(RETELL_CALL_ID=${RETELL_CALL_ID})
 same => n,NoOp(RETELL_ERROR=${RETELL_ERROR})

 same => n,GotoIf($["${RETELL_CALL_ID}"=""]?fail)

 same => n,Dial(PJSIP/retell-direct/sip:${RETELL_CALL_ID}@sip.retellai.com,60)
 same => n,Hangup()

 same => n(fail),NoOp(Retell registration failed: ${RETELL_ERROR})
 same => n,Playback(sorry-cant-let-you-do-that)
 same => n,Hangup()

```

* * *

# Example AGI Script (`retell_register.py`)

```auto
#!/usr/bin/env python3
import sys
import json
import urllib.request
import urllib.error

RETELL_API_KEY = "rtk_xxxxxxxxxxxxxxxxx"
RETELL_AGENT_ID = "agent_xxxxxxxxxxxxx"

def read_agi():
    while True:
        line = sys.stdin.readline().strip()
        if line == "":
            break

def agi_cmd(cmd):
    sys.stdout.write(cmd + "\n")
    sys.stdout.flush()
    return sys.stdin.readline()

def setvar(k,v):
    safe = str(v).replace('"','\\"')
    agi_cmd(f'SET VARIABLE {k} "{safe}"')

def main():
    read_agi()

    from_number = sys.argv[1]
    to_number = sys.argv[2]

    payload = {
        "agent_id": RETELL_AGENT_ID,
        "from_number": from_number,
        "to_number": to_number,
        "direction": "inbound"
    }

    req = urllib.request.Request(
        "https://api.retellai.com/v2/register-phone-call",
        data=json.dumps(payload).encode(),
        headers={
            "Authorization": f"Bearer {RETELL_API_KEY}",
            "Content-Type": "application/json"
        },
        method="POST"
    )

    try:
        with urllib.request.urlopen(req, timeout=10) as r:
            data = json.loads(r.read().decode())

        setvar("RETELL_CALL_ID", data["call_id"])
        setvar("RETELL_ERROR", "")

    except Exception as e:
        setvar("RETELL_CALL_ID", "")
        setvar("RETELL_ERROR", str(e))

if __name__ == " __main__":
    main()

```

Make executable:

```auto
chmod +x /var/lib/asterisk/agi-bin/retell_register.py

```

* * *

# Notes

## 1. Use REST API Key

Use the **Retell REST API key** , not webhook key.

## 2. Agent ID != Phone Number

Use:

```auto
agent_xxxxxxxxx

```

not the imported DID number.

## 3. DNS Check

Make sure your server resolves:

```auto
getent hosts sip.retellai.com

```

## 4. Firewall

Allow outbound SIP/RTP traffic.

## 5. Codec

I used:

```auto
allow=ulaw

```

* * *

# Final Result

Inbound PSTN calls now route:

```auto
Carrier DID → Asterisk → Retell AI agent

```

with full control of routing in Asterisk.

This lets you do:

- route only specific DIDs to AI

- time-of-day routing

- failover to queues/extensions

- blend human + AI call flows

- use your own carriers

Hope this helps someone.

Thanks to the Asterisk community thread that clarified the correct PJSIP URI format. ([Asterisk Community](https://community.asterisk.org/t/how-to-dial-dynamic-sip-uri-with-pjsip-in-asterisk-retell-ai-integration/108031?utm_source=chatgpt.com "How to Dial Dynamic SIP URI with PJSIP in Asterisk (Retell ..."))
