> For the complete documentation index, see [llms.txt](https://docs.n8n.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.n8n.io/connect/n8n-api/role-mapping-rule.md).

# Role Mapping Rule

Operations about identity-provider role-mapping rules

## Create a role-mapping rule

> Creates a rule that maps an identity-provider claim expression to a role. Set \`type\` to \`instance\` for a rule granting a global role, or \`project\` for a rule granting a project role on the projects named in \`projectIds\`. Omitting \`order\` appends the rule to the end of the evaluation order for its type.

```json
{"openapi":"3.0.0","info":{"title":"n8n Public API","version":"1.1.1"},"tags":[{"name":"RoleMappingRule","description":"Operations about identity-provider role-mapping rules"}],"servers":[{"url":"/api/v1","description":"Current n8n instance (self-hosted built-in playground)"},{"url":"{url}/api/v1","description":"Self-hosted n8n instance","variables":{"url":{"default":"https://example.com"}}}],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]},{"CookieAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-N8N-API-KEY"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"},"CookieAuth":{"type":"apiKey","in":"cookie","name":"n8n-auth"}},"responses":{"badRequest":{"description":"The request is invalid or provides malformed data."},"unauthorized":{"description":"Unauthorized"},"forbidden":{"description":"Forbidden"},"notFound":{"description":"The specified resource was not found."}}},"paths":{"/role-mapping-rules":{"post":{"operationId":"createRoleMappingRule","tags":["RoleMappingRule"],"summary":"Create a role-mapping rule","description":"Creates a rule that maps an identity-provider claim expression to a role. Set `type` to `instance` for a rule granting a global role, or `project` for a rule granting a project role on the projects named in `projectIds`. Omitting `order` appends the rule to the end of the evaluation order for its type.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"expression":{"type":"string","minLength":1},"role":{"type":"string","minLength":1,"maxLength":128},"type":{"type":"string","enum":["instance","project"]},"order":{"type":"integer","minimum":0},"projectIds":{"type":"array","items":{"type":"string"}}},"required":["expression","role","type"]}}}},"responses":{"201":{"description":"Operation successful.","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"expression":{"type":"string"},"role":{"type":"string"},"type":{"type":"string","enum":["instance","project"]},"order":{"type":"integer"},"projectIds":{"type":"array","items":{"type":"string"}},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","expression","role","type","order","projectIds","createdAt","updatedAt"]}}}},"400":{"$ref":"#/components/responses/badRequest"},"401":{"$ref":"#/components/responses/unauthorized"},"403":{"$ref":"#/components/responses/forbidden"},"404":{"$ref":"#/components/responses/notFound"}}}}}}
```
