HTTP request
What it does
Section titled “What it does”HTTP request sends one HTTP request to an outside API each time it runs, through an API connection saved in Connections. The next block receives the data the block received and the response from the API. The block uses no model. It holds no secret and no host, because both come from the connection.
When to use it
Section titled “When to use it”Use HTTP request for an action that has to happen on every run: send an email through a mail service, create a ticket, post a message, or read a record from a service’s API. A tool on a Think block is different, because there a model decides whether to call it.
The block only sends. A Webhook start and an Until webhook pause receive requests, and Triggers, approvals, and waits covers both. HTTP request does not receive events from the API it calls. It sends one request per run, and no block repeats it for each item of a list.
Settings
Section titled “Settings”Add the block from the bottom toolbar’s ⋮ menu, where its entry reads API, or from the block palette, in the API group as HTTP request. Before a connection is chosen the card reads “Choose a connection”. After that it shows the method, the path as typed, and the connection’s name on one line, such as POST /v3/mail/send · SendGrid. The card keeps the name the connection had when it was chosen. A later rename shows the old name on the card and changes nothing when the block runs.
The panel lists the settings in this order.
| Setting | What it does | Default | Limits |
|---|---|---|---|
| Connection | The API connection the request goes through. The list shows only connections that have a base URL: each turned-on one as “Name · host” and the others under Turned off. A connection that only receives events is not listed. Below a chosen connection the panel reads “Requests go to” and the base URL. | None. The placeholder reads “Choose an API connection”. | Required to publish. A turned-off connection adds “This connection is turned off, so the block will fail until it is on”. A deleted one reads “<name> (deleted)”. |
| Request | The method and the path. “The path is added to the connection’s base URL. The host is always the connection’s.” The path’s placeholder is /v3/mail/send. |
POST, with an empty path. |
The method is GET, POST, PUT, PATCH, or DELETE. The path starts with / and holds no ?, #, space, backslash, full URL, or leading //. It has at most 2,048 characters after its values are filled in. |
| Query parameters | Name and value rows, added with Add parameter. A value can hold expressions. | None | At most 20. A name has at most 128 characters. A name that reads as a credential cannot be published. |
| Headers | Name and value rows, added with Add header. A value can hold expressions. “The connection adds its own authentication header. It cannot be set here.” | None | At most 20. A name has at most 128 characters and a value at most 4,096. The headers listed after this table cannot be set. |
| Body | No body, JSON, or Text. With a body chosen, Insert value appears beside the choice. | No body | A GET sends no body. The body as sent has at most 256 KB, and the stored template at most 64 KB. |
| Fail on an error status | Whether an answer outside 2xx fails the block. “Off, a 4xx or 5xx answer is passed on, so a Route block can read response.status.” | On | None |
| Timeout (seconds) | How long the block waits for the API. “The request is sent once and never retried, so a send is never repeated.” | 30 | 1 to 60 |
With no API connection in the workspace, the Connection setting reads “No API connections yet. Add one in Connections, then choose it here.” When the workspace has API connections and none has a base URL, the line starts “No API connection has a base URL to send to yet.” in place of “No API connections yet.” For members and higher roles, “Add one” links to the form that adds a connection.
If the base URL is removed from a connection after a block chose it, the panel reads “This connection only receives events: it has no base URL, so the block has nowhere to send a request. Choose another connection, or add a base URL to this one in Connections” below the list.
A block cannot set Authorization, Proxy-Authorization, Host, Content-Length, Cookie, Connection, or Transfer-Encoding, or the header its connection authenticates with. It can set Content-Type, which then replaces the default for the body.
A JSON body is sent as application/json. The panel says “Write JSON and put values in with {{ }}. Inside quotes a value is text, escaped for you. Without quotes it keeps its type: a number, a list, an object.” In "to": "{{input.email}}" the value is always text, whatever it resolves to. In "count": {{input.count}} the value keeps its type and is null when it is missing. The template has to be valid JSON once its values are taken out, and it can nest at most 64 levels deep.
A Text body is “Sent as written, with {{ }} values filled in.” A Content type field appears under it. Left empty, the body is sent as text/plain; charset=utf-8.
The path, the query and header values, and the body take the same expressions as the database blocks: {{input}}, {{steps["Block name"]}}, {{assets["Asset name"]}}, {{now}}, and {{today}}. A path can follow the root, as in {{input.body.email}} or {{steps["Draft"].subject}}. For an HTTP request block earlier in the workflow, Insert value offers {{steps["<name>"].response.body}} with the hint “What the API answered <name>”.
A value that an expression puts in the path is one path segment, and it is percent-encoded. The request is not sent when that value is empty, holds a / or a \, or consists only of dots.
The panel ends with the internal note and Before publishing, which reads “No issues. This block is ready to publish.” or the publish messages listed under How it fails, each starting “This block”.
Inputs and outputs
Section titled “Inputs and outputs”The block has one input and one output. The input takes one connection. To bring several paths into it, put a Merge or Join in front.
The output is an object with two fields. input is what the block received, unchanged. response holds what the API answered.
| Field | Value |
|---|---|
response.status |
The status code, as a number. |
response.ok |
true for a 2xx status. |
response.headers |
The response headers, with lower-cased names. |
response.body |
Parsed JSON when the API answers JSON, and text otherwise. null when the body is empty or is not text, such as an image or a PDF. |
The next block reads a header by its lower-cased name, as in {{input.response.headers["x-message-id"]}}. An API can answer with an empty body and put what the workflow needs in a header, so check both. set-cookie and the headers that describe the connection are dropped. At most 50 headers are kept, and each value is cut at 2,000 characters.
A response body over 256 KB is cut and kept as text, with bodyTruncated: true in response. A JSON answer too large or too deeply nested to keep parsed is kept as text. If the input and the response together are too large to keep, input is null and inputDropped is true. Each of these cases records a warning and the block still completes. A body that is not text also records a warning.
In a run, the inspector’s This run section shows the status code as a chip, or “No answer”, beside the request as POST /v3/mail/send. Below it reads “Through” and the connection’s name, which links to the connection’s page, with sizes such as “1.2 KB sent, 340 bytes received”. It then shows the credits, the duration, and any warning. The log line reads <Connection> answered 202 · POST /v3/mail/send, or No answer from <Connection> · POST /v3/mail/send. The run records the URL without its query string, and never a request header or the request body.
What it costs
Section titled “What it costs”HTTP request adds a flat fee for each request that is sent, whatever the API answers. A request that ends in an error status, a timeout, or an API that could not be reached is charged like any other. A block that fails before anything is sent adds no charge. There is no model cost. The inspector shows the fee for the run, and Models and usage says where to review charges.
How it fails
Section titled “How it fails”The request is sent once. It is never retried, for any method, status, or network error, and a redirect is not followed. When the block fails, its branch stops.
With Fail on an error status on, an answer outside 2xx fails the block, and the inspector shows the first 500 characters of what the API said. When the block fails before sending, the inspector reads “Nothing was sent. The branch stopped here”.
When publishing
Section titled “When publishing”Each message appears in the publish dialog after Block "<name>", and in the panel’s Before publishing section after “This block”.
| Message | Kind | Cause |
|---|---|---|
needs an API connection chosen |
Error | No connection is chosen. |
uses an API connection that no longer exists; choose another |
Error | The connection was deleted. |
uses the API connection "<name>", which only receives events and has no base URL to send to; add a base URL to it in Connections, or choose another |
Error | The connection has no base URL. |
uses the API connection "<name>", which is turned off; turn it on in Connections |
Error | The connection is turned off. |
needs a path, for example /v1/items |
Error | The path is empty. |
has a path that does not start with / |
Error | The path starts with another character. |
has a path that starts with //; a path names a place on the connection's host |
Error | The path starts with two slashes. |
has a ? or # in its path; add query parameters in their own fields |
Error | The path holds a query string or a fragment. |
has a space or a backslash in its path |
Error | The path holds a space or a \. |
has a full URL in its path; the host comes from the connection |
Error | The path holds ://. |
has a path longer than 2048 characters |
Error | The path as typed is too long. |
has more than 20 query parameters |
Error | Also has more than 20 headers. |
has a query parameter with a value and no name |
Error | Also has a header with a value and no name. |
has a query parameter name that is too long |
Error | The name has more than 128 characters. |
puts a credential in the query parameter "<name>"; anyone who can view this workflow could read it. Use the connection's authentication |
Error | The parameter’s whole name is one such as key, api_key, token, access_token, secret, password, or sig. Names such as keyword and author pass. |
has a header name that is not valid: "<name>" |
Error | The name holds a character a header name cannot have. |
sets the <Header> header, which the connection or the request itself owns |
Error | The header is one of the seven a block cannot set. |
sets the <Header> header, which its connection uses to authenticate |
Error | The header is the connection’s own API key header. |
has a value for the <Header> header that is too long |
Error | The value has more than 4,096 characters. |
is a GET with a body; a GET sends none |
Error | The method is GET and a body is chosen. |
has a JSON body that cannot be used: the JSON body is not valid JSON |
Error | The template does not parse once its values are taken out. The part after the colon can also read the JSON body is empty, the JSON body nests deeper than 64 levels, the JSON body contains a character that cannot be sent, an expression is missing its closing }}, or an empty expression {{ }}. |
has a content type that is not valid, for example text/plain or application/xml |
Error | The Content type of a text body has no /, is not one printable line, or has more than 200 characters. |
has a body template that is too long |
Error | The stored template is over 64 KB. |
has a timeout outside 1 to 60 seconds |
Error | The timeout is out of range. |
has an expression that cannot be read: <parse error> |
Error | An expression in the path, a query or header value, or a text body does not parse. |
references steps["<label>"] but no block is named "<label>" |
Error | An expression names a block the workflow does not have. |
references steps["<label>"] but N blocks are named "<label>"; give them different names |
Error | Two or more blocks share the name. |
names an asset that does not exist: "<name>" — upload it in Assets or pick another |
Error | An expression names an asset the workspace does not have. |
is a POST with no body |
Warning | Also for PUT and PATCH. |
references steps["<label>"], which cannot reach this block and may not have run |
Warning | The named block is not connected before this one. |
During a run
Section titled “During a run”These messages appear on the block in the run log and the inspector. <name> is the connection’s name. The last column says whether a request was sent, which is also whether the fee is charged.
| Message | Cause | Sent |
|---|---|---|
HTTP request has no API connection chosen. Unpublish the chart and fix the block. |
The workflow was published without a connection. | No |
API connection "<name>" no longer exists (deleted after this chart was published). Unpublish the chart and fix the block. |
The connection was deleted. | No |
API connection "<name>" is turned off, so nothing was sent. Turn it on in Connections, then run again. |
The connection is turned off. | No |
API connection "<name>" only receives events: it has no base URL, so there is nowhere to send a request. Add a base URL to it in Connections, or choose another connection. |
The connection’s base URL was removed after the workflow was published. | No |
API connection "<name>" has a base URL that cannot be called. Fix it in Connections. |
The saved base URL no longer passes the base URL rules. | No |
The secret of API connection "<name>" could not be read. Enter it again in Connections. |
The stored secret could not be decrypted. | No |
HTTP request could not find its workspace. |
The run has no workspace. | No |
The path could not be built: a value in the path resolved to nothing. |
An expression in the path gave an empty value. | No |
The path could not be built: a value in the path contains a slash, which is not allowed there. |
An expression in the path gave a value with a / or a \. |
No |
The path could not be built: a value in the path resolved to "..", which is not allowed there. |
An expression in the path gave a value made only of dots. | No |
The path is longer than 2048 characters once its values are filled in. |
The path is too long after its expressions resolve. | No |
The path leads outside the connection's base URL, so nothing was sent. |
The finished URL has another host or leaves the path prefix of the base URL. Also The request leads outside the connection's base URL, so nothing was sent. |
No |
The request URL could not be built from the connection's base URL and the path. |
The base URL and the path do not form a URL. | No |
Header <Header> resolved to a value with a line break or a character a header cannot carry. |
An expression in a header value gave such a character. | No |
A header of this request, or the secret of <name>, holds a character that cannot be sent. Nothing was sent. |
A header or the connection’s secret could not be put on the request. | No |
The body is <n> KB once its values are filled in; the limit is 256 KB. Nothing was sent. |
The body as sent is over the limit. | No |
The body could not be built: <reason>. |
The body’s expressions or JSON could not be resolved. Query parameter "<name>" could not be built: <reason>. and Header <Header> could not be built: <reason>. are the same failure in those fields. |
No |
The request could not be built from this block's settings, so nothing was sent. |
An unexpected failure before sending. | No |
<name> answered <status>. |
Fail on an error status is on and the status is outside 2xx. | Yes |
<name> answered <status>, a redirect, which is not followed. Point the path at the final address. |
Fail on an error status is on and the status is 3xx. | Yes |
<name> did not answer within <n> seconds. It may still have processed the request, so check before running again. |
The timeout passed with no answer. | Yes |
<name> answered <status> but did not finish sending its response within <n> seconds. It has processed the request. |
The status arrived and the body did not finish within the timeout. | Yes |
Could not reach <name>. Check the connection's base URL. |
The request failed on the network. | Yes |
The request to <name> was sent, but its result could not be read. Check <name> before running again. |
An unexpected failure after sending. | Yes |
Example
Section titled “Example”A workflow starts from a webhook with a refund request and opens a ticket in a help desk. The connection, named Help desk, has the base URL https://api.example.com. Connect an API shows how to add it. The block’s Request is POST with the path /v1/tickets, and its Body is JSON:
{ "subject": "Refund request for order {{input.body.order_id}}", "requester": "{{input.body.email}}", "amount": {{input.body.amount}}}subject and requester are inside quotes, so each is sent as text. amount stands without quotes, so it is sent as the number the webhook supplied, or as null when the request has no amount. If the API answers with JSON that holds an id, the next block reads it as {{input.response.body.id}}.