Skip to content
GitmoapAPIBeta
Organizeaccess
POST/repositories/{repo_id}/access/grants

Give one role to people, service accounts or teams on a repository.

create_repo_access_grants
  • access:manage
    A token needs the access:manage scope: Give, change and revoke access to groups and repositoriesGranted by write_api.Every operation this scope unlocks
  • Audited · mutation

    x-gitmoap-audit: {"kind":"audited","arg":"mutation"}

  • Quota · members per scope

    x-gitmoap-quota: {"kind":"enforced","arg":"members_per_scope"}

  • Dry run
    Takes dry_run.

Names up to 50 subjects, with an optional expiry (in the future, at most a year away) and reason. Callers who can manage access here may call it (Maintainers and above with the built-in roles), and nobody can give a role carrying a permission or rank they do not hold themselves. A subject that already holds the same role is reported as unchanged; one holding a different role is refused. A service account can be given access only at its own group or repository or beneath it, and never as Owner. With dry_run=true the answer says who would gain what, and nothing changes.

Parameters

Path
  • repo_idRepositoryId (string · uuid)Repository ID
Query
  • dry_runbooleanoptionalSay who would gain what, and change nothing

Request body

application/json
  • subjectsarray of SubjectRefWho receives the role — at most 50 subjects in one request.
  • expires_atstring · date-time or nulloptionalWhen the access ends. Omit it for access that lasts until it is revoked.
  • reasonGrantReason (string) or nulloptionalWhy the access is given, shown beside the grant and kept in the audit log.
Request body exampleSynthesized example
{
"role": {
"builtin": "guest"
},
"subjects": [
{
"principal": "72e2558b-bc89-4cb4-bc66-531dc71dbdcd"
}
]
}

Responses

200A preview: who would gain what. Nothing was changedapplication/json
  • grantsarray of AccessGrantThe grants made. Empty for a preview.
    • The AccessGrant schema
    • created_atstring · date-time
    • grant_idGrantId (string · uuid)
    • roleRoleView
      • The RoleView schema
      • namestringThe role's display name: a built-in name such as Developer, or the custom role's name.
      • rankAccessLevelguestreporterdevelopermaintainerownerThe built-in rank the role counts as wherever a rank is compared, such as a protected branch's minimum.
      • builtinAccessLevelguestreporterdevelopermaintainerowneror nulloptionalSet when the role is built in.
      • customRoleId (string · uuid) or nulloptionalSet when the role is one the organization defined.
    • scopeAccessScopeWhere the grant was made.
    • updated_atstring · date-time
    • expires_atstring · date-time or nulloptional
    • granted_byActorSummary or nulloptionalWho made the grant. Absent for access the platform created — the creator of a group or repository, or a copied membership.
    • last_exercised_atstring · date-time or nulloptionalWhen the grant last let somebody do something, to the day. Absent until it has.
    • reasonstring or nulloptional
  • unchangedarray of UnchangedGrantSubjects that already held the role here and were left as they were.
    • The UnchangedGrant schema
    • grant_idGrantId (string · uuid)
    • reasonUnchangedReasonalready_granted_same_roleWhy a subject named in a create request was left as it was.
    • subjectSubjectRef
  • previewAccessPreview or nulloptionalPresent only for a preview: who would gain what. Nothing was written.
    • The AccessPreview schema
    • changesarray of AccessDeltaEach person whose access would change at the group or repository the change is made on.
      • The AccessDelta schema
      • gainsarray of stringPermissions they would hold that they do not hold now, by key.
      • lossesarray of stringPermissions they hold now that they would no longer hold, by key.
      • rank_afterAccessLevelguestreporterdevelopermaintainerowneror nulloptional
      • rank_beforeAccessLevelguestreporterdevelopermaintainerowneror nulloptional
    • summaryAccessPreviewSummary
      • The AccessPreviewSummary schema
      • people_gaininginteger · int320–∞
      • people_losinginteger · int320–∞
      • scopes_affectedinteger · int64The group or repository the change is made on, plus every one beneath it that inherits access and so changes with it.
    • truncatedbooleanWhether changes stops short of everyone affected. The summary still counts them all.
