> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mka1.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Prompt repository

> Manage versioned prompt templates with change history, rollback, and variable rendering through the Prompts API.

The Prompts API lets you store, version, and manage prompt templates centrally.
Every template change creates an immutable version, giving you a full change history
with the ability to roll back to any previous version at any time.

Templates support `{{variable}}` placeholders that are rendered server-side when you
retrieve a prompt, so you can reuse the same template across different contexts.

## Create a prompt

Create a prompt with a name and template. The first version is created automatically.

<CodeGroup>
  ```bash CLI theme={null}
  mka1 llm prompts create \
    --body '{
      "name": "greeting",
      "description": "A simple greeting template",
      "template": "Hello, {{name}}! Welcome to {{company}}.",
      "metadata": { "team": "onboarding" }
    }' \
    -H 'X-On-Behalf-Of: <end-user-id>'
  ```

  ```ts MKA1 SDK theme={null}
  import { SDK } from '@meetkai/mka1';

  const mka1 = new SDK({
    bearerAuth: `Bearer ${YOUR_API_KEY}`,
  });

  const result = await mka1.llm.prompts.create({
    name: 'greeting',
    description: 'A simple greeting template',
    template: 'Hello, {{name}}! Welcome to {{company}}.',
    metadata: { team: 'onboarding' },
  }, { headers: { 'X-On-Behalf-Of': '<end-user-id>' } });

  console.log(result.id);            // prompt_abc123...
  console.log(result.activeVersion); // 1
  ```

  ```csharp C# SDK theme={null}
  using MeetKai.MKA1;
  using MeetKai.MKA1.Types.Components;

  var sdk = new SDK(
      bearerAuth: "Bearer <mka1-api-key>",
      serverUrl: "https://apigw.mka1.com"
  );

  var result = await sdk.Llm.Prompts.CreateAsync(
      new CreatePromptRequest
      {
          Name = "greeting",
          Description = "A simple greeting template",
          Template = "Hello, {{name}}! Welcome to {{company}}.",
          Metadata = new Dictionary<string, object> { { "team", "onboarding" } },
      }
  );

  Console.WriteLine(result.CreatePromptResponseValue!.Id);            // prompt_abc123...
  Console.WriteLine(result.CreatePromptResponseValue!.ActiveVersion); // 1
  ```

  ```python Python SDK theme={null}
  from mka1 import SDK

  sdk = SDK(bearer_auth="Bearer YOUR_API_KEY")

  result = sdk.llm.prompts.create(
      name="greeting",
      description="A simple greeting template",
      template="Hello, {{name}}! Welcome to {{company}}.",
      metadata={"team": "onboarding"},
  )

  print(result.id)              # prompt_abc123...
  print(result.active_version)  # 1
  ```

  ```bash bash theme={null}
  curl https://apigw.mka1.com/api/v1/llm/prompts \
    --request POST \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer <mka1-api-key>' \
    --header 'X-On-Behalf-Of: <end-user-id>' \
    --data '{
      "name": "greeting",
      "description": "A simple greeting template",
      "template": "Hello, {{name}}! Welcome to {{company}}.",
      "metadata": { "team": "onboarding" }
    }'
  ```
</CodeGroup>

## Retrieve a prompt with rendered variables

Pass `variables` as a query parameter to render the template with your values.
Unmatched placeholders are left as-is.

