Skip to content
Docs
Roles

Update role

Update role

client.Zones.Roles.Update(ctx, roleID, params) (*Role, error)
PATCH/zones/{zoneId}/roles/{roleId}

Updates a customer-owned role's description. The identifier is immutable, and platform-owned roles cannot be modified.

ParametersExpand Collapse
roleID string
params ZoneRoleUpdateParams
ZoneID param.Field[string]

Path param: Zone ID

RoleUpdate param.Field[RoleUpdate]optional

Body param: Schema for updating an existing role. The role identifier is immutable.

ReturnsExpand Collapse
type Role struct{…}

A role that can be assigned to users within a zone.

ID string

Unique identifier of the role

CreatedAt Time

Entity creation timestamp

formatdate-time
Identifier string

Role identifier: a lowercase slug (letters and digits separated by single hyphens or underscores), unique per owner type within a zone. Role identifiers surface in policy evaluation, so the slug restriction keeps them unambiguous in policy text.

minLength1
maxLength255
OwnerType RoleOwnerType

Who owns this role. Platform-owned roles are managed by Keycard and cannot be modified or deleted via the API; customer-owned roles are user-created.

Accepts one of the following:
const RoleOwnerTypePlatform RoleOwnerType = "platform"
const RoleOwnerTypeCustomer RoleOwnerType = "customer"
UpdatedAt Time

Entity update timestamp

formatdate-time
ZoneID string

Zone this role belongs to

Description stringoptional

Human-readable description

maxLength1000

Update role

package main

import (
  "context"
  "fmt"

  "github.com/keycardai/keycard-go"
  "github.com/keycardai/keycard-go/option"
)

func main() {
  client := keycard.NewClient(
    option.WithAPIKey("My API Key"),
  )
  role, err := client.Zones.Roles.Update(
    context.TODO(),
    "roleId",
    keycard.ZoneRoleUpdateParams{
      ZoneID: "zoneId",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", role.ID)
}
{
  "id": "id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "identifier": "identifier",
  "owner_type": "platform",
  "updated_at": "2019-12-27T18:11:19.117Z",
  "zone_id": "zone_id",
  "description": "description"
}
Returns Examples
{
  "id": "id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "identifier": "identifier",
  "owner_type": "platform",
  "updated_at": "2019-12-27T18:11:19.117Z",
  "zone_id": "zone_id",
  "description": "description"
}