Skip to content

Auth.ApiKeys

Overview

Available Operations

create

Mint an API key bound to a (principal, team) carrying an explicit scope set. Requires a session, or a bearer key holding write:apikeys. The plaintext secret is returned once.

Example Usage

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

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

async function run() {
  const result = await sdk.auth.apiKeys.create({});

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

typescript
import { SDKCore } from "@meetkai/mka1/core.js";
import { authApiKeysCreate } from "@meetkai/mka1/funcs/authApiKeysCreate.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 authApiKeysCreate(sdk, {});
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("authApiKeysCreate 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.
  useAuthApiKeysCreateMutation
} from "@meetkai/mka1/react-query/authApiKeysCreate.js";

Parameters

ParameterTypeRequiredDescription
requestoperations.CreateScopedApiKeyRequest✔️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.CreateScopedApiKeyResponseBody>

Errors

Error TypeStatus CodeContent Type
errors.CreateScopedApiKeyResponseBody400application/json
errors.CreateScopedApiKeyAuthApiKeysResponseBody401application/json
errors.CreateScopedApiKeyAuthApiKeysResponseResponseBody403application/json
errors.CreateScopedApiKeyAuthApiKeysResponse404ResponseBody404application/json
errors.CreateScopedApiKeyAuthApiKeysResponse409ResponseBody409application/json
errors.CreateScopedApiKeyAuthApiKeysResponse429ResponseBody429application/json
errors.APIError4XX, 5XX*/*

list

List the caller's scoped API keys (metadata only — never the secret). Optional ?orgId=&teamId= narrows; a key caller is scoped to its own org.

Example Usage

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

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

async function run() {
  const result = await sdk.auth.apiKeys.list({});

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

typescript
import { SDKCore } from "@meetkai/mka1/core.js";
import { authApiKeysList } from "@meetkai/mka1/funcs/authApiKeysList.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 authApiKeysList(sdk, {});
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("authApiKeysList 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.
  useAuthApiKeysList,
  useAuthApiKeysListSuspense,

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

Parameters

ParameterTypeRequiredDescription
requestoperations.ListScopedApiKeysRequest✔️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.ResponseBody[]>

Errors

Error TypeStatus CodeContent Type
errors.ListScopedApiKeysResponseBody400application/json
errors.ListScopedApiKeysAuthApiKeysResponseBody401application/json
errors.ListScopedApiKeysAuthApiKeysResponseResponseBody403application/json
errors.ListScopedApiKeysAuthApiKeysResponse404ResponseBody404application/json
errors.ListScopedApiKeysAuthApiKeysResponse409ResponseBody409application/json
errors.ListScopedApiKeysAuthApiKeysResponse429ResponseBody429application/json
errors.APIError4XX, 5XX*/*

update

Update a key's scopes (and optionally name / rate limit). Scopes already on the key are retained; newly-added scopes are bounded by the caller's role (and, for a key caller, the calling key's own scopes).

Example Usage

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

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

async function run() {
  const result = await sdk.auth.apiKeys.update({});

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

typescript
import { SDKCore } from "@meetkai/mka1/core.js";
import { authApiKeysUpdate } from "@meetkai/mka1/funcs/authApiKeysUpdate.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 authApiKeysUpdate(sdk, {});
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("authApiKeysUpdate 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.
  useAuthApiKeysUpdateMutation
} from "@meetkai/mka1/react-query/authApiKeysUpdate.js";

Parameters

ParameterTypeRequiredDescription
requestoperations.UpdateScopedApiKeyRequest✔️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.UpdateScopedApiKeyResponseBody>

Errors

Error TypeStatus CodeContent Type
errors.UpdateScopedApiKeyResponseBody400application/json
errors.UpdateScopedApiKeyAuthApiKeysResponseBody401application/json
errors.UpdateScopedApiKeyAuthApiKeysResponseResponseBody403application/json
errors.UpdateScopedApiKeyAuthApiKeysResponse404ResponseBody404application/json
errors.UpdateScopedApiKeyAuthApiKeysResponse409ResponseBody409application/json
errors.UpdateScopedApiKeyAuthApiKeysResponse429ResponseBody429application/json
errors.APIError4XX, 5XX*/*

regenerate

Issue a new plaintext secret for an existing key in place (id / scopes / binding preserved). Returned once.

Example Usage

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

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

async function run() {
  const result = await sdk.auth.apiKeys.regenerate({});

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

typescript
import { SDKCore } from "@meetkai/mka1/core.js";
import { authApiKeysRegenerate } from "@meetkai/mka1/funcs/authApiKeysRegenerate.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 authApiKeysRegenerate(sdk, {});
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("authApiKeysRegenerate 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.
  useAuthApiKeysRegenerateMutation
} from "@meetkai/mka1/react-query/authApiKeysRegenerate.js";

Parameters

ParameterTypeRequiredDescription
requestoperations.RegenerateScopedApiKeyRequest✔️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.RegenerateScopedApiKeyResponseBody>

Errors

Error TypeStatus CodeContent Type
errors.RegenerateScopedApiKeyResponseBody400application/json
errors.RegenerateScopedApiKeyAuthApiKeysResponseBody401application/json
errors.RegenerateScopedApiKeyAuthApiKeysResponseResponseBody403application/json
errors.RegenerateScopedApiKeyAuthApiKeysResponse404ResponseBody404application/json
errors.RegenerateScopedApiKeyAuthApiKeysResponse409ResponseBody409application/json
errors.RegenerateScopedApiKeyAuthApiKeysResponse429ResponseBody429application/json
errors.APIError4XX, 5XX*/*

exchangeToken

Exchange an API key for a short-lived JWT token.

Example Usage

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

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

async function run() {
  const result = await sdk.auth.apiKeys.exchangeToken({
    requestBody: {
      audience: "https://medium-haversack.info/",
      externalUserId: "<id>",
    },
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

typescript
import { SDKCore } from "@meetkai/mka1/core.js";
import { authApiKeysExchangeToken } from "@meetkai/mka1/funcs/authApiKeysExchangeToken.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 authApiKeysExchangeToken(sdk, {
    requestBody: {
      audience: "https://medium-haversack.info/",
      externalUserId: "<id>",
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("authApiKeysExchangeToken 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.
  useAuthApiKeysExchangeTokenMutation
} from "@meetkai/mka1/react-query/authApiKeysExchangeToken.js";

Parameters

ParameterTypeRequiredDescription
requestoperations.ExchangeApiKeyTokenRequest✔️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.ExchangeApiKeyTokenResponseBody>

Errors

Error TypeStatus CodeContent Type
errors.ExchangeApiKeyTokenResponseBody400application/json
errors.ExchangeApiKeyTokenAuthApiKeysResponseBody401application/json
errors.ExchangeApiKeyTokenAuthApiKeysResponseResponseBody403application/json
errors.ExchangeApiKeyTokenAuthApiKeysResponse404ResponseBody404application/json
errors.ExchangeApiKeyTokenAuthApiKeysResponse409ResponseBody409application/json
errors.ExchangeApiKeyTokenAuthApiKeysResponse429ResponseBody429application/json
errors.APIError4XX, 5XX*/*