---
title: "Set Gitlab Username"
method: PUT
path: "/api/system/gitlab/principal-mapping"
tags: ["system"]
---

# Set Gitlab Username

`PUT /api/system/gitlab/principal-mapping`

## Request

- Base URL: `https://api.pigeonly.com` (the document declares no server; this is the origin it was published from)
- URL: `https://api.pigeonly.com/api/system/gitlab/principal-mapping`
- Auth: none declared

The one-time step for mapping the NEXT GitLab username (F10): a
person with `system:credentials:write` picks the Roost principal and
types the `gitlab.com` username GitLab itself shows as that person's
assignee -- never guessed, never inferred from a name.

Refuses (422) a principal that is not `kind = 'human'` or is
`removed_at IS NOT NULL` -- `app.modules.issues.gitlab_watch` would
never resolve either kind of row anyway (`_mapped_principals`,
`_resolve_assignees` both filter on exactly this), so accepting the
write and having it silently do nothing is worse than refusing it here
with a reason. Refuses (409) a username already mapped to a DIFFERENT
principal -- `principals_gitlab_username_unique_idx` (migration 0642)
is the floor under this; this route's own read-before-write check is
what turns that floor into a message a person can act on instead of a
bare `UniqueViolationError`.

## Request body

- SetGitLabUsernameRequest: Map a Roost principal to their GitLab username -- the operator path Frederick's standing rule 4 requires (F10, Fable review of #2196, 2026-09-25): before this route, `principals.gitlab_username` was written only by migration 0642's two literal `UPDATE`s (Marc, Jonathan), and mapping a THIRD person meant a hand `UPDATE` on production, which house rule makes a `tools/repairs/` data repair, not something a person types. This is the route; `docs/runbooks/ GITLAB_WEBHOOK_REGISTRATION.md`'s own sibling doc names the exact steps for using it.
  - `principal_id` string, uuid, required
  - `gitlab_username` string, required

## Response `200`

Successful Response

- object

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/pigeonly/apis/roost-v2-pigeonly-company-os.md) - [All operations](https://skmtc.dev/pigeonly/apis/roost-v2-pigeonly-company-os/llms.txt) - [OpenAPI document](https://skmtc.dev/pigeonly/apis/roost-v2-pigeonly-company-os/revisions/14571c4b7007?raw)
