| name | todoist-api-3-labels-management |
| description | Sub-skill of todoist-api: 3. Labels Management (+1). |
| version | 1.0.0 |
| category | business |
| type | reference |
| scripts_exempt | true |
3. Labels Management (+1)
3. Labels Management
REST API - Labels:
curl -s -X GET "https://api.todoist.com/rest/v2/labels" \
-H "Authorization: Bearer $TODOIST_API_KEY" | jq
curl -s -X POST "https://api.todoist.com/rest/v2/labels" \
-H "Authorization: Bearer $TODOIST_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "urgent",
"color": "red",
"order": 1,
"is_favorite": true
}' | jq
curl -s -X POST "https://api.todoist.com/rest/v2/labels/LABEL_ID" \
-H "Authorization: Bearer $TODOIST_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "high-priority",
"color": "orange"
}' | jq
curl -s -X DELETE "https://api.todoist.com/rest/v2/labels/LABEL_ID" \
-H "Authorization: Bearer $TODOIST_API_KEY"
Python SDK - Labels:
from todoist_api_python import TodoistAPI
api = TodoistAPI(os.environ["TODOIST_API_KEY"])
labels = api.get_labels()
for label in labels:
print(f"@{label.name} (color: {label.color})")
new_label = api.add_label(
name="review",
color="blue",
order=1,
is_favorite=True
)
api.update_label(
label_id=new_label.id,
name="code-review",
color="green"
)
api.delete_label(label_id=new_label.id)
review_tasks = api.get_tasks(filter="@code-review")
4. Sections Management
REST API - Sections:
curl -s -X GET "https://api.todoist.com/rest/v2/sections?project_id=PROJECT_ID" \
-H "Authorization: Bearer $TODOIST_API_KEY" | jq
curl -s -X POST "https://api.todoist.com/rest/v2/sections" \
-H "Authorization: Bearer $TODOIST_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "In Progress",
"project_id": "PROJECT_ID",
"order": 2
}' | jq
curl -s -X POST "https://api.todoist.com/rest/v2/sections/SECTION_ID" \
-H "Authorization: Bearer $TODOIST_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Currently Working"
}' | jq
curl -s -X DELETE "https://api.todoist.com/rest/v2/sections/SECTION_ID" \
-H "Authorization: Bearer $TODOIST_API_KEY"
Python SDK - Sections:
sections = ["Backlog", "To Do", "In Progress", "Review", "Done"]
for i, section_name in enumerate(sections):
api.add_section(
name=section_name,
project_id="2345678901",
order=i
)
sections = api.get_sections(project_id="2345678901")
for section in sections:
print(f"Section: {section.name} (ID: {section.id})")
api.update_task(
task_id="1234567890",
section_id="IN_PROGRESS_SECTION_ID"
)