---
title: "Toggle Favorite"
method: POST
path: "/api/favorites/toggle"
tags: ["Favorites"]
---

# Toggle Favorite

`POST /api/favorites/toggle`

## Request

- Base URL: `https://pegarex.com.br` (the document declares no server; this is the origin it was published from)
- URL: `https://pegarex.com.br/api/favorites/toggle`
- Auth: HTTP bearer

Toggle favorite by external_id (which is the car_listings.id at favorite-time).

On add: snapshot the current car_listings row into the favorites row.
On remove: simple delete.

## Request body

- FavoriteCarRequest
  - `car` CarData, required
    - `external_id` string, required
    - `source` string, required
    - `title` string, required
    - `price` number, nullable
    - `brand` string, nullable
    - `model` string, nullable
    - `year` union
      - string
      - integer
    - `km` union
      - string
      - integer
    - `location` string, nullable
    - `image_url` string, nullable
    - `link` string, nullable
    - `fuel` string, nullable
    - `transmission` string, nullable
  - `notes` string, nullable

## Response `200`

Successful Response

- unknown

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/pegarex/apis/pegarex-api.md) · [All operations](https://skmtc.dev/pegarex/apis/pegarex-api/llms.txt) · [OpenAPI document](https://skmtc.dev/pegarex/apis/pegarex-api/revisions/8c789c9bd72d?raw)
