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

# Create Custom Role

> Create a custom role on a team. A custom role extends a built-in base role with additional grantable actions. Assign it to a group with the Team Group API's custom_role_id. Requires custom roles to be enabled for the organization.

## Authentication and permissions

> **Token requirements:** **User-based token (OAuth)** or **Organization-scoped API key**.
>
> Send a bearer access token for one of these identities. The permissions and resource restrictions below also apply.

| Credential | Access requirements |
| - | - |
| Organization-scoped API key | `teams:manage` |
| Team-scoped API key | Unsupported |
| User-based token (OAuth) | Supported, subject to permissions |

Permissions joined by **+** are all required; **or** separates alternatives. Full-access keys still cannot call endpoints marked unsupported. Team keys must allow every team checked by the request. OAuth access depends on the user’s roles and resource access.

* **Default request:** With a user OAuth token, you also need Edit Team Settings on the role's team, and you can grant only actions you already hold there.


## OpenAPI

````yaml /sections/api-reference/openapi-spec-v2.yaml post /v2/teams/{team_id}/custom-roles
openapi: 3.1.0
info:
  title: Serval Public API
  description: Serval Public API
  contact:
    name: Serval
    url: https://serval.com
    email: support@serval.com
  license:
    name: Serval License
    url: https://serval.com/license
  version: 2.0.0
servers:
  - url: https://public.api.serval.com
security:
  - BearerAuth: []
tags:
  - name: Access Membership API
  - name: Access Policy API
  - name: Access Policy Approval Procedure API
  - name: Access Profile API
  - name: Access Relationship API
  - name: Access Request API
  - name: Agent API
  - name: Analytics API
  - name: App Instance API
  - name: App Resource API
  - name: App Resource Role API
  - name: Approval Delegation API
  - name: Approval Procedure API
  - name: Approval Request API
  - name: Assignment Rules API
  - name: Audit Log API
  - name: Campaign API
  - name: Change Blackout API
  - name: Change Model API
  - name: Connected Channels API
  - name: Custom Field API
  - name: Custom Role API
  - name: Custom Service API
  - name: Dashboards API
  - name: Email Intake API
  - name: Entity API
  - name: Entity Field Mapping API
  - name: Entity Ingestion Config API
  - name: Entity Type API
  - name: Folder API
  - name: Forms API
  - name: Group API
  - name: Guidance API
  - name: Help Agent API
  - name: Journey API
  - name: Knowledge API
  - name: Knowledge Base API
  - name: One-Time Window API
  - name: Report API
  - name: Review API
  - name: Roles API
  - name: SLA API
  - name: Schedule API
  - name: Tag API
  - name: Team API
  - name: Team Group API
  - name: Team SDLC Settings API
  - name: Team User API
  - name: Ticket API
  - name: Topic API
  - name: User API
  - name: User Relationship API
  - name: Widgets API
  - name: Worker API
  - name: Workflow API
  - name: Workflow Approval Procedure API
  - name: Workflow Run API
paths:
  /v2/teams/{team_id}/custom-roles:
    post:
      tags:
        - Custom Role API
      summary: Create Custom Role
      description: >-
        Create a custom role on a team. A custom role extends a built-in base
        role with additional grantable actions. Assign it to a group with the
        Team Group API's custom_role_id. Requires custom roles to be enabled for
        the organization.
      operationId: svrelay.publicv2.PublicAPIServiceV2.CreateCustomRole
      parameters:
        - name: team_id
          in: path
          required: true
          schema:
            type: string
            title: team_id
            description: >-
              The team that owns the role. A custom role can only be assigned on
              its
               own team.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  title: name
                  description: Unique among the team's custom roles.
                description:
                  type: string
                  title: description
                baseRole:
                  $ref: '#/components/schemas/svauth.public.TeamUserRole'
                  title: base_role
                  description: >-
                    The built-in role the custom role extends. A member holding
                    the custom
                     role has everything the base role grants plus granted_actions.
                grantedActions:
                  type: array
                  items:
                    type: string
                  title: granted_actions
                  description: >-
                    Action slugs the role grants on top of its base role. Only
                    grantable
                     actions are accepted; an unknown or non-grantable slug rejects the
                     request.
              title: CreateCustomRoleRequest
              required:
                - name
                - baseRole
              additionalProperties: false
        required: true
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/svauth.public.CreateCustomRoleResponse'
      security:
        - BearerAuth: []
components:
  schemas:
    svauth.public.TeamUserRole:
      type: string
      title: TeamUserRole
      enum:
        - TEAM_USER_ROLE_UNSPECIFIED
        - TEAM_USER_ROLE_AGENT
        - TEAM_USER_ROLE_MANAGER
        - TEAM_USER_ROLE_BUILDER
        - TEAM_USER_ROLE_VIEWER
        - TEAM_USER_ROLE_CONTRIBUTOR
        - TEAM_USER_ROLE_DRAFTER
        - TEAM_USER_ROLE_READONLY_AGENT
        - TEAM_USER_ROLE_APP_BUILDER
        - TEAM_USER_ROLE_APP_VIEWER
        - TEAM_USER_ROLE_PERSONAL_TEAM_OWNER
    svauth.public.CreateCustomRoleResponse:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/svauth.public.CustomRole'
          title: data
          x-stainless-terraform-configurability: optional
      title: CreateCustomRoleResponse
      additionalProperties: false
    svauth.public.CustomRole:
      type: object
      properties:
        id:
          type: string
          title: id
          readOnly: true
          x-stainless-terraform-configurability: computed
        teamId:
          type: string
          title: team_id
          x-stainless-terraform-configurability: optional
        name:
          type: string
          title: name
          x-stainless-terraform-configurability: optional
        description:
          type: string
          title: description
          x-stainless-terraform-configurability: optional
        baseRole:
          $ref: '#/components/schemas/svauth.public.TeamUserRole'
          title: base_role
          description: The built-in role the custom role extends.
          x-stainless-terraform-configurability: optional
        grantedActions:
          type: array
          items:
            type: string
          title: granted_actions
          description: Action slugs the role grants on top of its base role, sorted.
          x-stainless-terraform-configurability: optional
        createdAt:
          $ref: '#/components/schemas/google.protobuf.Timestamp'
          title: created_at
          readOnly: true
          x-stainless-terraform-configurability: computed
      title: CustomRole
      additionalProperties: false
    google.protobuf.Timestamp:
      type: string
      examples:
        - '2025-01-15T01:30:15.000Z'
        - '2025-06-01T00:00:00.000Z'
      format: date-time
      description: A timestamp in RFC 3339 format (e.g., "2025-01-15T01:30:15Z").
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.