Basics of API in Jira, Confluence, and Bitbucket

Pramodh Kumar M
2 min readMar 4, 2023

--

How many times have you thought in your mind about the tasks that were given to you or the tasks that you would do via User Interface in your company and whether they can be achieved via API/Automation?
Here’s an article that will get you started on the basics of the API journey in Atlassian products.

We will look at creating basic elements in Jira, Confluence, and Bitbucket

Let me start with Jira, it’s the issue
To create an issue

curl --request POST \
--url 'https://your-site.atlassian.net/rest/api/3/issue' \
--user 'your-email:api-token' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"fields" : {"summary" : "Issue Summary - Test",
"issuetype" : {"id" : "10000"},
"project" : {"id" : "10000"},
"assignee" : {"id" : "5d36b583beedf60c26aa372d"} } }'

Where to get the details like token, issue type ID, project ID, and assignee ID?

The token can be generated here
https://id.atlassian.com/manage-profile/security/api-tokens

Here’s the link that will help you in getting Project ID
https://confluence.atlassian.com/jirakb/how-to-get-project-id-from-the-jira-user-interface-827341414.html

With API, to get project ID it goes like this

curl --request GET \
--url 'https://your-domain.atlassian.net/rest/api/3/project/{projectKey}' \
--user 'your-email:api-token' \
--header 'Accept: application/json'
https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-projects/#api-rest-api-3-project-projectidorkey-get

Issue ID

curl --request GET \
--url 'https://your-domain.atlassian.net/rest/api/3/issuetype' \
--user 'your-email:api-token' \
--header 'Accept: application/json'

Get the Account ID of Users

curl --request GET \
--url 'https://your-domain.atlassian.com/rest/api/3/user/bulk/migration' \
--user 'your-email:api-token' \
--header 'Accept: application/json'

Now that you have all the fields to create an issue, fill in the values and create an issue!

Explore more and master yourself in API!
The link to API documentation is here
https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro

How to create Confluence pages using API?
To create an empty page

curl --request POST \
--url 'https://your-domain.atlassian.net/wiki/rest/api/content' \
--user 'your-email:api-token' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"title": "Page title", "type": "page", "space": {"key": "spaceKey"}, "status": "current"}'

Here’s how you would add the data in the API

curl --request POST \
--url 'https://your-domain.atlassian.net/wiki/rest/api/content' \
--user 'your-email:api-token' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"title": "Page title", "type": "page", "space": {"key": "spaceKey"}, "status": "current", "body":{"storage":{"value":"<p>This is a new page</p>", "representation":"storage" }}}'

The confluence REST API documentation is here
https://developer.atlassian.com/cloud/confluence/rest/intro

Now let’s go with Bitbucket
Creating a Private Repository

curl -X POST \
--url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo-name}' \
--user 'bitbucket-username:app-password' \
--header "Content-Type: application/json" \
--data '{"scm": "git", "project": {"key": "projectKey"}, "is_private": true }'

The Bitbucket API Documentation is here
https://developer.atlassian.com/bitbucket/api/2/reference

I hope you find this article gets the motivation to start with API in your instance. Please share your thoughts in the comments.

Thanks,
Pramodh

--

--

No responses yet