Trello API: Automating Task Creation

This guide provides a step-by-step process for automating task creation in Trello using the API. Learn how to obtain necessary credentials, retrieve a list ID, and create a new task programmatically.

Step 1: Obtain Your API Key

Retrieve your API Key from the Trello API settings page. Make sure to add https://www.postman.com to the Allowed Origins field for API access.

Example API Key Screenshot

Step 2: Generate a Token

Click Generate Token on the API Key page and copy the generated token for authentication.

Generate Token Screenshot

Step 3: Retrieve the List ID

Use the following GET request to retrieve the List ID where tasks will be created:


GET https://api.trello.com/1/boards/{boardID}/lists?key=YOUR_API_KEY&token=YOUR_ACCESS_TOKEN
        
Retrieve List ID Screenshot

Step 4: Create a Task Using a POST Request

Use the following request to create a task in Trello:


POST https://api.trello.com/1/cards
Content-Type: application/json

{
  "name": "Automated Task Example",
  "desc": "Task created via API automation.",
  "idList": "{LIST_ID}",
  "pos": "top",
  "due": "2024-12-10T09:00:00.000Z",
  "key": "YOUR_API_KEY",
  "token": "YOUR_ACCESS_TOKEN"
}
        
Create Task with POST Request

Expected Outcome

A new task titled "Automated Task Example" will be created in the specified Trello list.

Task Created Screenshot

Common Errors & Troubleshooting

Error Code Possible Cause Solution
401 Unauthorized Invalid API Key or Token Verify that the API Key and Token are correct.
400 Bad Request Missing required parameters Ensure all required fields (e.g., idList, name) are provided.
404 Not Found Invalid List ID Double-check that the List ID exists and is accessible.