MemNexus
GuidesUsing the SDK

Authentication

Configure API key authentication in the TypeScript SDK.

The MemNexus SDK uses API keys for authentication. Keys are passed as Bearer tokens in every request.

API key format

cmk_live_<id>.<secret>

Get your API key from memnexus.ai or create one with the CLI:

mx apikeys create --label "My App"

Configuring the client

Pass the API key as the token option when constructing the client.

import { Memnexus } from "@memnexus-ai/typescript-sdk";

const client = new Memnexus({
  token: process.env.MX_API_KEY,
});

From a secrets manager

import { Memnexus } from "@memnexus-ai/typescript-sdk";
import { getSecret } from "./secrets"; // Your secrets manager

const apiKey = await getSecret("memnexus-api-key");
const client = new Memnexus({ token: apiKey });

Managing API keys programmatically

List keys

const response = await client.apiKeys.listApiKeys();
for (const key of response.data?.data ?? []) {
  console.log(`${key.id}: ${key.label} (created ${key.createdAt})`);
}

Create a key

const response = await client.apiKeys.createApiKey({
  body: {
    label: "Production App",
    expiresAt: "2027-01-01T00:00:00Z",
  },
});

// Save this immediately — it's only shown once
console.log("New key:", response.data?.data?.apiKey);

Delete a key

await client.apiKeys.deleteApiKey("key_abc123");

Security best practices

  • Never hardcode API keys in source code
  • Use environment variables or a secrets manager
  • Set expirations on keys used for temporary access
  • Use separate keys per environment and application
  • Rotate keys periodically

Next steps