> ## Documentation Index
> Fetch the complete documentation index at: https://docs.neuraltrust.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a role

> Creates a new role in a gateway. model_policies cannot be set on create; bind registries first, then update the role.



## OpenAPI

````yaml /trustgate/api/openapi.json post /v1/gateways/{gateway_id}/roles
openapi: 3.0.0
info:
  description: >-
    Administrative API for managing gateways and their registries, policies,
    consumers, roles and auth credentials.
  title: TrustGate Admin API
  contact:
    name: NeuralTrust
    url: https://neuraltrust.ai/contact
    email: support@neuraltrust.ai
  version: '1.0'
servers:
  - url: https://agentgateway-admin.dev.neuraltrust.ai
    description: Admin API
security: []
paths:
  /v1/gateways/{gateway_id}/roles:
    post:
      tags:
        - roles
      summary: Create a role
      description: >-
        Creates a new role in a gateway. model_policies cannot be set on create;
        bind registries first, then update the role.
      parameters:
        - description: Gateway id
          name: gateway_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        content:
          application/json:
            schema:
              $ref: >-
                #/components/schemas/github_com_NeuralTrust_TrustGate_pkg_api_handler_http_role_request.CreateRoleRequest
        description: Role to create
        required: true
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/github_com_NeuralTrust_TrustGate_pkg_api_handler_http_role_response.RoleResponse
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/github_com_NeuralTrust_TrustGate_pkg_api_handler_http_helpers.ErrorBody
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/github_com_NeuralTrust_TrustGate_pkg_api_handler_http_helpers.ErrorBody
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/github_com_NeuralTrust_TrustGate_pkg_api_handler_http_helpers.ErrorBody
        '409':
          description: Conflict
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/github_com_NeuralTrust_TrustGate_pkg_api_handler_http_helpers.ErrorBody
      security:
        - BearerAuth: []
components:
  schemas:
    github_com_NeuralTrust_TrustGate_pkg_api_handler_http_role_request.CreateRoleRequest:
      type: object
      properties:
        mcp_policies:
          $ref: >-
            #/components/schemas/github_com_NeuralTrust_TrustGate_pkg_api_handler_http_role_request.MCPPoliciesRequest
        model_policies:
          type: array
          items:
            $ref: >-
              #/components/schemas/github_com_NeuralTrust_TrustGate_pkg_api_handler_http_role_request.ModelPolicyRequest
        name:
          type: string
        oidc_mapping:
          type: array
          items:
            type: integer
    github_com_NeuralTrust_TrustGate_pkg_api_handler_http_role_response.RoleResponse:
      type: object
      properties:
        created_at:
          type: string
        gateway_id:
          type: string
        id:
          type: string
        mcp_policies:
          $ref: >-
            #/components/schemas/github_com_NeuralTrust_TrustGate_pkg_domain_role.MCPPolicies
        model_policies:
          type: array
          items:
            $ref: >-
              #/components/schemas/github_com_NeuralTrust_TrustGate_pkg_api_handler_http_role_response.ModelPolicyResponse
        name:
          type: string
        oidc_mapping:
          type: array
          items:
            type: integer
        registry_ids:
          type: array
          items:
            type: string
        updated_at:
          type: string
    github_com_NeuralTrust_TrustGate_pkg_api_handler_http_helpers.ErrorBody:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
    github_com_NeuralTrust_TrustGate_pkg_api_handler_http_role_request.MCPPoliciesRequest:
      type: object
      properties:
        fail_mode:
          type: string
        toolkit:
          type: array
          items:
            $ref: >-
              #/components/schemas/github_com_NeuralTrust_TrustGate_pkg_api_handler_http_role_request.ToolkitEntryRequest
    github_com_NeuralTrust_TrustGate_pkg_api_handler_http_role_request.ModelPolicyRequest:
      type: object
      properties:
        allowed:
          type: array
          items:
            type: string
        default:
          type: string
        registry_id:
          type: string
    github_com_NeuralTrust_TrustGate_pkg_domain_role.MCPPolicies:
      type: object
      properties:
        fail_mode:
          $ref: >-
            #/components/schemas/github_com_NeuralTrust_TrustGate_pkg_domain_consumer.FailMode
        toolkit:
          type: array
          items:
            $ref: >-
              #/components/schemas/github_com_NeuralTrust_TrustGate_pkg_domain_consumer.ToolkitEntry
    github_com_NeuralTrust_TrustGate_pkg_api_handler_http_role_response.ModelPolicyResponse:
      type: object
      properties:
        allowed:
          type: array
          items:
            type: string
        default:
          type: string
        registry_id:
          type: string
    github_com_NeuralTrust_TrustGate_pkg_api_handler_http_role_request.ToolkitEntryRequest:
      type: object
      properties:
        expose_as:
          type: string
        prompt:
          type: string
        registry_id:
          type: string
        resource:
          type: string
        tool:
          type: string
    github_com_NeuralTrust_TrustGate_pkg_domain_consumer.FailMode:
      type: string
      enum:
        - closed
        - open
      x-enum-varnames:
        - FailModeClosed
        - FailModeOpen
    github_com_NeuralTrust_TrustGate_pkg_domain_consumer.ToolkitEntry:
      type: object
      properties:
        expose_as:
          type: string
        prompt:
          type: string
        registry_id:
          type: string
        resource:
          type: string
        tool:
          type: string
  securitySchemes:
    BearerAuth:
      type: apiKey
      name: Authorization
      in: header

````