A Jira subtask is used to break down work into smaller units. These smaller units can be assigned to different people independently.
Subtasks can be converted into issues and issues can also be converted into subtasks. In this guide, we will focus on using python to create a Jira subtask.
Python can be used to automate the creation of subtasks which is what this blog is about, Automation!
We have covered the creation of a Jira ticket with Python, read more about it here. The created ticket will be our parent ticket to host our subtask tickets.
To create a subtask:
- We initialise a Jira connection object, read about it here.
- Initiliasie the parent issue using the method:
jira_connection.issue
- e.g
parent_issue = jira_connection.issue('PJH-1')
- e.g
- Collect some parent Jira ticket attributes:
Project Key
– e.g'PJH'
- Key of the parent issue – e.g
'PJH-1'
- Create our subtask with a summary, description and the parent attributes collected above.
- Note that the issue type of the subtask should be
Sub-task
- Note that the issue type of the subtask should be
Complete code snippet:
from jira import JIRA
jira_connection = JIRA(
basic_auth=('workspace_email', 'api_token'),
server="https://server_name.atlassian.net"
)
# initialize the parent issue
parent_issue = jira_connection.issue('PJH-1')
project_key = parent_issue.fields.project.key
parent_issue_key = parent_issue.key
# create the subtask
subtask = jira_connection.create_issue(
project=project_key,
summary='Sample Subtask Title',
description='Sample detailed subtask description',
issuetype={'name': 'Sub-task'},
parent={'key': parent_issue_key}
)
print(subtask)
Sample screenshot of created subtask:

Happy automating!