---
title: "Create a path permission"
method: POST
path: "/repos/{repo_id}/granular-permissions"
tags: ["Repository Granular Permissions"]
---

# Create a path permission

`POST /repos/{repo_id}/granular-permissions`

## Request

- Base URL: `https://api.diversion.dev/v0`
- URL: `https://api.diversion.dev/v0/repos/{repo_id}/granular-permissions`
- Auth: OAuth 2
  - Implicit: `https://auth.diversion.dev/oauth2/authorize`
  - Scopes: `coreapi/write`
- TypeScript: <https://skmtc.dev/diversion/apis/diversion-core-api/docs/repos/:repo_id/granular-permissions/post.ts> (a function with typed inputs; its response is checked against the schema)

Create a new path permission rule for this repository

## Request body

- CreateGranularPermission
  - `user_id` string: User ID to assign this permission to (mutually exclusive with group_id)
  - `group_id` string: Group ID to assign this permission to (mutually exclusive with `user_id`)
  - `path_pattern` string, required: Path pattern for matching files. Supports wildcards: "/path/to/file" for exact match, "/path/..." for recursive wildcard, "/path/*.ext" for extension matching.
  - `access_level` 'ADMIN' | 'WRITE' | 'READ' | 'NO_ACCESS', required: Access level for path permissions. Hierarchical: ADMIN > WRITE > READ > NO_ACCESS.
  - `permission_type` 'ALLOW_LT_EQ' | 'ALLOW_EQ' | 'DENY_ALL' | 'DENY_EQ', required: Permission type controlling how access levels are granted or denied. ALLOW_LT_EQ grants specified level and all lower levels. ALLOW_EQ grants only the exact level. DENY_ALL denies all level granted above in the table. DENY_EQ denies only the exact level.
  - `insert_above_rule_id` string: Optional. ID of an existing rule to insert this rule above (lower evaluation_order). If not provided, the rule is added at the top (highest evaluation_order/priority).

## Response `201`

Resource created

- NewResourceId
  - `id` string, required: The id of the newly created resource

## Other responses

- `400`: Invalid path pattern or missing required fields
- `default`: An error occurred

---

[API](https://skmtc.dev/diversion/apis/diversion-core-api.md) - [All operations](https://skmtc.dev/diversion/apis/diversion-core-api/llms.txt) - [OpenAPI document](https://skmtc.dev/diversion/apis/diversion-core-api/revisions/38a18aba804b?raw)