200 exampleSynthesized example
{
"grants": [
{
"created_at": "2026-10-11T04:21:58Z",
"grant_id": "8a18938d-0e2c-4a78-9153-c685d39a70a9",
"role": {
"name": "payments-api",
"rank": "guest"
},
"scope": {
"full_path": "acme/payments-api",
"id": "id-40c5",
"type": "group"
},
"subject": {
"principal": {
"id": "1e4a93a3-ce2b-4a6b-a6c9-c42cb53a427b",
"kind": "user",
"username": "lin"
}
},
"updated_at": "2026-10-14T19:12:15Z"
}
],
"unchanged": [
{
"grant_id": "bffcd9c1-6717-4012-9c10-8d3bd7cca964",
"reason": "already_granted_same_role",
"subject": {
"principal": "3c7b8fd1-33c8-41b1-8b93-ab671beb5dd1"
}
},
{
"grant_id": "204483c0-692f-4f75-b3f0-46e6cf89b129",
"reason": "already_granted_same_role",
"subject": {
"principal": "946f6411-de36-4435-883b-55899e0496cb"
}
}
],
"preview": {
"changes": [
{
"gains": [],
"losses": [],
"principal": {
"id": "a58f31a2-0857-45fb-b19d-40642b3c39cf",
"kind": "user",
"username": "mara"
},
"scope": {
"full_path": "acme/payments-api",
"id": "id-6802",
"type": "group"
}
}
],
"summary": {
"people_gaining": 13,
"people_losing": 89,
"scopes_affected": 46
},
"truncated": false
}
}
201Access givenapplication/json
  • grantsarray of AccessGrantThe grants made. Empty for a preview.
    • The AccessGrant schema
    • created_atstring · date-time
    • grant_idGrantId (string · uuid)
    • roleRoleView
      • The RoleView schema
      • namestringThe role's display name: a built-in name such as Developer, or the custom role's name.
      • rankAccessLevelguestreporterdevelopermaintainerownerThe built-in rank the role counts as wherever a rank is compared, such as a protected branch's minimum.
      • builtinAccessLevelguestreporterdevelopermaintainerowneror nulloptionalSet when the role is built in.
      • customRoleId (string · uuid) or nulloptionalSet when the role is one the organization defined.
    • scopeAccessScopeWhere the grant was made.
    • updated_atstring · date-time
    • expires_atstring · date-time or nulloptional
    • granted_byActorSummary or nulloptionalWho made the grant. Absent for access the platform created — the creator of a group or repository, or a copied membership.
    • last_exercised_atstring · date-time or nulloptionalWhen the grant last let somebody do something, to the day. Absent until it has.
    • reasonstring or nulloptional
  • unchangedarray of UnchangedGrantSubjects that already held the role here and were left as they were.
    • The UnchangedGrant schema
    • grant_idGrantId (string · uuid)
    • reasonUnchangedReasonalready_granted_same_roleWhy a subject named in a create request was left as it was.
    • subjectSubjectRef
  • previewAccessPreview or nulloptionalPresent only for a preview: who would gain what. Nothing was written.
    • The AccessPreview schema
    • changesarray of AccessDeltaEach person whose access would change at the group or repository the change is made on.
      • The AccessDelta schema
      • gainsarray of stringPermissions they would hold that they do not hold now, by key.
      • lossesarray of stringPermissions they hold now that they would no longer hold, by key.
      • rank_afterAccessLevelguestreporterdevelopermaintainerowneror nulloptional
      • rank_beforeAccessLevelguestreporterdevelopermaintainerowneror nulloptional
    • summaryAccessPreviewSummary
      • The AccessPreviewSummary schema
      • people_gaininginteger · int320–∞
      • people_losinginteger · int320–∞
      • scopes_affectedinteger · int64The group or repository the change is made on, plus every one beneath it that inherits access and so changes with it.
    • truncatedbooleanWhether changes stops short of everyone affected. The summary still counts them all.
