Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions docs/authentication/group-sync.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,40 @@ Manual roles are also never downgraded by syncing. If someone was manually made
- Adding a paid workspace role through sync respects your seat limits.
- **Sync errors never block sign-in.** If syncing fails, the user still logs in and the error is logged.

## Manage project mappings with the API

You can read and update project role mappings programmatically with the Plane API. Authenticate with an API token that has group-sync write access. Group syncing must be enabled for the workspace.

### Filter mappings by project

`GET /api/v1/workspaces/:slug/group-sync/project-mappings/` lists every project role mapping in the workspace. Pass the `project_identifier` query parameter to return only the mappings for one project:

```bash
curl "https://api.plane.so/api/v1/workspaces/my-workspace/group-sync/project-mappings/?project_identifier=ENG" \
-H "x-api-key: $PLANE_API_KEY"
```

The identifier is matched case-insensitively, so `eng` and `ENG` resolve to the same project. An identifier that matches no project returns an empty list.

### Update a mapping by project and group

You can update a mapping without knowing its internal ID by addressing it with the project identifier and the IdP group name:

```bash
curl -X PATCH "https://api.plane.so/api/v1/workspaces/my-workspace/group-sync/project-mappings/ENG/eng-team/" \
-H "x-api-key: $PLANE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"role": "admin"}'
Comment on lines +149 to +153

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Document URL encoding for path parameters.

Line 150 places idp_group_name directly in the URL path. IdP group names can contain spaces or reserved characters. URI path segments use / as separators, and reserved characters require percent-encoding. (rfc-editor.org)

Add encoding guidance and an example such as Platform%20Engineering.

Proposed documentation change
 curl -X PATCH "https://api.plane.so/api/v1/workspaces/my-workspace/group-sync/project-mappings/ENG/eng-team/" \
   -H "x-api-key: $PLANE_API_KEY" \
   -H "Content-Type: application/json" \
   -d '{"role": "admin"}'

+Percent-encode both path parameters. For example, use Platform%20Engineering for Platform Engineering.
+
A project can have one mapping per IdP group, so both the project identifier and the group name are needed to identify a single mapping.

</details>

<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/authentication/group-sync.md` around lines 149 - 153, Update the
group-sync PATCH example documentation to state that both path parameters must
be percent-encoded, and illustrate an encoded IdP group name such as
Platform%20Engineering. Preserve the explanation that both the project
identifier and group name identify the mapping.

```

A project can have one mapping per IdP group, so both the project identifier and the group name are needed to identify a single mapping. The fields you can update are `idp_group_name`, `project`, `all_projects`, and `role`.

Keep in mind:

- The project identifier is case-insensitive, but the IdP group name must match exactly, including case.
- If the project or the mapping doesn't exist, the request returns `404`.
- Updating any group mapping with an empty request body returns `400` with `{"error": "Request body cannot be empty."}` instead of silently returning the unchanged mapping.

## Common use cases

**New hire provisioning.** Map your `engineering` group to a Member role on all engineering projects (or use Apply to all projects). New engineers get access on their first sign-in with no admin action.
Expand Down
Loading