Level up your Twilio API skills in TwilioQuest, an educational game for Mac, Windows, and Linux. Download Now

Menu

Expand
Rate this page:

Thanks for rating this page!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

HTTP Request

HTTP Request widget

Description:

HTTP Request allows you to interact with applications and code that live outside Studio. Use this widget to interact with parts of your business logic not defined in flows or as Functions.

Note: Returning custom TwiML from an HTTP Request widget isn't supported. Use the Run Function widget instead, and follow our guide for returning custom TwiML from Twilio Functions.

Required Configuration:

The required fields for this Widget are Request Method and Request URL. The Request Method can be selected from a dropdown, and the URL is able to be set as Automatic.

Name

Description

Request Method

The desired HTTP method of your request (GET or POST)

Request URL

The URL you would like to make a request to.

Tip: For secure URLs, add your Basic Authentication credentials. Example: https://user:password@mydomain.com/handler.php

Content Type Content type of the request body, either application/x-www-form-urlencoded or application/json.

Optional Configuration:

You may optionally decide to declare a request body and HTTP parameters for this Widget.

Name

Description

Request Body

Text to include as the body of your request.

HTTP Parameters

Key-value pairs of parameters to pass along with the request. String literals and variables are supported.


Transitions:

This Widget has two events that trigger transitions.

Name

Description

Success

A successful return (HTTP 20X)

Fail

The URL does not successfully return (or has an error)

Response:

The HTTP response from the URL must return a 2xx status code within 5 seconds, and the response body must not exceed 64kB.

Response Recommendation Notes
Status Code 200 or 204 3xx redirection is supported. 4xx or 5xx status code will transition to "failed" in the widget.
Content Type application/json Content-Type header is not required if Status Code is 204 No Content. Other content types are supported, such as plain text or XML. But only application/json objects (e.g. {"foo":"bar"}) will be automatically parsed into Studio variables.
Body valid JSON Body content must match the Content-Type header.
Response Time 5 seconds or less Studio will timeout the request at 5 seconds and transition to "failed" in the widget.
Response Size Maximum 64kb Studio can only process responses up to 64kB.


Variables:

Json: If your function returns valid Json, you should be able to access it via widgets.MY_WIDGET_NAME.parsed

For example, if you return {"message": "Hi", "person": {"name": "Bob", "age": 40}}, you can reference that in subsequent widgets as:

widgets.MY_WIDGET_NAME.parsed.message

widgets.MY_WIDGET_NAME.parsed.person.name

widgets.MY_WIDGET_NAME.parsed.person.age

For all return types, you will have the following variables:

widgets.MY_WIDGET_NAME.body

widgets.MY_WIDGET_NAME.status_code

widgets.MY_WIDGET_NAME.content_type

Rate this page:

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.