<CodeGroup>
  ```bash CLI theme={null}
  mka1 llm prompts get \
    --id prompt_abc123 \
    --variables '{"name":"Alice","company":"Acme"}'
  ```

  ```ts MKA1 SDK theme={null}
  const prompt = await mka1.llm.prompts.get({
    id: promptId,
    variables: JSON.stringify({ name: 'Alice', company: 'Acme' }),
  }, { headers: { 'X-On-Behalf-Of': '<end-user-id>' } });

  console.log(prompt.renderedTemplate);
  // "Hello, Alice! Welcome to Acme."
  ```

  ```csharp C# SDK theme={null}
  using MeetKai.MKA1;

  var sdk = new SDK(
      bearerAuth: "Bearer <mka1-api-key>",
      serverUrl: "https://apigw.mka1.com"
  );

  var prompt = await sdk.Llm.Prompts.GetAsync(
      id: promptId,
      variables: "{\"name\":\"Alice\",\"company\":\"Acme\"}"
  );

  Console.WriteLine(prompt.GetPromptResponseValue!.RenderedTemplate);
  // "Hello, Alice! Welcome to Acme."
  ```

  ```python Python SDK theme={null}
  prompt = sdk.llm.prompts.get(
      id=prompt_id,
      variables='{"name": "Alice", "company": "Acme"}',
  )

  print(prompt.rendered_template)
  # "Hello, Alice! Welcome to Acme."
  ```

  ```bash bash theme={null}
  # URL-encode the variables JSON
  curl "https://apigw.mka1.com/api/v1/llm/prompts/prompt_abc123?variables=%7B%22name%22%3A%22Alice%22%2C%22company%22%3A%22Acme%22%7D" \
    --header 'Authorization: Bearer <mka1-api-key>' \
    --header 'X-On-Behalf-Of: <end-user-id>'
  ```
</CodeGroup>

## List prompts

Retrieve a paginated list of all prompts. Use `after` for cursor-based pagination.

<CodeGroup>
  ```bash CLI theme={null}
  mka1 llm prompts list --limit 10 --order desc
  ```

  ```ts MKA1 SDK theme={null}
  const list = await mka1.llm.prompts.list({
    limit: 10,
    order: 'desc',
  }, { headers: { 'X-On-Behalf-Of': '<end-user-id>' } });

  for (const prompt of list.data) {
    console.log(prompt.name, `v${prompt.activeVersion}`);
  }

  if (list.hasMore) {
    // Fetch next page using the last ID as cursor
    const next = await mka1.llm.prompts.list({
      limit: 10,
      after: list.lastId,
    }, { headers: { 'X-On-Behalf-Of': '<end-user-id>' } });
  }
  ```

  ```csharp C# SDK theme={null}
  using MeetKai.MKA1;

  var sdk = new SDK(
      bearerAuth: "Bearer <mka1-api-key>",
      serverUrl: "https://apigw.mka1.com"
  );

  var prompts = await sdk.Llm.Prompts.ListAsync();

  Console.WriteLine(prompts);
  ```

  ```python Python SDK theme={null}
  prompts = sdk.llm.prompts.list()

  for prompt in prompts.data:
      print(prompt.name, f"v{prompt.active_version}")
  ```

  ```bash bash theme={null}
  curl "https://apigw.mka1.com/api/v1/llm/prompts?limit=10&order=desc" \
    --header 'Authorization: Bearer <mka1-api-key>' \
    --header 'X-On-Behalf-Of: <end-user-id>'
  ```
</CodeGroup>

## Update prompt metadata

Update the name, description, or metadata of a prompt. To change the template,
create a new version instead.

