---
title: Create custom roles for Scorecards
source: https://docs.newrelic.com/docs/apis/nerdgraph/examples/nerdgraph-scorecards-custom-tutorial
---

A Scorecard serves as a container for various rules that collectively assess adherence to defined standards. Scorecards use rules to monitor compliance across different entities and teams, identify areas for improvement, and ensure alignment with both internal and external requirements.

## Default Scorecards access [#default-access]

New Relic provides default access to Scorecards through these standard roles:

| Action                                          | Required role                                                                                                                                                                                 |
| ----------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| View Scorecards                                 | [**Organization read only**](https://docs.newrelic.com/docs/accounts/accounts-billing/new-relic-one-user-management/user-management-concepts/#standard-roles)                                 |
| Create, update, and delete Scorecards and rules | [**Organization Product Admin**](https://docs.newrelic.com/docs/accounts/accounts-billing/new-relic-one-user-management/user-management-concepts/#standard-roles) or a custom Scorecards role |

You might need a custom role if the default permissions don't meet your organization's needs.

## Scorecards capabilities [#capabilities]

When building a custom role for Scorecards, use the permissions below. Scorecards permissions are organization-scoped.

| Capability                                           | Permission identifier         |
| ---------------------------------------------------- | ----------------------------- |
| Read Scorecards (also grants `scorecards.read.rule`) | `scorecards.read.scorecard`   |
| Create, update, and delete Scorecards                | `scorecards.modify.scorecard` |
| Read Scorecard rules                                 | `scorecards.read.rule`        |
| Create, update, and delete Scorecard rules           | `scorecards.modify.rule`      |

## Prerequisites [#prerequisites]

Before you begin, ensure you have:

-   [General NerdGraph requirements](https://docs.newrelic.com/docs/apis/nerdgraph/get-started/introduction-new-relic-nerdgraph/#authentication)
-   Organization Admin with `Organization Product Admin` role to create custom roles

> #### 💡 TIP
>
> You can also create a custom role for Scorecards through the UI. For the permissions to select and the scope to use, see [Scorecards capabilities](https://docs.newrelic.com/docs/service-architecture-intelligence/scorecards/getting-started/#scorecards-capabilities).

To create a custom role via the NerdGraph API, perform the following steps:

## Find the required permission IDs for Scorecards

Use the `customerAdministration` query to retrieve a list of capabilities, their permission IDs, and related information. Filter by `scope: "organization"` to get Scorecards permissions.

#### Input parameters

| Parameter | Data Type | Is it Required? | Description                                                             |
| --------- | --------- | --------------- | ----------------------------------------------------------------------- |
| `eq`      | String    | Yes             | Set the value to `organization` to retrieve permissions for Scorecards. |

#### Sample request

````graphql
{
  customerAdministration {
    permissions(filter: { scope: { eq: "organization" } }) {
      items {
        feature
        category
        id
        product
      }
    }
  }
}
```

#### Sample response

```json
{
  "data": {
    "customerAdministration": {
      "permissions": {
        "items": [
          {
            "category": "READ",
            "feature": "Scorecards Rules",
            "id": "xxxxx",
            "product": "New Relic One"
          },
          {
            "category": "MANAGE",
            "feature": "Scorecards Rules",
            "id": "xxxxx",
            "product": "New Relic One"
          },
          {
            "category": "READ",
            "feature": "Scorecards",
            "id": "xxxxx",
            "product": "New Relic One"
          },
          {
            "category": "MANAGE",
            "feature": "Scorecards",
            "id": "xxxxx",
            "product": "New Relic One"
          }
        ]
      }
    }
  }
}
```

From the response, identify and copy the permission IDs where `feature` is `"Scorecards"` or `"Scorecards Rules"` and `category` matches the access level you want to grant. You'll need these IDs in the next step.

````

## Retrieve your organization ID

Retrieve your organization ID, which you'll use in subsequent mutations.

#### Sample request

````graphql
{
  actor {
    organization {
      id
    }
  }
}
```

#### Sample response

```json
{
  "data": {
    "actor": {
      "organization": {
        "id": "YOUR_ORGANIZATION_ID"
      }
    }
  }
}
```

Copy your organization ID from the response. You'll need it to create the custom role.

````

## Create the custom role

Use the `customRoleCreate` mutation to create your custom role for Scorecards management.

#### Input parameters

| Parameter       | Data Type         | Is it Required? | Description                                         |
| --------------- | ----------------- | --------------- | --------------------------------------------------- |
| `id`            | String            | Yes             | The organization ID from the previous step.         |
| `type`          | String            | Yes             | Set to `organization`.                              |
| `name`          | String            | Yes             | The display name for the custom role.               |
| `permissionIds` | Array of Integers | Yes             | The Scorecards permission IDs identified in Step 1. |
| `scope`         | String            | Yes             | Set to `organization`.                              |

#### Sample request

````graphql
mutation {
  customRoleCreate(
    container: {
      id: "YOUR_ORGANIZATION_ID"
      type: "organization"
    }
    name: "Scorecards manager"
    permissionIds: [xxxxx, xxxxx]
    scope: "organization"
  ) {
    id
  }
}
```

#### Sample response

```json
{
  "data": {
    "customRoleCreate": {
      "id": 9999999
    }
  }
}
```

Save the returned role ID — you'll need it to assign this role to a user group.

````

## Add the custom role to a user group

After creating the custom role, assign it to a user group in New Relic.

### Retrieve group IDs

Use the `customerAdministration` query to get a list of available user groups.

#### Input parameters

| Parameter | Data Type | Is it Required? | Description                                 |
| --------- | --------- | --------------- | ------------------------------------------- |
| `id`      | String    | Yes             | The organization ID from the previous step. |

#### Sample request

````graphql
{
  customerAdministration {
    groups(
      filter: {
        organizationId: { eq: "YOUR_ORGANIZATION_ID" }
      }
    ) {
      nextCursor
      items {
        id
        name
        users {
          items {
            id
            email
          }
        }
      }
    }
  }
}
```

From the response, copy the group ID for the group you want to assign the Scorecards role to.

### Assign the role to the group

Use the `authorizationManagementGrantAccess` mutation to assign the custom role to a user group.

#### Input parameters

<table>
  <thead>
    <tr>
      <th>Parameter</th>
      <th>Data Type</th>
      <th>Is it Required?</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>`roleId`</td>
      <td>String</td>
      <td>Yes</td>
      <td>The custom role ID from the previous step.</td>
    </tr>
    <tr>
      <td>`groupId`</td>
      <td>String</td>
      <td>Yes</td>
      <td>The group ID retrieved above.</td>
    </tr>
  </tbody>
</table>

#### Sample request

```graphql
mutation {
  authorizationManagementGrantAccess(
    grantAccessOptions: {
      organizationAccessGrants: { roleId: "YOUR_ROLE_ID" }
      groupId: "YOUR_GROUP_ID"
    }
  ) {
    roles {
      id
      name
      organizationId
      roleId
      groupId
      displayName
    }
  }
}
```

#### Sample response

```json
{
  "data": {
    "authorizationManagementGrantAccess": {
      "roles": [
        {
          "displayName": "Scorecards manager",
          "groupId": null,
          "id": "99999999",
          "name": "scorecards_manager",
          "organizationId": "YOUR_ORGANIZATION_ID",
          "roleId": 99999
        }
      ]
    }
  }
}
```

````

## Manage existing custom roles [#manage-roles]

**Update a role**

Use the `customRoleUpdate` mutation to rename a role or replace its permission set.

````graphql
mutation {
  customRoleUpdate(
    id: ROLE_ID
    name: "Updated role name"
    permissionIds: [xxxxx, xxxxx]
  ) {
    id
  }
}
```

<table>
  <thead>
    <tr>
      <th>Parameter</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>`id`</td>
      <td>The ID of the role to update.</td>
    </tr>
    <tr>
      <td>`name`</td>
      <td>New display name for the role.</td>
    </tr>
    <tr>
      <td>`permissionIds`</td>
      <td>Full replacement list of permission IDs. This replaces all existing permissions on the role.</td>
    </tr>
  </tbody>
</table>

````

**Delete a role**

Use the `customRoleDelete` mutation to permanently remove a custom role.

````graphql
mutation {
  customRoleDelete(id: ROLE_ID) {
    id
  }
}
```

The response returns the ID of the deleted role, confirming successful deletion.

````

**Find a custom role's ID**

Use the following query to look up a role ID by browsing your organization's groups and their assigned roles.

````graphql
{
  actor {
    organization {
      authorizationManagement {
        authenticationDomains(id: "YOUR_AUTHENTICATION_DOMAIN_ID") {
          authenticationDomains {
            groups {
              groups {
                displayName
                id
                roles {
                  roles {
                    roleId
                    name
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
```

````

For more information about Scorecards, see the [Scorecards documentation](https://docs.newrelic.com/docs/service-architecture-intelligence/scorecards/getting-started/).
