Skip to content
Docs
Roles

List roles

List roles

client.Zones.Roles.List(ctx, zoneID, query) (*ZoneRoleListResponse, error)
GET/zones/{zoneId}/roles

Returns the roles defined in the specified zone. The full result set is currently returned in a single page; the after/before/limit cursor parameters are reserved and not yet enforced, and pagination cursors are always null.

ParametersExpand Collapse
zoneID string
query ZoneRoleListParams
After param.Field[string]optional

Cursor for forward pagination

minLength1
maxLength255
Before param.Field[string]optional

Cursor for backward pagination

minLength1
maxLength255
Expand param.Field[ZoneRoleListParamsExpandUnion]optional
type ZoneRoleListParamsExpandString string
type ZoneRoleListParamsExpandArray []string
Identifier param.Field[string]optional

Filter roles by identifier

Limit param.Field[int64]optional

Maximum number of items to return

minimum1
maximum100
ReturnsExpand Collapse
type ZoneRoleListResponse struct{…}
Items []Role
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

List roles

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"),
  )
  roles, err := client.Zones.Roles.List(
    context.TODO(),
    "zoneId",
    keycard.ZoneRoleListParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", roles.Items)
}
{
  "items": [
    {
      "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"
    }
  ],
  "pagination": {
    "after_cursor": "x",
    "before_cursor": "x",
    "total_count": 0
  }
}
Returns Examples
{
  "items": [
    {
      "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"
    }
  ],
  "pagination": {
    "after_cursor": "x",
    "before_cursor": "x",
    "total_count": 0
  }
}