<CodeGroup>
  ```bash CLI theme={null}
  mka1 llm prompts update \
    --id prompt_abc123 \
    --body '{
      "name": "welcome-greeting",
      "description": "Updated greeting for the welcome flow",
      "metadata": { "team": "onboarding", "reviewed": true }
    }'
  ```

  ```ts MKA1 SDK theme={null}
  const updated = await mka1.llm.prompts.update({
    id: promptId,
    requestBody: {
      name: 'welcome-greeting',
      description: 'Updated greeting for the welcome flow',
      metadata: { team: 'onboarding', reviewed: true },
    },
  }, { headers: { 'X-On-Behalf-Of': '<end-user-id>' } });
  ```

  ```csharp C# SDK theme={null}
  using MeetKai.MKA1;
  using MeetKai.MKA1.Types.Requests;

  var sdk = new SDK(
      bearerAuth: "Bearer <mka1-api-key>",
      serverUrl: "https://apigw.mka1.com"
  );

  var updated = await sdk.Llm.Prompts.UpdateAsync(
      id: promptId,
      body: new UpdatePromptRequestBody
      {
          Name = "welcome-greeting",
          Description = "Updated greeting for the welcome flow",
          Metadata = new Dictionary<string, object>
          {
              { "team", "onboarding" },
              { "reviewed", true },
          },
      }
  );
  ```

  ```python Python SDK theme={null}
  updated = sdk.llm.prompts.update(
      id=prompt_id,
      name="welcome-greeting",
      description="Updated greeting for the welcome flow",
      metadata={"team": "onboarding", "reviewed": True},
  )
  ```

  ```bash bash theme={null}
  curl "https://apigw.mka1.com/api/v1/llm/prompts/prompt_abc123" \
    --request PUT \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer <mka1-api-key>' \
    --header 'X-On-Behalf-Of: <end-user-id>' \
    --data '{
      "name": "welcome-greeting",
      "description": "Updated greeting for the welcome flow",
      "metadata": { "team": "onboarding", "reviewed": true }
    }'
  ```
</CodeGroup>

## Create a new version

Each template change creates a new version. The new version automatically becomes the active version.

<CodeGroup>
  ```bash CLI theme={null}
  mka1 llm prompts create-version \
    --id prompt_abc123 \
    --body '{
      "template": "Hi {{name}}! Welcome aboard at {{company}}. Your onboarding starts {{date}}."
    }'
  ```

  ```ts MKA1 SDK theme={null}
  const version = await mka1.llm.prompts.createVersion({
    id: promptId,
    requestBody: {
      template: 'Hi {{name}}! Welcome aboard at {{company}}. Your onboarding starts {{date}}.',
    },
  }, { headers: { 'X-On-Behalf-Of': '<end-user-id>' } });

  console.log(version.version);  // 2
  console.log(version.template); // The new template text
  ```

  ```csharp C# SDK theme={null}
  using MeetKai.MKA1;
  using MeetKai.MKA1.Types.Requests;

  var sdk = new SDK(
      bearerAuth: "Bearer <mka1-api-key>",
      serverUrl: "https://apigw.mka1.com"
  );

  var version = await sdk.Llm.Prompts.CreateVersionAsync(
      id: promptId,
      body: new CreatePromptVersionRequestBody
      {
          Template = "Hi {{name}}! Welcome aboard at {{company}}. Your onboarding starts {{date}}.",
      }
  );

  Console.WriteLine(version.CreateVersionResponse!.Version);  // 2
  Console.WriteLine(version.CreateVersionResponse!.Template); // The new template text
  ```

  ```python Python SDK theme={null}
  version = sdk.llm.prompts.create_version(
      id=prompt_id,
      template="Hi {{name}}! Welcome aboard at {{company}}. Your onboarding starts {{date}}.",
  )

  print(version.version)   # 2
  print(version.template)  # The new template text
  ```

  ```bash bash theme={null}
  curl "https://apigw.mka1.com/api/v1/llm/prompts/prompt_abc123/versions" \
    --request POST \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer <mka1-api-key>' \
    --header 'X-On-Behalf-Of: <end-user-id>' \
    --data '{
      "template": "Hi {{name}}! Welcome aboard at {{company}}. Your onboarding starts {{date}}."
    }'
  ```
</CodeGroup>

## View version history

List all versions of a prompt to see its full change history.

