Production-ready reference implementation for Exotel vSIP APIs in multiple programming languages (cURL, Python, PHP, Go, Java) with comprehensive error handling and testing framework.
- π§ Complete API Coverage: All 5 core vSIP operations
- π Multi-Language Support: cURL, Python, PHP, Go, Java
- π§ͺ Comprehensive Testing: 35+ test scenarios, all error codes covered
- π Complete Documentation: 900+ lines of error reference and guides
- π Production-Ready: Robust error handling, validation, logging
- π Zero Dependencies: Core implementations use standard libraries only
| Operation | Description | Endpoint |
|---|---|---|
| Trunk Creation | Create new SIP trunk | POST /trunks |
| DID Mapping | Map phone number to trunk | POST /trunks/{sid}/phone-numbers |
| IP Whitelisting | Whitelist IP addresses | POST /trunks/{sid}/whitelisted-ips |
| Destination URIs | Configure SIP destinations (UDP/TCP/TLS) | POST /trunks/{sid}/destination-uris |
| Trunk Settings | Set trunk configuration | POST /trunks/{sid}/settings |
git clone https://github.com/your-username/exotel-vsip-trunk-api.git
cd exotel-vsip-trunk-api
# Copy environment template and add your credentials
cp .env.example .env
# Edit .env with your Exotel API credentialscd curl/
./create_trunk.shcd python/
python3 create_trunk.py
# Or run comprehensive test suite
python3 tests/test_all_apis.py# Install Python testing dependencies (optional)
pip3 install -r tests/requirements.txt
# Run all tests to validate your setup
python3 tests/test_all_apis.py --verboseβββ curl/ # π’ Bash/cURL examples (production-ready)
βββ python/ # π’ Python examples (production-ready)
βββ php/ # π‘ PHP examples (ready, not tested live)
βββ go/ # π‘ Go examples (ready, not tested live)
βββ java/ # π‘ Java examples (ready, not tested live)
βββ tests/ # π§ͺ Comprehensive testing framework
β βββ test_all_apis.py # Main test suite (35+ scenarios)
β βββ mock_server.py # Local development server
β βββ load_test.py # Performance testing
β βββ requirements.txt # Python dependencies
βββ docs/ # π Documentation
β βββ DEBUGGING.md # Debugging guide
β βββ ERROR_REPORTS.md # Error analysis
β βββ TESTING_SETUP.md # Testing framework setup
β βββ TESTING_SUMMARY.md # Testing overview
βββ logs/ # π Test results and logs (gitignored)
βββ .env.example # π§ Environment template
βββ .gitignore # π Security-focused gitignore
βββ TRUNK_ERRORS_README.md # π¨ Complete error reference (668 lines)
βββ COMPREHENSIVE_TESTING_SUMMARY.md # π Testing summary
βββ README.md # π This file
Copy .env.example to .env and configure with your Exotel credentials:
| Variable | Description | Where to Find | Example |
|---|---|---|---|
EXO_AUTH_KEY |
Your Exotel API Key | API Settings | your_api_key_here |
EXO_AUTH_TOKEN |
Your Exotel Auth Token | API Settings | your_auth_token_here |
EXO_SUBSCRIBIX_DOMAIN |
Exotel API Domain | API Settings | api.in.exotel.com |
EXO_ACCOUNT_SID |
Your Account SID | API Settings | your_account_sid_here |
| Variable | Description | Where to Find | Default |
|---|---|---|---|
TRUNK_NAME |
Trunk Name (β€16 chars) | Choose any unique name | my_test_trunk |
DID_NUMBER |
DID in E.164 format | Virtual Numbers | +1234567890 |
WHITELIST_IP |
IP to whitelist | Your SIP server's public IP | 192.168.1.100 |
TRUNK_DEST_IP |
Your SIP server IP | Your SIP server's IP address | your_sip_server_ip |
EXOPHONE |
Virtual number for alias | Virtual Numbers | +1234567890 |
π Security: Never commit your .env file. It's included in .gitignore.
# Import files from postman/ directory:
# - Exotel_vSIP_API_Collection.json
# - Exotel_vSIP_Environment.json
# Features:
# β
All 5 API operations ready to use
# π Automatic authentication
# π TRUNK_SID auto-population
# β
Response validation tests
# π Rich documentationπ See postman/POSTMAN_GUIDE.md for complete Postman setup
# Run all API tests (35+ scenarios)
python3 tests/test_all_apis.py
# Run specific operation
python3 tests/test_all_apis.py --test create
python3 tests/test_all_apis.py --test map
# Verbose mode with detailed logging
python3 tests/test_all_apis.py --verbose# Start local mock server
python3 tests/mock_server.py
# Test against mock server (different terminal)
export EXO_SUBSCRIBIX_DOMAIN=localhost:8000
python3 tests/test_all_apis.py# Performance and rate limit testing
python3 tests/load_test.py# Test all language implementations
./tests/test_runner.sh| Language | Status | Location | Dependencies | Notes |
|---|---|---|---|---|
| cURL/Bash | β Production Ready | curl/ |
None | Tested with real API |
| Python | β Production Ready | python/ |
None (stdlib only) | Tested with real API |
| PHP | π‘ Ready | php/ |
cURL extension | Not tested live |
| Go | π‘ Ready | go/ |
Go 1.16+ | Not tested live |
| Java | π‘ Ready | java/ |
Java 11+ | Not tested live |
TRUNK_ERRORS_README.md- π¨ Complete error reference (668 lines)- All 17+ error codes with examples and solutions
- Troubleshooting guide with step-by-step debugging
- Best practices for error handling and validation
- Production-ready error handling code examples
COMPREHENSIVE_TESTING_SUMMARY.md- π Complete testing summarydocs/TESTING_SETUP.md- Testing framework setup guidedocs/DEBUGGING.md- Debugging and troubleshooting guide
docs/ERROR_REPORTS.md- Detailed error analysis and resolution strategies
import os
from _client import post
result = post("/trunks", {
"trunk_name": os.getenv("TRUNK_NAME", "my_trunk"),
"nso_code": "ANY-ANY",
"domain_name": f"{os.getenv('EXO_ACCOUNT_SID')}.pstn.exotel.com"
})
print(f"β
Trunk created: {result['trunk_sid']}")curl -X POST "https://${EXO_AUTH_KEY}:${EXO_AUTH_TOKEN}@${EXO_SUBSCRIBIX_DOMAIN}/v2/accounts/${EXO_ACCOUNT_SID}/trunks/${TRUNK_SID}/phone-numbers" \
-H "Content-Type: application/json" \
-d '{"phone_number":"'${DID_NUMBER}'"}'def handle_exotel_error(response_data):
error_code = response_data.get('response', {}).get('error_data', {}).get('code')
if error_code == 1010:
return "Authentication failed - check credentials"
elif error_code == 1002:
return f"Validation error: {response_data['response']['error_data']['description']}"
elif error_code == 1008:
return "Resource already exists - use different name"
# ... see TRUNK_ERRORS_README.md for complete error handling| Code | Description | Solution |
|---|---|---|
| 1010 | Authorization failed | Check API credentials in .env |
| 1002 | Invalid parameter | Validate input format (see error reference) |
| 1008 | Duplicate resource | Use unique names/IDs |
| 1001 | Missing parameter | Include all required fields |
| 1007 | Invalid JSON | Check request body syntax |
| 1011 | Wrong content type | Use application/json |
π Complete Reference: See TRUNK_ERRORS_README.md for all 17+ error scenarios with examples and solutions.
- cURL: Available on most systems
- Python: 3.6+ (no external dependencies for core functionality)
- PHP: 7.0+ with cURL extension
- Go: 1.16+
- Java: 11+
pip3 install -r tests/requirements.txt- π Credentials: Store in
.envfile, never commit to git - π Rotation: Regularly rotate API keys
- π Monitoring: Monitor API usage in Exotel dashboard
- π HTTPS: Always use HTTPS for API calls
- π‘οΈ Validation: Validate all inputs before API calls
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
- All new features must include tests
- Run full test suite:
python3 tests/test_all_apis.py - Update documentation for new error scenarios
This project is licensed under the terms specified in the LICENSE file.
- π API Credentials: Get your API Keys & Account SID
- π± Virtual Numbers: Manage your DIDs/Exophones
- π Call Flows: Create flows with Connect Applet
- π¨ Error Reference:
TRUNK_ERRORS_README.md - π Issues: Create GitHub Issue
- π§ Exotel Support: Contact via your Exotel dashboard
- π API Documentation: Exotel Developer Portal
- π§ͺ Testing Guide:
docs/TESTING_SETUP.md
| Metric | Status |
|---|---|
| API Coverage | β 100% (5/5 operations) |
| Error Scenarios | β 35+ tested |
| Error Codes | β 17+ documented |
| Documentation | β 900+ lines |
| Production Ready | β Yes |
| Live Testing | β Validated with real Exotel account |
π Ready for production integration with comprehensive error handling and multi-language support!