March 13, 2020 By Jason Zhou 3 min read

IBM Watson Studio provides you with the environment and tools to solve your business problems by collaboratively working with data.

You can choose the tools you need to analyze and visualize data, to cleanse and shape data, to ingest streaming data, or to create and train machine learning models.

Users can manage assets under the IBM Watson Studio project via the web interface, but you can also use a collection of Watson Data REST APIs associated with Watson Studio and Watson Knowledge Catalog to manage data-related assets and the people who need to use these assets. 

This post will outline how to manage the project assets through the API command line interface. Users who are interested in automating the process may benefit from this content.  

1. Create the user token 

The Watson Data API documentation provides instructions on creating an IAM bearer token.

To create a token in the IBM Cloud, log in to IBM Cloud and select Manage > Access (IAM) > IBM Cloud API Keys.

Create an API key for your own personal identity, copy the key value, and save it in a secure place. After you leave the page, you will no longer be able to access this value.

Use this curl command to retrieve a token:

curl "" \       
-d "apikey=YOUR_API_KEY_HERE&grant_type=urn%3Aibm%3Aparams%3Aoauth%3Agrant-type%3Aapikey" \       
-H "Content-Type: application/x-www-form-urlencoded" \       
-H "Authorization: Basic Yng6Yng="

Sample response:

        "access_token": "eyJraWQiOiIyMDE3MDgwOS0wMDowMDowMCIsImFsZyI6...",
        "refresh_token": "zmRTQFKhASUdF76Av6IUzi9dtB7ip8F2XV5fNgoRQ0mbQgD5XCeWkQhjlJ1dZi8K...",
        "token_type": "Bearer",
        "expires_in": 3600,
        "expiration": 1505865282

Since, by default, the access token expires after an hour, it’s easier to use a script to get the IAM access token and refresh it when you need to. 

A sample shell script:

api_key=<your API key>

curl -k -X POST \--header "Authorization: Basic Yng6Yng=" \
--header "Content-Type: application/x-www-form-urlencoded" \
--header "Accept: application/json" \
--data-urlencode "grant_type=urn:ibm:params:oauth:grant-type:apikey" \
--data-urlencode "${api_key}" \
-o token_resp.txt \

token=`cat token_resp.txt | jq '. "access_token"'`
token=`echo "$token" | tr -d '"'`
echo "Authorization: Bearer $token" > wml_token.txt

Note: The script was created on MacOS—you might need to modify it to run correctly in other OS. ‘jq’ is a utility to format the output in JSON format. 

2. Get the data asset

Once you have retrieved the access token, you can use it to access the data asset. For example, you may get the data asset by using something similar to the following code:

project_id="<project id>"
data_asset_id="<data asset id>"

curl -H 'accept: application/json' -H 'Content-Type: application/json' -H "$(cat wml_token.txt)" -X GET "${end_point}/v2/data_assets/${data_asset_id}?project_id=${project_id}"

The access token is read from the stored text file in Step 1 wml_token.txt.

Tip: You can get the data_asset_id and project_id from the URL of the Watson Studio interface:

Click on the data file GoSales.csv and you can see the URL in the following screenshot:

Sample output:

3. (Optional) Delete the asset

Run the following curl command to delete the asset if you wish:

curl -H 'accept: application/json' -H 'Content-Type: application/json' -H "$(cat wml_token.txt)" -X DELETE "${end_point}/v2/data_assets/${data_asset_id}?project_id=${project_id}"


The Watson Data API provides a comprehensive list of functions to manage the assets, and most GUI interface based functions can also be implemented with the API command line.

You can also follow these guidelines to access other various assets in Watson Studio, such as projects, catalogs, buckets, etc. For further information on the API, please refer to the online documentation at IBM Watson Data API.

Was this article helpful?

More from Cloud

A clear path to value: Overcome challenges on your FinOps journey 

3 min read - In recent years, cloud adoption services have accelerated, with companies increasingly moving from traditional on-premises hosting to public cloud solutions. However, the rise of hybrid and multi-cloud patterns has led to challenges in optimizing value and controlling cloud expenditure, resulting in a shift from capital to operational expenses.   According to a Gartner report, cloud operational expenses are expected to surpass traditional IT spending, reflecting the ongoing transformation in expenditure patterns by 2025. FinOps is an evolving cloud financial management discipline…

IBM Power8 end of service: What are my options?

3 min read - IBM Power8® generation of IBM Power Systems was introduced ten years ago and it is now time to retire that generation. The end-of-service (EoS) support for the entire IBM Power8 server line is scheduled for this year, commencing in March 2024 and concluding in October 2024. EoS dates vary by model: 31 March 2024: maintenance expires for Power Systems S812LC, S822, S822L, 822LC, 824 and 824L. 31 May 2024: maintenance expires for Power Systems S812L, S814 and 822LC. 31 October…

24 IBM offerings winning TrustRadius 2024 Top Rated Awards

2 min read - TrustRadius is a buyer intelligence platform for business technology. Comprehensive product information, in-depth customer insights and peer conversations enable buyers to make confident decisions. “Earning a Top Rated Award means the vendor has excellent customer satisfaction and proven credibility. It’s based entirely on reviews and customer sentiment,” said Becky Susko, TrustRadius, Marketing Program Manager of Awards. Top Rated Awards have to be earned: Gain 10+ new reviews in the past 12 months Earn a trScore of 7.5 or higher from…

IBM Newsletters

Get our newsletters and topic updates that deliver the latest thought leadership and insights on emerging trends.
Subscribe now More newsletters