Skip to content

Users

(permissions.users)

Overview

Available Operations

checkUserPermission

Verifies whether the specified user has the requested permission level (owner, writer, or reader) on a given resource. Due to the hierarchical permission model, owner permissions include writer and reader access, and writer permissions include reader access. Returns true if the user has the permission (either directly or through inheritance), false otherwise.

Example Usage

typescript
import { SDK } from "@meetkai/mka1";

const sdk = new SDK({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await sdk.permissions.users.checkUserPermission({
    user: "alice@example.com",
    permission: "reader",
    resource: "budget-2024",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

typescript
import { SDKCore } from "@meetkai/mka1/core.js";
import { permissionsUsersCheckUserPermission } from "@meetkai/mka1/funcs/permissionsUsersCheckUserPermission.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await permissionsUsersCheckUserPermission(sdk, {
    user: "alice@example.com",
    permission: "reader",
    resource: "budget-2024",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("permissionsUsersCheckUserPermission failed:", res.error);
  }
}

run();

React hooks and utilities

This method can be used in React components through the following hooks and associated utilities.

Check out this guide for information about each of the utilities below and how to get started using React hooks.

tsx
import {
  // Query hooks for fetching data.
  usePermissionsUsersCheckUserPermission,
  usePermissionsUsersCheckUserPermissionSuspense,

  // Utility for prefetching data during server-side rendering and in React
  // Server Components that will be immediately available to client components
  // using the hooks.
  prefetchPermissionsUsersCheckUserPermission,
  
  // Utilities to invalidate the query cache for this query in response to
  // mutations and other user actions.
  invalidatePermissionsUsersCheckUserPermission,
  invalidateAllPermissionsUsersCheckUserPermission,
} from "@meetkai/mka1/react-query/permissionsUsersCheckUserPermission.js";

Parameters

ParameterTypeRequiredDescription
requestoperations.CheckUserPermissionRequest✔️The request object to use for the request.
optionsRequestOptionsUsed to set various options for making HTTP requests.
options.fetchOptionsRequestInitOptions that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retriesRetryConfigEnables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.CheckUserPermissionResponseBody>

Errors

Error TypeStatus CodeContent Type
errors.APIError4XX, 5XX*/*

listUserPermissions

Retrieves a comprehensive list of all resources the specified user has access to, organized by permission level (owner, writer, reader). This endpoint is useful for displaying a user's access rights or implementing authorization UI. Each permission level returns an array of resource IDs that the user can access at that level.

Example Usage

typescript
import { SDK } from "@meetkai/mka1";

const sdk = new SDK({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await sdk.permissions.users.listUserPermissions({
    user: "alice@example.com",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

typescript
import { SDKCore } from "@meetkai/mka1/core.js";
import { permissionsUsersListUserPermissions } from "@meetkai/mka1/funcs/permissionsUsersListUserPermissions.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await permissionsUsersListUserPermissions(sdk, {
    user: "alice@example.com",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("permissionsUsersListUserPermissions failed:", res.error);
  }
}

run();

React hooks and utilities

This method can be used in React components through the following hooks and associated utilities.

Check out this guide for information about each of the utilities below and how to get started using React hooks.

tsx
import {
  // Query hooks for fetching data.
  usePermissionsUsersListUserPermissions,
  usePermissionsUsersListUserPermissionsSuspense,

  // Utility for prefetching data during server-side rendering and in React
  // Server Components that will be immediately available to client components
  // using the hooks.
  prefetchPermissionsUsersListUserPermissions,
  
  // Utilities to invalidate the query cache for this query in response to
  // mutations and other user actions.
  invalidatePermissionsUsersListUserPermissions,
  invalidateAllPermissionsUsersListUserPermissions,
} from "@meetkai/mka1/react-query/permissionsUsersListUserPermissions.js";

Parameters

ParameterTypeRequiredDescription
requestoperations.ListUserPermissionsRequest✔️The request object to use for the request.
optionsRequestOptionsUsed to set various options for making HTTP requests.
options.fetchOptionsRequestInitOptions that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retriesRetryConfigEnables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.ListUserPermissionsResponseBody>

Errors

Error TypeStatus CodeContent Type
errors.APIError4XX, 5XX*/*

grantUserPermission

Grants the specified permission level (owner, writer, or reader) on a resource to a user. This creates a direct permission assignment. Note that due to the hierarchical model, granting owner permission automatically includes writer and reader access, and granting writer includes reader access. If the permission already exists, this operation will fail with a validation error.

Example Usage

typescript
import { SDK } from "@meetkai/mka1";

const sdk = new SDK({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await sdk.permissions.users.grantUserPermission({
    user: "alice@example.com",
    permission: "reader",
    resource: "budget-2024",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

typescript
import { SDKCore } from "@meetkai/mka1/core.js";
import { permissionsUsersGrantUserPermission } from "@meetkai/mka1/funcs/permissionsUsersGrantUserPermission.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await permissionsUsersGrantUserPermission(sdk, {
    user: "alice@example.com",
    permission: "reader",
    resource: "budget-2024",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("permissionsUsersGrantUserPermission failed:", res.error);
  }
}

run();

React hooks and utilities

This method can be used in React components through the following hooks and associated utilities.

Check out this guide for information about each of the utilities below and how to get started using React hooks.

tsx
import {
  // Mutation hook for triggering the API call.
  usePermissionsUsersGrantUserPermissionMutation
} from "@meetkai/mka1/react-query/permissionsUsersGrantUserPermission.js";

Parameters

ParameterTypeRequiredDescription
requestoperations.GrantUserPermissionRequestBody✔️The request object to use for the request.
optionsRequestOptionsUsed to set various options for making HTTP requests.
options.fetchOptionsRequestInitOptions that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retriesRetryConfigEnables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.GrantUserPermissionResponseBody>

Errors

Error TypeStatus CodeContent Type
errors.APIError4XX, 5XX*/*

revokeUserPermission

Removes the specified permission level from a user on a resource. This only removes the direct permission assignment at the specified level. Due to the hierarchical model, if a user has owner permission and you revoke reader, they will still have reader access through the owner permission. To fully remove access, revoke the highest permission level the user has.

Example Usage

typescript
import { SDK } from "@meetkai/mka1";

const sdk = new SDK({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await sdk.permissions.users.revokeUserPermission({
    user: "alice@example.com",
    permission: "reader",
    resource: "budget-2024",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

typescript
import { SDKCore } from "@meetkai/mka1/core.js";
import { permissionsUsersRevokeUserPermission } from "@meetkai/mka1/funcs/permissionsUsersRevokeUserPermission.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await permissionsUsersRevokeUserPermission(sdk, {
    user: "alice@example.com",
    permission: "reader",
    resource: "budget-2024",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("permissionsUsersRevokeUserPermission failed:", res.error);
  }
}

run();

React hooks and utilities

This method can be used in React components through the following hooks and associated utilities.

Check out this guide for information about each of the utilities below and how to get started using React hooks.

tsx
import {
  // Mutation hook for triggering the API call.
  usePermissionsUsersRevokeUserPermissionMutation
} from "@meetkai/mka1/react-query/permissionsUsersRevokeUserPermission.js";

Parameters

ParameterTypeRequiredDescription
requestoperations.RevokeUserPermissionRequestBody✔️The request object to use for the request.
optionsRequestOptionsUsed to set various options for making HTTP requests.
options.fetchOptionsRequestInitOptions that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retriesRetryConfigEnables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.RevokeUserPermissionResponseBody>

Errors

Error TypeStatus CodeContent Type
errors.APIError4XX, 5XX*/*