Home/Atlassian REST API reference
Jira and Confluence Cloud REST API
Jira work item links with the REST API
POST /rest/api/3/issueLink links two work items by key and link type name and answers 201 with an empty body; the new id is in the Location header and in the issuelinks field. The same link is shown as inwardIssue on one work item and outwardIssue on the other.
Endpoints
| Method | Path | What it does |
|---|---|---|
GET | /rest/api/3/issueLinkType | Lists the link types and their inward and outward wording. |
POST | /rest/api/3/issueLink | Creates a link between two work items. |
GET | /rest/api/3/issueLink/{linkId} | Returns one link. |
DELETE | /rest/api/3/issueLink/{linkId} | Deletes a link. |
Examples
GET /rest/api/3/issueLinkType
List the link types. Each has a name plus inward and outward phrases.
curl
curl \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
'https://your-domain.atlassian.net/rest/api/3/issueLinkType'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.get(
'https://your-domain.atlassian.net/rest/api/3/issueLinkType',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
)
print(r.status_code, r.text)Response: HTTP 200
{
"issueLinkTypes": [
{
"id": "10000",
"name": "Blocks",
"inward": "is blocked by",
"outward": "blocks",
"self": "https://your-domain.atlassian.net/rest/api/3/issueLinkType/10000"
},
{
"id": "10001",
"name": "Cloners",
"inward": "is cloned by",
"outward": "clones",
"self": "https://your-domain.atlassian.net/rest/api/3/issueLinkType/10001"
},
{
"id": "10002",
"name": "Duplicate",
"inward": "is duplicated by",
"outward": "duplicates",
"self": "https://your-domain.atlassian.net/rest/api/3/issueLinkType/10002"
},
{
"id": "10003",
"name": "Relates",
"inward": "relates to",
"outward": "relates to",
"self": "https://your-domain.atlassian.net/rest/api/3/issueLinkType/10003"
}
]
}Sent to Atlassian Cloud on .
POST /rest/api/3/issueLink
Link two work items with the Relates type. The 201 has no body.
curl
curl -X POST \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data '{
"type": {
"name": "Relates"
},
"inwardIssue": {
"key": "{issueIdOrKey}"
},
"outwardIssue": {
"key": "{otherIssueKey}"
}
}' \
'https://your-domain.atlassian.net/rest/api/3/issueLink'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.post(
'https://your-domain.atlassian.net/rest/api/3/issueLink',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
json={'type': {'name': 'Relates'},
'inwardIssue': {'key': '{issueIdOrKey}'},
'outwardIssue': {'key': '{otherIssueKey}'}},
)
print(r.status_code, r.text)Response: HTTP 201
No response body.
Response headers
Location: https://your-domain.atlassian.net/rest/api/3/issueLink/10106
X-Ratelimit-Limit: 200Sent to Atlassian Cloud on .
GET /rest/api/3/issue/{issueIdOrKey}
Read the link back through the issuelinks field of the work item.
curl
curl -G \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
--data-urlencode 'fields=issuelinks' \
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.get(
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
params={'fields': 'issuelinks'},
)
print(r.status_code, r.text)Response: HTTP 200
{
"key": "WEB-55",
"fields": {
"issuelinks": [
{
"id": "10106",
"type": {
"name": "Relates"
},
"outwardIssue": {
"key": "WEB-56",
"fields": {
"summary": "REST API reference test issue2 - delete"
}
}
}
]
}
}Sent to Atlassian Cloud on .
GET /rest/api/3/issueLink/{linkId}
Read the link by id. This view holds both ends.
curl
curl \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
'https://your-domain.atlassian.net/rest/api/3/issueLink/{linkId}'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.get(
'https://your-domain.atlassian.net/rest/api/3/issueLink/{linkId}',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
)
print(r.status_code, r.text)Response: HTTP 200
{
"id": "10106",
"type": {
"name": "Relates"
},
"inwardIssue": {
"key": "WEB-55"
},
"outwardIssue": {
"key": "WEB-56"
}
}Sent to Atlassian Cloud on .
DELETE /rest/api/3/issueLink/{linkId}
Delete the link by id. The answer is 204.
curl
curl -X DELETE \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
'https://your-domain.atlassian.net/rest/api/3/issueLink/{linkId}'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.delete(
'https://your-domain.atlassian.net/rest/api/3/issueLink/{linkId}',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
)
print(r.status_code, r.text)Response: HTTP 204
No response body.
Sent to Atlassian Cloud on .
How it behaves
- The create call answered 201 with no body. The link id came in the Location header and in the work item's issuelinks.
- The request named inwardIssue as the first work item and outwardIssue as the second. On the first work item the link appeared as an outwardIssue entry pointing at the second one.
- Reading the link by id showed inwardIssue for the first work item and outwardIssue for the second, matching the request.
- The Relates type uses the same text, 'relates to', for inward and outward.
Pitfalls
- The spec says the response does not return the link id. Read it from the Location header or from the issuelinks field.
- On a directional type such as Blocks the roles matter. Check the inward and outward wording in the type list before choosing which key goes where.
- A duplicate link request still answers as created, per the spec, so check issuelinks before creating when you need uniqueness.
- Links need issue linking enabled on the site; the spec says 404 otherwise.
Questions and answers
Where do I get the id of a link I just created?
From the Location header, or from the issuelinks array of either work item.
Can I add a comment while linking?
The spec says an optional comment can be included and is added to the outward work item.