How to send data to Tableau using the Tableau API and MuleSoft

In this tutorial, you will learn how to interface with the Tableau API using MuleSoft to send data from your Mule application and visualize it in Tableau. Sending data to Tableau using MuleSoft is pretty straightforward, and we’ve even built a sample jar file for you to download and try out on your local machine, all you need to do is enter your own credentials. You will learn how to:
- Set up authentication with Tableau
- Fetch all of the current users in Tableau
- Create a new user in Tableau
- Delete an existing user in Tableau
- Initiate a file upload and append a file to upload to Tableau using Multipart
In order to get started, you first need to download Anypoint Studio and create your free Anypoint Platform trial account. Click the button below to get started:
Already have an account? Sign in.
Next, make sure to download the jar file by clicking the button below where all of the contents of this tutorial are documented:
Setting up authentication with Tableau is pretty straightforward using MuleSoft. The first step is to create a new flow called Authentication-Flow. Drag an HTTP Request connector into your flow and setup the configuration file with the following information:
- Base path: /api/3.6
- Protocol: HTTPS
- Host: XXX.online.tableau.com
- TLS Configuration: Edit Inline
For your TLS Configuration, make sure that you create a keystore and add it to your src/main/resources folder in your Mule application. If you have never learned how to create a keystore or secure an HTTPS endpoint, please follow the instructions in this tutorial.
For the HTTP Request settings, make sure you have the following settings:
- Method: POST
- Path: auth/signin
For your body, copy and paste the following XML code and add your Personal Access Token Name and Secret and Site ContentURL that you can copy from your Tableau account:
One you send this HTTP Request, Tableau will return you with your Site ID and Auth Token. You will need to save these as variables in your mule flow in order to use them throughout your Mule application.

Attached below is the DataWeave code for both setSiteID and setAuthToken variables:
Nice job, you have completed your authentication flow and successfully authenticated with Tableau.
In this flow, our goal is to return all of the current users in our Tableau instance. Create a new flow by dragging an HTTP Listener onto your canvas. Name the path /query-users and add a flow reference to the Authentication-Flow that you created in the previous step.

Next, drag an HTTP Request connector into your flow and select the HTTP Request Configuration file you used for your Authentication-Flow that contains the HTTPS endpoint. Add the following configuration to your request:
- Method: GET
- Path: sites/{siteId}/users
- Body: payload
For your Headers, add the following code to add the x-tableau-auth to your request:
For your URI Parameters, add the following code to replace {siteId} with the site ID that you fetch in your Authentication-Flow:
Nice job, you have successfully fetched users from Tableau. To test it out, load up Postman and send a request to /query-users. You should get a request similar to what you see below:


To create a new user in our Tableau dashboard, we are going to create an API endpoint that allows you to submit query parameters that include the following:
- Set Username
- Save Role
- Set Password
- Set Email
You can find all the information on how to add a new user to Tableau if you visit the Tableau API documentation page. You can set various site roles such as Creator, Explorer, Viewer etc.
Create a new flow by dragging an HTTP Listener onto your canvas. Name the path /create-user. Next, create variables for each of the query parameters by using the DataWeave code: attributes.queryParams.username, attributes.queryParams.role, attributes.queryParams.password, attributes.queryParams.email
To read more about how to set up custom headers, query, and URI parameters in DataWeave, make sure to read this article. Next, drag a flow reference to the Authentication-Flow that you created in the previous step and drag an HTTP Request Connector after the authentication flow reference with the following settings:
- Method: POST
- Path: sites/{siteId}/users
For the body of the request add the following JSON:
For your Headers, add the following code to add the x-tableau-auth to your request:
For your URI Parameters, add the following code to replace {siteId} with the site ID that you fetch in your Authentication-Flow:
To delete an existing user in Tableau, you will need to query a backup owner ID and update ownership for each account. The best way to do this is to download the jar file at the top of the tutorial and load the project into your own Anypoint Studio IDE.

In this flow, our goal is to upload a file to our Tableau server. Create a new flow by dragging an HTTP Listener onto your canvas. Name the path /file-upload and add a flow reference to the Authentication-Flow that you created in the previous step. Next, drag an HTTP Request connector into your flow and use the same HTTP Request Configuration that you’ve used for the previous steps.
- Method: POST
- Path: sites/{siteId}/fileUploads
- Body: payload
For your Headers, add the following code to add the x-tableau-auth to your request:
For your URI Parameters, add the following code to replace {siteId} with the site ID that you fetch in your Authentication-Flow:
Next, add a Set Variable connector to your flow and name it uploadSessionId. Input the following dataweave code to save the session ID as a variable:
Next, drag another HTTP Request connector into your flow. This HTTP Request will append a file to upload to Tableau. The contents of this payload are defined on the Tableau API documentation.
- Method: PUT
- Path: sites/{siteId}/fileUploads/{uploadSessionId}
For the body, you will need to format a multipart message that contains your tdsx file which is located in your src/main/resources folder. The file will be sent as a binary, as defined by application/octet-stream and you will need to set a boundary for your multipart message as well in the output header. The following DataWeave script below will transform your JSON message to a Multipart form message:
For your Headers, add the following code to add the x-tableau-auth to your request:
For your URI Parameters, add the following code to replace {siteId} and {uploadSessionId} with siteID and uploadSessionId that you fetch in your Authentication-Flow:
The next step is to add another HTTP Request connector to your flow. This HTTP Request will publish the datasource to Tableau and will overwrite any existing datasource.
- Method: POST
- Path: sites/{siteId}/datasources?uploadSessionId={uploadSessionId}&datasourceType=tdsx&overwrite=true
For the Body of the response, enter the following DataWeave code and input your own project ID:
Copy the Headers and URI Parameters from the previous HTTP Request to finish the publishing of your datasource to Tableau.
Now that you have learned how to integrate with the Tableau API, feel free to visit their developer portal to learn about more integrations that you can create with Tableau and MuleSoft. Additionally, if you want to read more MuleSoft tutorials to help you get started with the platform, visit developer.mulesoft.com. If you want to learn how to deploy your Tableau application to CloudHub, visit our Hello Mule tutorial to learn how to publish your first Mule application.