Skip to main content
POST/end-user-role-grants

Grant End User Role

Grants a project-level role to an end-user, creating a eur_-prefixed role grant record.

The role must be within the project's configured role ladder (minimum PROJECT_END_USER).

Role grants are privilege-escalation operations and require a checker by default under the Maker-Checker policy framework.

Requires PROJECT_ADMIN authority.

Parameters
projectSlug *path

The project's slug: the path segment after @.

It is unique within the org.

Request body
endUserId *string

The end user to grant the role to (eu_...).

An id with no end user in this project gets 404 K9O_NOT_FOUND.

role *string

The role name, as your application defines it.

The platform does not check it against a list.

An end user holds each role at most once: granting a role they already hold gets 400 K9O_INVALID_FIELD_VALUE.

Responses
HTTPK9O CodeDescription
200Success
401K9O_SESSION_EXPIREDYour session has expired; sign in again to continue.
403K9O_ACCESS_DENIEDYou do not hold the required role to grant roles to end-users.
404K9O_END_USER_NOT_FOUNDThe specified end-user does not exist in this project.
Response body (200)
data *object

The grant that was created.

grant *object

An active role grant.

id *string

The grant's id (eurg_...).

Use it to revoke the grant.

endUserId *string

The end user who holds the role (eu_...).

role *string

The role name.

grantedAt *string <date-time>

When the role was granted.

grantedBy *string

Who granted it: the subject id of the caller that made the grant (an operator's user id, usr_...), or invitation when the end user received it by redeeming an invitation.

meta *any

Request metadata: cost, timing and the request and trace ids.

TypeScript
// const k9o = new K9o({ orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…' })
const { data } = await k9o.endUsers.roleGrants.grant({
  endUserId: 'string',
  role: 'string'
})

Showing example in TypeScript

Request example
{
  "endUserId": "string",
  "role": "string"
}
Response example (200)
{
  "data": {
    "grant": {
      "id": "string",
      "endUserId": "string",
      "role": "string",
      "grantedAt": "string",
      "grantedBy": "string"
    }
  }
}

More in Members & End Users