Create a work item relation
Relate the work item in the path to one or more other work items through a relation definition. One call creates one relation per id in work_item_ids, all with the same definition and direction.
direction decides which side the path work item is on. The path work item lists the related work items under the label you send, and each of them lists the path work item under the definition's other label. Sending tests on ENG-42 for ENG-17 means "ENG-42 tests ENG-17", so ENG-17 shows ENG-42 under tested by.
The response is 201 with the path work item's whole relations map after the write, not only the new relations. A relation that already exists, with the same definition and direction, is skipped without an error.
The call is all or nothing on lookups: if the definition or any related work item isn't found, it returns 404 and creates no relations. Every 404 has the same detail, so check the definition id, the direction, and each id in work_item_ids when you get one.
You need edit access to the path work item. Project admins, contributors, and workspace owners and admins have it. The related work items only need to be visible to you, and they can be in any project in the workspace.
Path parameters
slug:requiredstringThe workspace slug. It appears in your Plane URLs. In https://app.plane.so/my-team/projects/, the slug is my-team.
project_id:requiredstringThe project the resource belongs to. Accepts the project UUID or its bare identifier, for example ENG.
work_item_id:requiredstringThe work item the resource belongs to. Accepts the work item UUID or its PROJ-123 identifier.
Body parameters
relation_definition_id:requiredstring (uuid)The id of the relation definition to use. Get it from List work item relation definitions. An unknown or inactive definition returns 404.
direction:requiredstringOne of the definition's two labels, its outward or its inward, for example tests or tested by. The path work item lists the related work items under this label. The match is exact and case-sensitive. A value that matches neither label returns 404.
work_item_ids:requiredarray of string (uuid)The work items to relate, from 1 to 100 UUIDs. PROJ-123 identifiers aren't accepted here. A repeated id counts once.
Every id must be a work item in the workspace that you can see. Archived, draft, and intake work items count as missing. One missing id fails the whole call with 404.
Scopes
projects.work_items.relations:write
Errors
| Status | Code | Cause |
|---|---|---|
400 | invalid_request | relation_definition_id, direction, or work_item_ids is missing, work_item_ids is empty or has more than 100 ids, or an id isn't a UUID. See errors[]. |
401 | unauthorized | Missing or invalid credentials. |
403 | forbidden | You can't edit this work item, or your token scope doesn't allow this. |
404 | not_found | No such workspace, project, or work item, you can't see the work item, or it's archived. |
404 | not_found | An id in work_item_ids isn't a work item you can see. Nothing is created. |
404 | not_found | No active definition has this relation_definition_id with direction as one of its labels. Nothing is created. |
406 | not_acceptable | The Accept header asks for a representation the API can't produce. |
409 | governance_migration_in_progress | A governance migration is running in this workspace, so writes are paused. Retry after it finishes. |
413 | payload_too_large | The request body is over the size limit. |
415 | unsupported_media_type | The Content-Type isn't one this endpoint accepts. |
429 | rate_limited | Throttled. Honor the Retry-After header before retrying. |
curl -X POST \
"https://api.plane.so/api/v2/workspaces/my-team/projects/4af68566-94a4-4eb3-94aa-50dc9427067b/work-items/8c3d1f72-4a9e-4b65-9d20-6e1f3b7a5c48/relations/" \
-H "X-Api-Key: $PLANE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"relation_definition_id": "7a4c9e12-5f3b-4d68-8e01-2b6d9f4a3c85",
"direction": "tests",
"work_item_ids": [
"9c1f0b3d-6d2e-4c9a-8b41-2f7e5a0d6c88",
"3d8f5a62-7b1e-4c94-a0d3-9e6c2f8b1a57"
]
}'import requests
response = requests.post(
"https://api.plane.so/api/v2/workspaces/my-team/projects/4af68566-94a4-4eb3-94aa-50dc9427067b/work-items/8c3d1f72-4a9e-4b65-9d20-6e1f3b7a5c48/relations/",
headers={"X-Api-Key": "your-api-key"},
json={
"relation_definition_id": "7a4c9e12-5f3b-4d68-8e01-2b6d9f4a3c85",
"direction": "tests",
"work_item_ids": [
"9c1f0b3d-6d2e-4c9a-8b41-2f7e5a0d6c88",
"3d8f5a62-7b1e-4c94-a0d3-9e6c2f8b1a57",
],
},
)
print(response.json())const response = await fetch(
"https://api.plane.so/api/v2/workspaces/my-team/projects/4af68566-94a4-4eb3-94aa-50dc9427067b/work-items/8c3d1f72-4a9e-4b65-9d20-6e1f3b7a5c48/relations/",
{
method: "POST",
headers: {
"X-Api-Key": "your-api-key",
"Content-Type": "application/json",
},
body: JSON.stringify({
relation_definition_id: "7a4c9e12-5f3b-4d68-8e01-2b6d9f4a3c85",
direction: "tests",
work_item_ids: [
"9c1f0b3d-6d2e-4c9a-8b41-2f7e5a0d6c88",
"3d8f5a62-7b1e-4c94-a0d3-9e6c2f8b1a57",
],
}),
},
);
const data = await response.json();{
"relates to": ["f3b8a1c6-2d7e-4a95-8c14-5e9d0b3f7a28"],
"duplicate": [],
"implements": [],
"implemented by": ["6e2a9d47-1c5b-4f83-a7d0-3b8e4f1c9a62"],
"tests": ["9c1f0b3d-6d2e-4c9a-8b41-2f7e5a0d6c88", "3d8f5a62-7b1e-4c94-a0d3-9e6c2f8b1a57"],
"tested by": []
}