<CodeGroup>
  ```bash CLI theme={null}
  mka1 llm prompts list-versions --id prompt_abc123 --order desc
  ```

  ```ts MKA1 SDK theme={null}
  const versions = await mka1.llm.prompts.listVersions({
    id: promptId,
    order: 'desc',
  }, { headers: { 'X-On-Behalf-Of': '<end-user-id>' } });

  for (const v of versions.data) {
    console.log(`v${v.version}: ${v.template.slice(0, 50)}...`);
  }
  ```

  ```csharp C# SDK theme={null}
  using MeetKai.MKA1;
  using MeetKai.MKA1.Types.Requests;

  var sdk = new SDK(
      bearerAuth: "Bearer <mka1-api-key>",
      serverUrl: "https://apigw.mka1.com"
  );

  var versions = await sdk.Llm.Prompts.ListVersionsAsync(
      id: promptId,
      order: ListPromptVersionsOrder.Desc
  );

  foreach (var v in versions.ListVersionsResponse!.Data)
  {
      Console.WriteLine($"v{v.Version}: {v.Template.Substring(0, 50)}...");
  }
  ```

  ```python Python SDK theme={null}
  versions = sdk.llm.prompts.list_versions(id=prompt_id)

  for v in versions.data:
      print(f"v{v.version}: {v.template[:50]}...")
  ```

  ```bash bash theme={null}
  curl "https://apigw.mka1.com/api/v1/llm/prompts/prompt_abc123/versions?order=desc" \
    --header 'Authorization: Bearer <mka1-api-key>' \
    --header 'X-On-Behalf-Of: <end-user-id>'
  ```
</CodeGroup>

## Retrieve a specific version

Fetch a single version by its version number.

<CodeGroup>
  ```bash CLI theme={null}
  mka1 llm prompts get-version --id prompt_abc123 --version-param 1
  ```

  ```ts MKA1 SDK theme={null}
  const v1 = await mka1.llm.prompts.getVersion({
    id: promptId,
    version: 1,
  }, {
    headers: { 'X-On-Behalf-Of': '<end-user-id>' },
  });

  console.log(v1.template);
  ```

  ```csharp C# SDK theme={null}
  using MeetKai.MKA1;

  var sdk = new SDK(
      bearerAuth: "Bearer <mka1-api-key>",
      serverUrl: "https://apigw.mka1.com"
  );

  var v1 = await sdk.Llm.Prompts.GetVersionAsync(
      id: promptId,
      version: 1
  );

  Console.WriteLine(v1.CreateVersionResponse!.Template);
  ```

  ```python Python SDK theme={null}
  v1 = sdk.llm.prompts.get_version(id=prompt_id, version=1)

  print(v1.template)
  ```

  ```bash bash theme={null}
  curl "https://apigw.mka1.com/api/v1/llm/prompts/prompt_abc123/versions/1" \
    --header 'Authorization: Bearer <mka1-api-key>' \
    --header 'X-On-Behalf-Of: <end-user-id>'
  ```
</CodeGroup>

## Roll back to a previous version

Rollback sets an earlier version as the active version. All versions are preserved — rollback
does not delete newer versions, so you can always roll forward again.

<CodeGroup>
  ```bash CLI theme={null}
  # Currently on version 2, roll back to version 1
  mka1 llm prompts rollback --id prompt_abc123 --version-param 1
  ```

  ```ts MKA1 SDK theme={null}
  // Currently on version 2, roll back to version 1
  const rolledBack = await mka1.llm.prompts.rollback({
    id: promptId,
    requestBody: {
      version: 1,
    },
  }, { headers: { 'X-On-Behalf-Of': '<end-user-id>' } });

  console.log(rolledBack.activeVersion);  // 1
  console.log(rolledBack.latestVersion);  // 2 (still exists)
  ```

  ```csharp C# SDK theme={null}
  using MeetKai.MKA1;
  using MeetKai.MKA1.Types.Requests;

  var sdk = new SDK(
      bearerAuth: "Bearer <mka1-api-key>",
      serverUrl: "https://apigw.mka1.com"
  );

  // Currently on version 2, roll back to version 1
  var rolledBack = await sdk.Llm.Prompts.RollbackAsync(
      id: promptId,
      body: new RollbackPromptRequestBody { Version = 1 }
  );

  Console.WriteLine(rolledBack.UpdatePromptResponse!.ActiveVersion);  // 1
  Console.WriteLine(rolledBack.UpdatePromptResponse!.LatestVersion);  // 2 (still exists)
  ```

  ```python Python SDK theme={null}
  # Currently on version 2, roll back to version 1
  rolled_back = sdk.llm.prompts.rollback(id=prompt_id, version=1)

  print(rolled_back.active_version)  # 1
  print(rolled_back.latest_version)  # 2 (still exists)
  ```

  ```bash bash theme={null}
  curl "https://apigw.mka1.com/api/v1/llm/prompts/prompt_abc123/rollback" \
    --request POST \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer <mka1-api-key>' \
    --header 'X-On-Behalf-Of: <end-user-id>' \
    --data '{ "version": 1 }'
  ```
