Skip to main content
POST
/
trunks
/
{id}
/
rotate-sip-password
Rotate SIP Password
curl --request POST \
  --url https://api.example.com/trunks/{id}/rotate-sip-password
{
  "id": "<string>",
  "sip_username": "<string>",
  "sip_password": "<string>",
  "rotated_at": "<string>"
}

Overview

Rotate the SIP password for a trunk. This invalidates the old password immediately.
Rotating the password will immediately invalidate the old password. Update your carrier configuration with the new password before rotating to avoid service interruption.

Request

id
string
required
The trunk ID (e.g., conn_abc123xyz)

Example Request

curl -X POST https://api.telepathvoice.com/v1/trunks/conn_abc123xyz/rotate-sip-password \
  -H "Authorization: Bearer sk_live_abc123def456..." \
  -H "Content-Type: application/json"

Python Example

import requests

API_KEY = "sk_live_abc123def456..."
TRUNK_ID = "conn_abc123xyz"

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}

response = requests.post(
    f"https://api.telepathvoice.com/v1/trunks/{TRUNK_ID}/rotate-sip-password",
    headers=headers
)

result = response.json()
print(f"New SIP password: {result['sip_password']}")

Response

id
string
Trunk identifier
sip_username
string
SIP username (unchanged)
sip_password
string
New SIP password
rotated_at
string
ISO 8601 rotation timestamp

Example Response

{
  "id": "conn_abc123xyz",
  "sip_username": "support-01",
  "sip_password": "NewSecurePassword456!",
  "rotated_at": "2024-03-05T17:00:00Z"
}

Error Responses

Trunk Not Found

{
  "error": {
    "code": "TRUNK_NOT_FOUND",
    "message": "Trunk 'conn_abc123xyz' not found"
  }
}
Status Code: 404

Best Practices

Before Rotating

  1. Record Old Password: Save old password for reference
  2. Note Timestamp: When you’re rotating
  3. Plan Carrier Update: Know which carrier configurations use this trunk

Rotation Process

  1. Rotate the Password: Call this API endpoint
  2. Copy New Password: From the response
  3. Update Carrier Configuration: Within 5 minutes
  4. Test Call: Verify calls still work
  5. Confirm: Password rotation is complete

After Rotating

  • ✅ New password is active immediately
  • ❌ Old password no longer works
  • Monitor for any call failures
  • Update any documentation

Usage Examples

Safe Rotation with Verification

def rotate_and_verify(api_key, trunk_id, carrier_config_func):
    """Rotate password and update carrier configuration"""

    headers = {
        "Authorization": f"Bearer {api_key}",
        "Content-Type": "application/json"
    }

    # 1. Rotate password
    response = requests.post(
        f"https://api.telepathvoice.com/v1/trunks/{trunk_id}/rotate-sip-password",
        headers=headers
    )

    if response.status_code != 200:
        print(f"Failed to rotate password: {response.json()}")
        return False

    result = response.json()
    new_password = result['sip_password']
    print(f"✓ Password rotated at {result['rotated_at']}")

    # 2. Update carrier
    try:
        carrier_config_func(
            trunk_id,
            result['sip_username'],
            new_password
        )
        print(f"✓ Carrier configuration updated")
    except Exception as e:
        print(f"✗ Failed to update carrier: {e}")
        return False

    # 3. Verify with test call
    print("Making test call to verify...")
    test_result = make_test_call(trunk_id)

    if test_result['success']:
        print(f"✓ Verification successful")
        return True
    else:
        print(f"✗ Verification failed: {test_result['error']}")
        return False

Scheduled Rotation

import schedule
import time
from datetime import timedelta

def schedule_password_rotations(api_key, trunk_ids, rotation_days=90):
    """Schedule automatic password rotation"""

    def rotate_all():
        for trunk_id in trunk_ids:
            try:
                rotate_and_verify(api_key, trunk_id, update_carrier)
                print(f"✓ Rotated password for {trunk_id}")
            except Exception as e:
                print(f"✗ Failed to rotate {trunk_id}: {e}")
                send_alert(f"Password rotation failed for {trunk_id}")

    # Schedule rotation every N days
    schedule.every(rotation_days).days.do(rotate_all)

    # Keep scheduler running
    while True:
        schedule.run_pending()
        time.sleep(60)

See Also