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

# Modify Lens

> Modifies an existing lens template

## Overview

This endpoint modifies an existing lens template, overwriting any previous settings of that template.

Only lens templates that are modifiable can be modified. Developers can check if a lens template is modifiable via the `/lens/metadata` API (look for `lens_modifiable: true`).

## Request Body

<ParamField body="lens_id" type="string" required>
  The ID of the lens to modify (must be a modifiable lens)
</ParamField>

<ParamField body="lens_name" type="string">
  Updated name for the lens
</ParamField>

<ParamField body="lens_config" type="object">
  Updated configuration for the lens

  <Expandable title="properties">
    <ParamField body="model_pipeline" type="array">
      Updated model pipeline configuration
    </ParamField>

    <ParamField body="model_parameters" type="object">
      Updated model parameters
    </ParamField>
  </Expandable>
</ParamField>

## Response

<ResponseField name="lens_id" type="string">
  ID of the modified lens
</ResponseField>

<ResponseField name="lens_name" type="string">
  Updated name of the lens
</ResponseField>

<ResponseField name="lens_modifiable" type="boolean">
  Whether the lens can be further modified
</ResponseField>

<ResponseField name="lens_status" type="string">
  Current status of the lens
</ResponseField>

<ResponseField name="lens_config" type="object">
  Updated lens configuration
</ResponseField>

<RequestExample>
  ```bash cURL theme={"system"}
  curl -X POST https://api.u1.archetypeai.app/v0.5/lens/modify \
    -H "Authorization: Bearer $ATAI_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "lens_id": "lns-test-lens-b2ba0058",
      "lens_name": "Updated Lens Name"
    }'
  ```

  ```python Python theme={"system"}
  import requests
  import os

  api_key = os.environ.get("ATAI_API_KEY")

  response = requests.post(
      "https://api.u1.archetypeai.app/v0.5/lens/modify",
      headers={
          "Authorization": f"Bearer {api_key}",
          "Content-Type": "application/json"
      },
      json={
          "lens_id": "lns-test-lens-b2ba0058",
          "lens_name": "Updated Lens Name"
      }
  )

  result = response.json()

  if result.get("lens_name"):
      print(f"Lens modified: {result['lens_id']}")
  else:
      print("Modification may have failed")
  ```

  ```javascript JavaScript theme={"system"}
  const response = await fetch(
    "https://api.u1.archetypeai.app/v0.5/lens/modify",
    {
      method: "POST",
      headers: {
        Authorization: `Bearer ${process.env.ATAI_API_KEY}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        lens_id: "lns-test-lens-b2ba0058",
        lens_name: "Updated Lens Name",
      }),
    }
  );

  const result = await response.json();

  if (result.lens_name) {
    console.log(`Lens modified: ${result.lens_id}`);
  } else {
    console.log("Modification may have failed");
  }
  ```
</RequestExample>

<ResponseExample>
  ```json 200 - OK theme={"system"}
  {
    "lens_id": "lns-test-lens-b2ba0058",
    "lens_name": "Updated Lens Name",
    "lens_status": "LENS_STATUS_MOUNTED",
    "lens_modifiable": true,
    "lens_config": {
      "model_pipeline": [
        {
          "processor_name": "lens_noop_processor",
          "processor_config": {}
        }
      ]
    }
  }
  ```

  ```json 422 - Missing required field: lens_id theme={"system"}
  {
    "errors": [
      {
        "code": "missing_lens_id",
        "message": "Missing required field: lens_id.",
        "suggestion": "Include the 'lens_id' field in the request payload.",
        "error_uid": "err-xxxxxxxx"
      }
    ]
  }
  ```

  ```json 404 - Lens not found theme={"system"}
  {
    "errors": [
      {
        "code": "lens_not_found",
        "message": "The specified lens was not found.",
        "suggestion": "Verify the lens identifier and ensure it exists before retrying.",
        "error_uid": "err-xxxxxxxx"
      }
    ]
  }
  ```

  ```json 403 - Lens is non-modifiable theme={"system"}
  {
    "errors": [
      {
        "code": "lens_not_modifiable",
        "message": "The specified lens is non-modifiable.",
        "suggestion": "Check whether the lens is modifiable before attempting modifications.",
        "error_uid": "err-xxxxxxxx"
      }
    ]
  }
  ```

  ```json 401 - Unauthorized theme={"system"}
  {
    "errors": [
      {
        "code": "unauthorized_request",
        "message": "Unauthorized or invalid access.",
        "suggestion": "Provide valid authentication credentials and ensure they have the required permissions.",
        "error_uid": "err-xxxxxxxx"
      }
    ]
  }
  ```
</ResponseExample>