</CodeGroup>

## Delete a prompt

Deleting a prompt removes it and all of its versions permanently.

<CodeGroup>
  ```bash CLI theme={null}
  mka1 llm prompts delete --id prompt_abc123
  ```

  ```ts MKA1 SDK theme={null}
  const deleted = await mka1.llm.prompts.delete({
    id: promptId,
  }, {
    headers: { 'X-On-Behalf-Of': '<end-user-id>' },
  });

  console.log(deleted.deleted); // true
  ```

  ```csharp C# SDK theme={null}
  using MeetKai.MKA1;

  var sdk = new SDK(
      bearerAuth: "Bearer <mka1-api-key>",
      serverUrl: "https://apigw.mka1.com"
  );

  var deleted = await sdk.Llm.Prompts.DeleteAsync(id: promptId);

  Console.WriteLine(deleted.DeletePromptResponseValue!.Deleted); // True
  ```

  ```python Python SDK theme={null}
  deleted = sdk.llm.prompts.delete(id=prompt_id)

  print(deleted.deleted)  # True
  ```

  ```bash bash theme={null}
  curl "https://apigw.mka1.com/api/v1/llm/prompts/prompt_abc123" \
    --request DELETE \
    --header 'Authorization: Bearer <mka1-api-key>' \
    --header 'X-On-Behalf-Of: <end-user-id>'
  ```
</CodeGroup>

## Full example: versioning and rollback workflow

This example demonstrates the complete lifecycle — creating a prompt, iterating on the
template, reviewing history, and rolling back.