201 exampleSynthesized example
{
"grants": [
{
"created_at": "2026-10-10T23:33:31Z",
"grant_id": "6e43e752-f8f6-4694-a5e0-29a86a52fd23",
"role": {
"name": "payments-api",
"rank": "guest"
},
"scope": {
"full_path": "acme/payments-api",
"id": "id-d5cd",
"type": "group"
},
"subject": {
"principal": {
"id": "bc771f9c-bbed-40f4-a71d-d2eb200c0241",
"kind": "user",
"username": "tomas"
}
},
"updated_at": "2026-10-09T02:54:23Z"
},
{
"created_at": "2026-10-11T16:37:53Z",
"grant_id": "fa1f1ef7-9b3f-4ac5-ac8a-07bde733c0f1",
"role": {
"name": "payments-api",
"rank": "guest"
},
"scope": {
"full_path": "acme/payments-api",
"id": "id-c46f",
"type": "group"
},
"subject": {
"principal": {
"id": "bc2ad539-e88f-47ea-809b-a5b1d1bf0e90",
"kind": "user",
"username": "tomas"
}
},
"updated_at": "2026-10-15T02:19:48Z"
}
],
"unchanged": [
{
"grant_id": "5f48d7c2-4c0d-4fcf-8472-aeaa4e1cc53c",
"reason": "already_granted_same_role",
"subject": {
"principal": "f3340db6-bf9d-4acd-ac09-f037edcb30bb"
}
},
{
"grant_id": "8c5fade0-1490-456c-bb79-f4f1d040b11e",
"reason": "already_granted_same_role",
"subject": {
"principal": "e291c0a0-74c2-46fa-bd58-5644d7f6958c"
}
}
],
"preview": {
"changes": [
{
"gains": [],
"losses": [],
"principal": {
"id": "9ba2b838-9095-4830-a93d-471f03833044",
"kind": "user",
"username": "lin"
},
"scope": {
"full_path": "acme/payments-api",
"id": "id-4414",
"type": "group"
}
},
{
"gains": [],
"losses": [],
"principal": {
"id": "a26138f9-2e94-434a-a559-4309c51174cc",
"kind": "user",
"username": "lin"
},
"scope": {
"full_path": "acme/payments-api",
"id": "id-862e",
"type": "group"
}
}
],
"summary": {
"people_gaining": 13,
"people_losing": 47,
"scopes_affected": 20
},
"truncated": false
}
}
400Invalid requestapplication/json
Error codes
  • BAD_REQUESTThe request is malformed: a parameter or a body field is not a well-formed value of its type
  • errorErrorBody
    • The ErrorBody schema
    • codestringThe coarse category, tied to the status: NOT_FOUND, CONFLICT, INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all.
    • messagestringWhat went wrong, for a person. Written to be read, not parsed: match on reason or code.
    • fieldstring or nulloptionalOn a 400 that refused one field's value, the field, as its JSON path: email, items[0].name. Put the message under that input. Absent on every other error.
    • reasonstring or nulloptionalThe specific code, when the error has one: LAST_ORGANIZATION_OWNER, BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and on code otherwise.
    • required_scopestring or nulloptionalThe scope the access token was missing, on INSUFFICIENT_SCOPE.
    • violationsanyoptionalPresent on the structured-validation errors (PROVIDER_VALIDATION_FAILED per-node, PIPELINE_VALIDATION_FAILED DAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
400 exampleSynthesized example
{
"error": {
"code": "code-5135",
"message": "Label every synthesized example"
}
}
401Authentication requiredapplication/json
Error codes
  • UNAUTHORIZEDNo credential was sent, or the one sent is invalid, expired or revoked
  • errorErrorBody
    • The ErrorBody schema
    • codestringThe coarse category, tied to the status: NOT_FOUND, CONFLICT, INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all.
    • messagestringWhat went wrong, for a person. Written to be read, not parsed: match on reason or code.
    • fieldstring or nulloptionalOn a 400 that refused one field's value, the field, as its JSON path: email, items[0].name. Put the message under that input. Absent on every other error.
    • reasonstring or nulloptionalThe specific code, when the error has one: LAST_ORGANIZATION_OWNER, BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and on code otherwise.
    • required_scopestring or nulloptionalThe scope the access token was missing, on INSUFFICIENT_SCOPE.
    • violationsanyoptionalPresent on the structured-validation errors (PROVIDER_VALIDATION_FAILED per-node, PIPELINE_VALIDATION_FAILED DAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
401 exampleSynthesized example
{
"error": {
"code": "code-3ea5",
"message": "Inline scalar newtypes but keep their brand"
}
}
403The caller cannot give this role hereapplication/json
Error codes
  • FORBIDDENYou are signed in but may not do this here; reason names the permission or the rule that refused it
  • INSUFFICIENT_SCOPEThe access token lacks the scope this operation needs; required_scope names it
  • PERMISSION_REQUIREDYou need a permission you do not hold here; the message names it
  • errorErrorBody
    • The ErrorBody schema
    • codestringThe coarse category, tied to the status: NOT_FOUND, CONFLICT, INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all.
    • messagestringWhat went wrong, for a person. Written to be read, not parsed: match on reason or code.
    • fieldstring or nulloptionalOn a 400 that refused one field's value, the field, as its JSON path: email, items[0].name. Put the message under that input. Absent on every other error.
    • reasonstring or nulloptionalThe specific code, when the error has one: LAST_ORGANIZATION_OWNER, BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and on code otherwise.
    • required_scopestring or nulloptionalThe scope the access token was missing, on INSUFFICIENT_SCOPE.
    • violationsanyoptionalPresent on the structured-validation errors (PROVIDER_VALIDATION_FAILED per-node, PIPELINE_VALIDATION_FAILED DAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
403 exampleSynthesized example
{
"error": {
"code": "code-2667",
"message": "Stream pipeline status into the run header"
}
}
404Repository, role or subject not foundapplication/json
Error codes
  • NOT_FOUNDThe resource does not exist — or exists and you cannot see it: a private resource you have no access to answers exactly as an absent one does
  • errorErrorBody
    • The ErrorBody schema
    • codestringThe coarse category, tied to the status: NOT_FOUND, CONFLICT, INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all.
    • messagestringWhat went wrong, for a person. Written to be read, not parsed: match on reason or code.
    • fieldstring or nulloptionalOn a 400 that refused one field's value, the field, as its JSON path: email, items[0].name. Put the message under that input. Absent on every other error.
    • reasonstring or nulloptionalThe specific code, when the error has one: LAST_ORGANIZATION_OWNER, BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and on code otherwise.
    • required_scopestring or nulloptionalThe scope the access token was missing, on INSUFFICIENT_SCOPE.
    • violationsanyoptionalPresent on the structured-validation errors (PROVIDER_VALIDATION_FAILED per-node, PIPELINE_VALIDATION_FAILED DAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
404 exampleSynthesized example
{
"error": {
"code": "code-f940",
"message": "Stream pipeline status into the run header"
}
}
409A subject already holds a different role hereapplication/json
Error codes
  • CONFLICTThe request conflicts with the resource's current state; reason says how
  • LEGAL_ACCEPTANCE_REQUIREDAccept the current Terms of Service before changing anything; reading stays open
  • errorErrorBody
    • The ErrorBody schema
    • codestringThe coarse category, tied to the status: NOT_FOUND, CONFLICT, INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all.
    • messagestringWhat went wrong, for a person. Written to be read, not parsed: match on reason or code.
    • fieldstring or nulloptionalOn a 400 that refused one field's value, the field, as its JSON path: email, items[0].name. Put the message under that input. Absent on every other error.
    • reasonstring or nulloptionalThe specific code, when the error has one: LAST_ORGANIZATION_OWNER, BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and on code otherwise.
    • required_scopestring or nulloptionalThe scope the access token was missing, on INSUFFICIENT_SCOPE.
    • violationsanyoptionalPresent on the structured-validation errors (PROVIDER_VALIDATION_FAILED per-node, PIPELINE_VALIDATION_FAILED DAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
409 exampleSynthesized example
{
"error": {
"code": "code-f022",
"message": "Draw the region map from operation density"
}
}
422A service account cannot hold this role hereapplication/json
Error codes
  • UNPROCESSABLE_ENTITYThe request is well-formed but asks for something the resource's rules do not allow; reason says which
  • errorErrorBody
    • The ErrorBody schema
    • codestringThe coarse category, tied to the status: NOT_FOUND, CONFLICT, INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all.
    • messagestringWhat went wrong, for a person. Written to be read, not parsed: match on reason or code.
    • fieldstring or nulloptionalOn a 400 that refused one field's value, the field, as its JSON path: email, items[0].name. Put the message under that input. Absent on every other error.
    • reasonstring or nulloptionalThe specific code, when the error has one: LAST_ORGANIZATION_OWNER, BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and on code otherwise.
    • required_scopestring or nulloptionalThe scope the access token was missing, on INSUFFICIENT_SCOPE.
    • violationsanyoptionalPresent on the structured-validation errors (PROVIDER_VALIDATION_FAILED per-node, PIPELINE_VALIDATION_FAILED DAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
422 exampleSynthesized example
{
"error": {
"code": "code-1853",
"message": "Draw the region map from operation density"
}
}
429Access limit reached for this repositoryapplication/json
Error codes
  • TOO_MANY_REQUESTSRetryableA quota, a rate limit or a transfer budget is spent. When the response carries Retry-After, retry after that many seconds
  • errorErrorBody
    • The ErrorBody schema
    • codestringThe coarse category, tied to the status: NOT_FOUND, CONFLICT, INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all.
    • messagestringWhat went wrong, for a person. Written to be read, not parsed: match on reason or code.
    • fieldstring or nulloptionalOn a 400 that refused one field's value, the field, as its JSON path: email, items[0].name. Put the message under that input. Absent on every other error.
    • reasonstring or nulloptionalThe specific code, when the error has one: LAST_ORGANIZATION_OWNER, BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and on code otherwise.
    • required_scopestring or nulloptionalThe scope the access token was missing, on INSUFFICIENT_SCOPE.
    • violationsanyoptionalPresent on the structured-validation errors (PROVIDER_VALIDATION_FAILED per-node, PIPELINE_VALIDATION_FAILED DAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
429 exampleSynthesized example
{
"error": {
"code": "code-5f21",
"message": "Label every synthesized example"
}
}

CLI

gitmoap access create-repo-access-grants

  • --repo-ididRepository ID (id or owner/repo path)
  • --dry-runflagoptionalSay who would gain what, and change nothing
  • --expires-atstringoptionalWhen the access ends. Omit it for access that lasts until it is revoked.
  • --reasonstringoptional
  • --rolejson
  • --subjectsjsonWho receives the role — at most 50 subjects in one request.

Used in these guides