Twilio API
Stateful Twilio REST emulation with seeded accounts, Auth Tokens, API keys, incoming phone numbers, Programmable Messaging, Messaging Services, Verify, basic Voice calls, Conversations REST resources, signed webhooks, local simulator routes, and an inspector.
Start
When Twilio is the only enabled service, it starts on http://localhost:4000. When all services are started, it uses http://localhost:4013.
Defaults
URL Mapping
| Real Twilio URL | Emulator URL |
|---|---|
https://api.twilio.com/2010-04-01/... | $TWILIO_EMULATOR_URL/2010-04-01/... |
https://messaging.twilio.com/v1/... | $TWILIO_EMULATOR_URL/messaging/v1/... |
https://verify.twilio.com/v2/... | $TWILIO_EMULATOR_URL/verify/v2/... |
https://conversations.twilio.com/v1/... | $TWILIO_EMULATOR_URL/conversations/v1/... |
The official Node SDK builds absolute Twilio product URLs. In SDK tests, use a custom request client that rewrites those hosts to the emulator prefixes above.
Only an active account can send messages or place calls. Set the seeded account status to suspended or closed, or update it with POST /2010-04-01/Accounts/{AccountSid}.json and Status, to test the failure: message and call creation return HTTP 401 with error 20005, "Account not active". Set the status back to active to restore them.
Supported Routes
GET /2010-04-01/Accounts/{AccountSid}.jsonGET /2010-04-01/Accounts/{AccountSid}/IncomingPhoneNumbers.jsonPOST /2010-04-01/Accounts/{AccountSid}/IncomingPhoneNumbers.jsonPOST /2010-04-01/Accounts/{AccountSid}/Messages.jsonGET /2010-04-01/Accounts/{AccountSid}/Messages.jsonGET /2010-04-01/Accounts/{AccountSid}/Messages/{MessageSid}.jsonPOST /2010-04-01/Accounts/{AccountSid}/Messages/{MessageSid}.jsonDELETE /2010-04-01/Accounts/{AccountSid}/Messages/{MessageSid}.jsonPOST /2010-04-01/Accounts/{AccountSid}/Calls.jsonGET /2010-04-01/Accounts/{AccountSid}/Calls.jsonPOST /messaging/v1/ServicesGET /messaging/v1/ServicesPOST /verify/v2/Services/{ServiceSid}/VerificationsPOST /verify/v2/Services/{ServiceSid}/VerificationCheckPOST /conversations/v1/ServicesPOST /conversations/v1/Services/{ServiceSid}/ConversationsPOST /conversations/v1/Services/{ServiceSid}/Conversations/{ConversationSid}/ParticipantsPOST /conversations/v1/Services/{ServiceSid}/Conversations/{ConversationSid}/Messages
SMS And OTP Testing
The seeded Verify Service uses code 123456, so most local OTP tests can start a verification through the normal Verify API and submit that code. Tests that need to read the current local code can use the authenticated helper route:
The helper returns the latest local verification for that phone number, including verification_sid, status, attempts, and code. It is local-only test support, not a production Twilio API. The Verify inspector also shows each attempted code.
For inbound SMS, configure a phone number sms_url, then call POST /_twilio/simulate/inbound-message with To, From, and Body. If the destination number is assigned to a Messaging Service with inbound_request_url, the simulator sends the inbound webhook there and includes MessagingServiceSid; otherwise it uses the phone number sms_url. For outbound delivery transitions, create a message with StatusCallback, then call POST /_twilio/simulate/message-status.
Simulator
POST /_twilio/simulate/inbound-messagePOST /_twilio/simulate/message-statusGET /_twilio/simulate/verification-codePOST /_twilio/simulate/inbound-callPOST /_twilio/simulate/call-statusPOST /_twilio/simulate/verification-status
Seed Config
Inspector
Open GET / in the Twilio emulator to inspect messages, Verify attempts, calls, Conversations, phone numbers, services, credentials, and webhook deliveries.
Current Limits
No real SMS, MMS, WhatsApp, email, voice, carrier, compliance, billing, SendGrid, Studio, Flex, TaskRouter, Video, Sync, Segment, Conversations SDK websocket behavior, or complete TwiML interpreter behavior is implemented.