<CodeGroup>
  ```bash CLI theme={null}
  # 1. Create a prompt with the initial template
  mka1 llm prompts create \
    --body '{
      "name": "support-reply",
      "template": "Hi {{customer}}, thanks for contacting us about {{issue}}."
    }'
  # → { "id": "prompt_abc123", "active_version": 1, ... }

  # 2. Ship v2 with a friendlier tone
  mka1 llm prompts create-version \
    --id prompt_abc123 \
    --body '{
      "template": "Hey {{customer}}! We got your message about {{issue}} and are on it."
    }'

  # 3. Retrieve the prompt with rendered variables
  mka1 llm prompts get \
    --id prompt_abc123 \
    --variables '{"customer":"Alice","issue":"billing"}'

  # 4. Review version history
  mka1 llm prompts list-versions --id prompt_abc123 --order asc

  # 5. Roll back to v1
  mka1 llm prompts rollback --id prompt_abc123 --version-param 1

  # 6. Clean up
  mka1 llm prompts delete --id prompt_abc123
  ```

  ```ts MKA1 SDK theme={null}
  import { SDK } from '@meetkai/mka1';

  const mka1 = new SDK({
    bearerAuth: `Bearer ${YOUR_API_KEY}`,
  });

  const headers = { 'X-On-Behalf-Of': 'user-123' };

  // 1. Create a prompt with the initial template
  const prompt = await mka1.llm.prompts.create({
    name: 'support-reply',
    template: 'Hi {{customer}}, thanks for contacting us about {{issue}}.',
  }, { headers });

  console.log('Created:', prompt.id, 'v1');

  // 2. Ship v2 with a friendlier tone
  const v2 = await mka1.llm.prompts.createVersion({
    id: prompt.id,
    requestBody: {
      template: 'Hey {{customer}}! We got your message about {{issue}} and are on it.',
    },
  }, { headers });

  console.log('Created v2:', v2.version);

  // 3. Retrieve the prompt — active version is now v2
  const current = await mka1.llm.prompts.get({
    id: prompt.id,
    variables: JSON.stringify({ customer: 'Alice', issue: 'billing' }),
  }, { headers });

  console.log('Active:', current.renderedTemplate);
  // "Hey Alice! We got your message about billing and are on it."

  // 4. Review version history
  const history = await mka1.llm.prompts.listVersions({
    id: prompt.id,
    order: 'asc',
  }, { headers });

  for (const v of history.data) {
    console.log(`  v${v.version}: ${v.template}`);
  }

  // 5. Roll back to v1
  const rolledBack = await mka1.llm.prompts.rollback({
    id: prompt.id,
    requestBody: {
      version: 1,
    },
  }, { headers });

  console.log('Rolled back to v' + rolledBack.activeVersion);
  // active_version=1, latest_version=2

  // 6. Clean up
  await mka1.llm.prompts.delete({ id: prompt.id }, { headers });
  ```

  ```csharp C# SDK theme={null}
  using MeetKai.MKA1;
  using MeetKai.MKA1.Types.Components;
  using MeetKai.MKA1.Types.Requests;

  var sdk = new SDK(
      bearerAuth: "Bearer <mka1-api-key>",
      serverUrl: "https://apigw.mka1.com"
  );

  // 1. Create a prompt with the initial template
  var prompt = await sdk.Llm.Prompts.CreateAsync(
      new CreatePromptRequest
      {
          Name = "support-reply",
          Template = "Hi {{customer}}, thanks for contacting us about {{issue}}.",
      }
  );

  var promptId = prompt.CreatePromptResponseValue!.Id;
  Console.WriteLine($"Created: {promptId} v1");

  // 2. Ship v2 with a friendlier tone
  var v2 = await sdk.Llm.Prompts.CreateVersionAsync(
      id: promptId,
      body: new CreatePromptVersionRequestBody
      {
          Template = "Hey {{customer}}! We got your message about {{issue}} and are on it.",
      }
  );

  Console.WriteLine($"Created v2: {v2.CreateVersionResponse!.Version}");

  // 3. Retrieve the prompt with rendered variables
  var current = await sdk.Llm.Prompts.GetAsync(
      id: promptId,
      variables: "{\"customer\":\"Alice\",\"issue\":\"billing\"}"
  );

  Console.WriteLine($"Active: {current.GetPromptResponseValue!.RenderedTemplate}");

  // 4. Review version history
  var history = await sdk.Llm.Prompts.ListVersionsAsync(
      id: promptId,
      order: ListPromptVersionsOrder.Asc
  );

  foreach (var v in history.ListVersionsResponse!.Data)
  {
      Console.WriteLine($"  v{v.Version}: {v.Template}");
  }

  // 5. Roll back to v1
  var rolledBack = await sdk.Llm.Prompts.RollbackAsync(
      id: promptId,
      body: new RollbackPromptRequestBody { Version = 1 }
  );

  Console.WriteLine($"Rolled back to v{rolledBack.UpdatePromptResponse!.ActiveVersion}");

  // 6. Clean up
  await sdk.Llm.Prompts.DeleteAsync(id: promptId);
  ```

  ```python Python SDK theme={null}
  from mka1 import SDK

  sdk = SDK(bearer_auth="Bearer YOUR_API_KEY")

  # 1. Create a prompt with the initial template
  prompt = sdk.llm.prompts.create(
      name="support-reply",
      template="Hi {{customer}}, thanks for contacting us about {{issue}}.",
  )

  print("Created:", prompt.id, "v1")

  # 2. Ship v2 with a friendlier tone
  v2 = sdk.llm.prompts.create_version(
      id=prompt.id,
      template="Hey {{customer}}! We got your message about {{issue}} and are on it.",
  )

  print("Created v2:", v2.version)

  # 3. Retrieve the prompt — active version is now v2
  current = sdk.llm.prompts.get(
      id=prompt.id,
      variables='{"customer": "Alice", "issue": "billing"}',
  )

  print("Active:", current.rendered_template)
  # "Hey Alice! We got your message about billing and are on it."

  # 4. Review version history
  history = sdk.llm.prompts.list_versions(id=prompt.id)

  for v in history.data:
      print(f"  v{v.version}: {v.template}")

  # 5. Roll back to v1
  rolled_back = sdk.llm.prompts.rollback(id=prompt.id, version=1)

  print("Rolled back to v" + str(rolled_back.active_version))
  # active_version=1, latest_version=2

  # 6. Clean up
  sdk.llm.prompts.delete(id=prompt.id)
  ```

  ```bash bash theme={null}
  # 1. Create a prompt
  curl https://apigw.mka1.com/api/v1/llm/prompts \
    --request POST \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer <mka1-api-key>' \
    --header 'X-On-Behalf-Of: user-123' \
    --data '{
      "name": "support-reply",
      "template": "Hi {{customer}}, thanks for contacting us about {{issue}}."
    }'
  # → { "id": "prompt_abc123", "active_version": 1, ... }

  # 2. Create v2 with a friendlier tone
  curl https://apigw.mka1.com/api/v1/llm/prompts/prompt_abc123/versions \
    --request POST \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer <mka1-api-key>' \
    --header 'X-On-Behalf-Of: user-123' \
    --data '{
      "template": "Hey {{customer}}! We got your message about {{issue}} and are on it."
    }'

  # 3. Get the prompt with rendered variables
  curl "https://apigw.mka1.com/api/v1/llm/prompts/prompt_abc123?variables=%7B%22customer%22%3A%22Alice%22%2C%22issue%22%3A%22billing%22%7D" \
    --header 'Authorization: Bearer <mka1-api-key>' \
    --header 'X-On-Behalf-Of: user-123'

  # 4. View version history
  curl "https://apigw.mka1.com/api/v1/llm/prompts/prompt_abc123/versions?order=asc" \
    --header 'Authorization: Bearer <mka1-api-key>' \
    --header 'X-On-Behalf-Of: user-123'

  # 5. Roll back to v1
  curl https://apigw.mka1.com/api/v1/llm/prompts/prompt_abc123/rollback \
    --request POST \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer <mka1-api-key>' \
    --header 'X-On-Behalf-Of: user-123' \
    --data '{ "version": 1 }'

  # 6. Delete the prompt
  curl https://apigw.mka1.com/api/v1/llm/prompts/prompt_abc123 \
    --request DELETE \
    --header 'Authorization: Bearer <mka1-api-key>' \
    --header 'X-On-Behalf-Of: user-123'
  ```
</CodeGroup>

## Behavior details

| Aspect             | Detail                                                                                           |
| ------------------ | ------------------------------------------------------------------------------------------------ |
| Versioning         | Immutable — each template change creates a new version that cannot be modified                   |
| Active version     | New versions auto-activate; use rollback to switch to a different version                        |
| Rollback           | Non-destructive — sets `active_version` without deleting newer versions                          |
| Pagination         | Cursor-based for listing prompts — use `after` parameter with `first_id`/`last_id` from response |
| Template rendering | Server-side — pass `variables` query parameter; unmatched placeholders preserved                 |
| Ownership          | Per API key — prompts are isolated by authentication context                                     |
| Concurrency        | Conflict detection — concurrent version creation returns 409                                     |

## Next steps

* [Generate a response](/docs/generate-a-response) — use rendered prompts as input to the Responses API
* [Extract structured data](/docs/extract-structured-data) — combine prompts with structured extraction
* [Conversations](/docs/conversations) — manage multi-turn exchanges with versioned system prompts
