Update a work item's audiences
Attach the audiences in add to this work item and detach the ones in remove, then get back the result in the same shape as Get a work item's audiences. Audiences you don't name stay as they are, so you can attach or detach one without reading the list first.
This changes only the work item's own audiences, never its type's. A work item's own audiences override its type's: once it has an active audience of its own, the type's audiences stop applying to it. Detach all of its own audiences and it follows its type again.
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:requiredstring (uuid)The project the work item belongs to.
pk:requiredstringThe work item's UUID or its identifier, such as PROJ-157.
Body parameters
add:optionalarray of string (uuid)Audience ids to attach. Up to 100. Attaching an audience that is already attached changes nothing, and duplicate ids count once.
Every id must be an audience in this workspace. If one isn't, the request returns 400 and nothing is written. You can attach an inactive audience. It restricts nothing until it is turned on.
remove:optionalarray of string (uuid)Audience ids to detach. Up to 100. Detaching an audience that isn't attached, or an id that names no audience, changes nothing.
An id in both add and remove is a 400. A body with neither field, such as {}, changes nothing and returns the current audiences.
This works on archived work items without ?archived=.
Permissions
You need edit access to the work item.
Scopes
projects.work_items:write
Errors
| Status | Code | Cause |
|---|---|---|
400 | invalid_request | add or remove isn't an array of UUIDs, has more than 100 ids, or shares an id with the other. Or an id in add isn't an audience in this workspace. |
401 | unauthorized | Missing or invalid credentials. |
402 | payment_required | Work item security isn't on your plan, or is switched off. |
403 | forbidden | You can't edit the work item, or your token can't write. |
404 | not_found | No such work item, it's outside your project or tenant, you can't view it, or it's a draft, a triage work item, or in an archived project. |
405 | method_not_allowed | You sent PUT. Use PATCH. |
406 | not_acceptable | The Accept header asks for a representation the API can't produce. |
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 PATCH \
"https://api.plane.so/api/v2/workspaces/my-team/projects/4af68566-94a4-4eb3-94aa-50dc9427067b/work-items/47ed6fba-1a4d-4b19-8c67-28d835d2c2c7/audiences/" \
-H "X-Api-Key: $PLANE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"add": ["8bcf2c8f-7bd0-4d0c-bdc6-82df9fa1f312"]
}'import requests
response = requests.patch(
"https://api.plane.so/api/v2/workspaces/my-team/projects/4af68566-94a4-4eb3-94aa-50dc9427067b"
"/work-items/47ed6fba-1a4d-4b19-8c67-28d835d2c2c7/audiences/",
headers={"X-Api-Key": "your-api-key"},
json={"add": ["8bcf2c8f-7bd0-4d0c-bdc6-82df9fa1f312"]},
)
print(response.json())const response = await fetch(
"https://api.plane.so/api/v2/workspaces/my-team/projects/4af68566-94a4-4eb3-94aa-50dc9427067b" +
"/work-items/47ed6fba-1a4d-4b19-8c67-28d835d2c2c7/audiences/",
{
method: "PATCH",
headers: { "X-Api-Key": "your-api-key", "Content-Type": "application/json" },
body: JSON.stringify({
add: ["8bcf2c8f-7bd0-4d0c-bdc6-82df9fa1f312"],
}),
},
);
const data = await response.json();{
"source": "work_item",
"enforced_source": "work_item",
"audiences": [
{
"id": "8bcf2c8f-7bd0-4d0c-bdc6-82df9fa1f312",
"name": "Security response",
"logo_props": {},
"is_active": true
}
]
}{
"type": "invalid_request",
"code": "invalid_request",
"detail": "One or more fields failed validation.",
"errors": [
{
"field": "add",
"code": "invalid",
"message": "Audiences not found in this workspace: ['5b7e2f90-c3a1-4d6e-8f42-91d0a6c3e7b8']"
}
]
}What a PATCH changes
- The response is the work item's audiences after the change, with
sourceandenforced_sourcerecomputed. When you detach the work item's last audience of its own, the response switches to its type's audiences, or to[]withenforced_source: null. - Each audience the call attaches or detaches adds an
attachedordetachedentry to that audience's activity, and an "added audience" or "removed audience" entry to the work item's activity. These changes send no notifications. Ids that didn't change anything add nothing. - The change applies as one transaction. If any id in
addfails, nothing is attached or detached.
You can restrict a work item away from yourself
Edit access is enough to attach an audience, even one that doesn't admit you. Unless you are a workspace owner or admin, or an assignee or subscriber of the work item, attaching an active audience you aren't in hides the work item from you: the response still comes back, but later reads return 404. Check List an audience's effective users first.
Swap audiences in one call
Because add and remove apply together, you can replace one audience with another without a window where the work item falls back to its type:
{
"add": ["33d89ed2-712a-4fc0-93cf-91eedbba5ef1"],
"remove": ["8bcf2c8f-7bd0-4d0c-bdc6-82df9fa1f312"]
}
