The best way to understand how Twilio Functions works is to start by understanding the HTTP request flow and how Twilio ultimately executes your code. Twilio Functions is designed to handle as much of the infrastructure work of building a web app as possible so that you can focus on application logic instead. For Twilio Functions, this work begins at the front door, handling the HTTP request for your Function and continues through the pipeline up to your code.
HTTP 400
response.context
and event
. Once the payload has been constructed, it is used to invoke your Function.handler
code that you have provided. When your Function completes executing, it can emit a response using the callback
method. The emitted response will be transmitted to the Function Gateway.Currently, Twilio Functions only supports HTTP requests. Twilio Functions will respond to three HTTP verbs: GET
, POST
, and OPTIONS
. PUT
and DELETE
are currently not supported.
For POST
requests, Twilio Functions natively supports the application/json
and application/x-www-form-urlencoded
content types. This means that JSON bodies and form and query parameters will be normalized into the event parameter.
There are several important limitations to Twilio Functions that you should consider when designing your application:
HTTP 504 Gateway Time-out
response.Now that you have an understanding of the request flow to your Functions, it's time to learn about the execution process, handler method, and response building processes.