This project demonstrates how to create boards, lists, card, checklist, and label using the Trello API via Postman.
- Requirements
- Getting API Key and Token
- Postman Setting Environment and Global Variables
- API Operations
- Collection Runner
- Dynamic Variables
- Pre-request Scripts
- Postman (Web or Desktop)
- Trello (Web or Desktop)
- Trello API Key and Token
- Trello Rest API Documentation
-
Create an Account on Trello
-
Create a Workspace on Trello
-
Activate the Power-Up
-
Click the New button in the upper right corner
-
Fill in the new power-up field and select workspace then click the Create button
-
Click the Generate a new API Key button
-
Then API Key is created and final step click the Token button
- Create a Collection on Trello
-
Create a Collection on Trello
-
Click the Variables in this Request button in the upper right corner
- Click the Enviroment button
- Give names for key and token and enter the token and key values
-
Repeat step 3.
-
Click the Globals
-
Add the baseURL portion of the url from the REST API documentation.
For example, in this URL, https://api.trello.com/1/actions/{id}?key=APIKey&token=APIToken ---> the BaseURL is https://api.trello.com/
- Open the Trello Rest API Documentation
- Copy the URL in the Trello Rest API Documentation
- Go to Postman
- Create a new request and give a name (Create a Board). The method type for this operation is POST. Choose POST. Paste the URL and Convert the BaseURL part of URL to the global variable we created for BaseURL. Use enviroment variables we created for API Key and Token. Then give a name for new board.
- Write test to check the response status code.
- Send the request. Response status code should be 200.
- Check the Trello.
- Open the Trello Rest API Documentation
- Copy the URL in the Trello Rest API Documentation
- Go to Postman. Create a new request and give a name (Create a new List). The method type for this operation is POST. Choose POST. Paste the URL and Convert the BaseURL part of URL to the global variable we created for BaseURL. Use enviroment variables we created for API Key and Token.
- Give a name for new list.
- To determine which board to add the list to, copy the id of the board we created in the previous step and paste it into the value field opposite the idBoard parameter.
- Write test to check the response status code. Send the request. Response status code should be 200.
- Check the Trello.
- Open the Trello Rest API Documentation
- Copy the URL in the Trello Rest API Documentation
- Go to Postman. Create a new request and give a name (Create a new Card). The method type for this operation is POST method. Choose POST method. Paste the URL and Convert the BaseURL part of URL to the global variable we created for BaseURL. Use enviroment variables we created for API Key and Token.
- Paste "&name=" to end of the URL. This will create the name parameter.
- Give a name for new card.
- To determine which list to add the card to, copy the id of the list we created in the previous step and paste it into the value field opposite the idList parameter.
- Write test to check the response status code. Send the request. Response status code should be 200.
- Check the Trello.
- Open the Trello Rest API Documentation
- Copy the URL in the Trello Rest API Documentation
- Go to Postman. Create a new request and give a name (Create a Checklist). The method type for this operation is POST method. Choose POST method. Paste the URL and Convert the BaseURL part of URL to the global variable we created for BaseURL. Use enviroment variables we created for API Key and Token.
- Paste "&name=" to end of the URL. This will create the name parameter.
- Give a name for checklist.
- To determine which card to add the checklist to, copy the id of the card we created in the previous step and paste it into the value field opposite the idCard parameter.
- Write test to check the response status code. Send the request. Response status code should be 200.
- Check the Trello.
- Open the Trello Rest API Documentation
- Copy the URL in the Trello Rest API Documentation
- Go to Postman. Create a new request and give a name (Create a Label). The method type for this operation is POST. Choose POST method. Paste the URL and Convert the BaseURL part of URL to the global variable we created for BaseURL. Use enviroment variables we created for API Key and Token.
- Give a name for label and choose a color from among the valid colors. Valid values: yellow, purple, blue, red, green, orange, black, sky, pink, lime for color parameter.
- To determine which board to add the label to, copy the id of the board we created in the first step and paste it into the value field opposite the idBoard parameter.
- Write test to check the response status code. Send the request. Response status code should be 200.
- Check the Trello.
- Click the name of the collection. Then click the Runs button.
- Click the Run Project button.
- View the Result
- View the Summary
By storing values returned from the API—such as id or name—in a variable, we can reuse them in subsequent requests. This eliminates the need for manual copy-paste and allows Postman to automatically pass data from one response to the next request. As a result, dependent operations can be executed in a seamless, chained, and dynamic workflow.
- Saving the ID in the Post-request Script Firstly, In the Tests (Post-request Script) section, we extract the response body and store a specific value (such as an ID) in an environment variable: let response = pm.response.json(); pm.environment.set("idboard", response.id);
The idboard variable we set here will be automatically created and stored in the Environments section. This allows Postman to reuse it in other requests without any manual input.
- Using the idboard Variable in Create a List Request
Apply the same process we used in the previous step to save the list ID. After creating the list, extract the response and store the returned id value as an environment variable (e.g., idlist). This will allow us to reuse the list ID in the following requests just like we did with idboard.
You can apply these steps to all operations in the project. By saving each returned ID (board, list, card, checklist, label) as an environment variable, you can easily reuse them in subsequent requests and create fully connected, automated API workflows.
Using the Collection Runner, you can run the project multiple times in succession without errors. Since all IDs are dynamically stored and reused via environment variables, the requests remain fully connected and automated, allowing for seamless repeated execution.
Pre-request scripts are executed before sending an API request. They allow us to:
-
Set or update environment and global variables dynamically
-
Generate timestamps, tokens, or random data required for the request
-
Prepare any data or configuration needed for the request to run successfully
Essentially, they let us automate setup tasks so that each request has the correct data and context before execution.
- pm.environment.set("nameBoard", "udemy " + parseInt(Math.random()*1000)); in the Pre-request field for nameBoard
- Use this nameBoard variable in the request
- Write a Test and Check
let response = pm.response.json(); // we wrote this already pm.test("response name is equal to expected name", function () { pm.expect(response.name).is.eql(pm.environment.get("nameBoard")); console.log("response name: ", response.name); console.log("expected name: ", pm.environment.get("nameBoard"));
});