> ## 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.

# Delete Lens

> Deletes a lens template

## Overview

This endpoint deletes a lens template, removing it from the list of available lens templates.

Note that deleting the lens template does not stop or delete any active lens sessions based on the template.

## Request

<ParamField body="lens_id" type="string" required>
  The unique lens ID to delete. This is returned when the lens template is created.
</ParamField>

## Response

<ResponseField name="is_valid" type="boolean">
  Whether the deletion was successful. Check this field to detect errors.
</ResponseField>

<ResponseField name="lens_id" type="string">
  The ID of the lens that was deleted (or attempted to delete).
</ResponseField>

<ResponseField name="errors" type="array">
  Array of error messages if the deletion failed.
</ResponseField>

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

  ```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/delete",
      headers={
          "Authorization": f"Bearer {api_key}",
          "Content-Type": "application/json"
      },
      json={
          "lens_id": "lns-test-lens-85c01267"
      }
  )

  result = response.json()

  if result.get("is_valid") == False:
      print(f"Error deleting lens: {result['errors']}")
  else:
      print(f"Lens deleted: {result['lens_id']}")
  ```

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

  const result = await response.json();

  if (result.is_valid === false) {
    console.error('Error:', result.errors);
  } else {
    console.log(`Lens deleted: ${result.lens_id}`);
  }
  ```
</RequestExample>

<ResponseExample>
  ```json 200 - Success theme={"system"}
  {
    "is_valid": true,
    "lens_id": "lns-test-lens-85c01267",
    "errors": []
  }
  ```

  ```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"
      }
    ]
  }
  ```

  ```json 500 - Missing lens_id field theme={"system"}
  Internal Server Error
  ```
</ResponseExample>
