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

# Update Saved Search

> Update an existing saved search

## Path Parameters

<ParamField path="organizationId" type="string" required>
  Organization ID
</ParamField>

<ParamField path="projectId" type="string" required>
  Project ID
</ParamField>

<ParamField path="id" type="string" required>
  Saved search ID
</ParamField>

## Request Body

<ParamField body="name" type="string">
  Updated display name
</ParamField>

<ParamField body="description" type="string">
  Updated description
</ParamField>

<ParamField body="folderId" type="string">
  New parent folder ID (null for root level)
</ParamField>

<ParamField body="filter" type="object">
  Updated search filter criteria
</ParamField>

<ParamField body="sort" type="object[]">
  Updated sort criteria
</ParamField>

<Note>
  The saved search `type` cannot be changed after creation. To change the type, delete the saved search and create a new one.
</Note>

### Example Request

```json theme={null}
{
  "name": "Updated Name",
  "filter": {
    "type": {
      "in": ["image/jpeg", "image/png", "image/gif"]
    }
  }
}
```

## Response

Returns the updated SavedSearch object.

```json theme={null}
{
  "id": "ss123",
  "name": "Updated Name",
  "description": "Recently uploaded image assets",
  "type": "asset",
  "folderId": null,
  "filter": {
    "type": {
      "in": ["image/jpeg", "image/png", "image/gif"]
    },
    "createdAt": {
      "gte": "2024-03-01T00:00:00Z"
    }
  },
  "sort": [
    { "field": "createdAt", "order": "desc" }
  ],
  "favorites": ["user123"],
  "metadata": {
    "lastUsed": "2024-03-21T15:30:00Z",
    "useCount": 15
  },
  "createdAt": "2024-03-20T10:00:00Z",
  "updatedAt": "2024-03-22T14:00:00Z"
}
```

## Error Responses

### Saved Search Not Found

```json theme={null}
{
  "error": {
    "code": "NOT_FOUND",
    "message": "Saved search ss123 not found"
  }
}
```

## Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PUT "https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/saved-searches/ss123" \
    -H "Authorization: Bearer YOUR_JWT" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Updated Name",
      "filter": {
        "type": { "in": ["image/jpeg", "image/png", "image/gif"] }
      }
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/saved-searches/ss123',
    {
      method: 'PUT',
      headers: {
        'Authorization': 'Bearer YOUR_JWT',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        name: 'Updated Name',
        filter: {
          type: { in: ['image/jpeg', 'image/png', 'image/gif'] }
        }
      })
    }
  );

  const savedSearch = await response.json();
  console.log(`Updated saved search: ${savedSearch.name}`);
  ```

  ```swift Swift theme={null}
  var request = URLRequest(url: URL(string: "https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/saved-searches/ss123")!)
  request.httpMethod = "PUT"
  request.setValue("Bearer YOUR_JWT", forHTTPHeaderField: "Authorization")
  request.setValue("application/json", forHTTPHeaderField: "Content-Type")

  let body = ["name": "Updated Name"]
  request.httpBody = try JSONEncoder().encode(body)

  let (data, _) = try await URLSession.shared.data(for: request)
  ```

  ```kotlin Kotlin theme={null}
  val response = client.put("https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/saved-searches/ss123") {
      header("Authorization", "Bearer YOUR_JWT")
      contentType(ContentType.Application.Json)
      setBody(mapOf("name" to "Updated Name"))
  }
  ```
</CodeGroup>
