Connecting to an API

Connect to any REST, GraphQL or SOAP API.

You can make requests to any HTTP, GraphQL or SOAP API with Retool. Many developers get data from their own internal APIs, render them in Tables, then post data (like resetting passwords) back again to their own API. But you can also connect Retool to APIs like Stripe, Salesforce, Slack, etc.

You query REST resources in an interface where you can set URL params, headers and cookies:

POSTing to httpbin

Need help authenticating? Check out our dedicated auth docs.

📘

Video: connecting your API to Retool

We put together a video that walks through the basics of connecting an API to Retool here.

JSON Body in API requests

By default, it is easy to construct a JSON object using the key-value interface. To create a more complex structure, you can nest objects as children of a key like below:

Alternatively, you can also switch from the key-value interface to send custom JSON. Here is an equivalent query to above. You will need to specify the Content-Type header in order for this to work.

🚧

Formatting JSON can be a little confusing at first!

For a value that should be a string, make sure to wrap the {{ }} with double quotes.
For a value that is a boolean / number, do not wrap the {{ }} with double quotes.
For a value that is an object / array, wrap the value inside with a JSON.stringify

Since it can be a little confusing at times to discover the right way to format, an easy alternative is to just construct the entire object dynamically like below:

SOAP APIs

SOAP API can be done very similarly. See SOAP APIs

Uploading Files

Retool currently supports two methods for uploading files

  • Uploading a binary file without any metadata
  • Uploading a file using FormData

Here are some quick examples:

The filepicker component

The button will allow you to instruct users to select a file to upload. In the screenshot above, once the file has been selected, uploadFile will be run.

Uploading using binary

Uploading using form data

Misc. features

How do I automatically add user specific information like the user's email or Google ID?

📘

Only available for on-prem users of Retool

If you want the API requests that get made in Retool to contain information about the user who made the request, you can use two magic constants in the API Resource configuration screen.

%USER_PRIMARY_EMAIL%
%USER_GOOGLE_ID%

For example, if you want every api request to contain an extra header called X-User-Email and X-User-Google-Id you can just add two new resource headers like in the screenshot below.

Updated 5 months ago


Connecting to an API


Connect to any REST, GraphQL or SOAP API.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.