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

# Toggle Favorite

> Toggle favorite status for a saved search

Toggles the favorite status of a saved search for the current user. If the search is already favorited, it will be unfavorited, *and* vice versa.

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

## Response

```json theme={null}
{
  "data": {
    "id": "ss123",
    "favorited": true
  }
}
```

When unfavoriting:

```json theme={null}
{
  "data": {
    "id": "ss123",
    "favorited": false
  }
}
```

## Error Responses

### Saved Search Not Found

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

## Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/saved-searches/ss123/favorite" \
    -H "Authorization: Bearer YOUR_JWT"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/saved-searches/ss123/favorite',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_JWT'
      }
    }
  );

  const { data } = await response.json();
  console.log(`Saved search ${data.id} is ${data.favorited ? 'now' : 'no longer'} a favorite`);
  ```

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

  let (data, _) = try await URLSession.shared.data(for: request)
  let result = try JSONDecoder().decode(FavoriteResponse.self, from: data)
  print("Favorited: \(result.favorited)")
  ```

  ```kotlin Kotlin theme={null}
  val response = client.post("https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/saved-searches/ss123/favorite") {
      header("Authorization", "Bearer YOUR_JWT")
  }

  val result = response.body<FavoriteResponse>()
  println("Favorited: ${result.favorited}")
  ```
</CodeGroup>
