Skip to main content
This endpoint requires authentication. Requests without a valid session return 401 No autorizado.

Endpoint

POST /api/favoritos

Request body

recetaId
string
required
The UUID of the recipe to add to favorites.

Response

Returns a confirmation message on success.
message
string
Confirmation string. Value is "Añadido a favoritos" on success.

Error responses

StatusErrorDescription
401No autorizadoNo active session or invalid session token.
400Database error messageA Supabase insert error occurred. This includes cases where the recipe is already in the user’s favorites (unique constraint violation).
500Error internoAn unexpected server error occurred.
The favoritos table enforces uniqueness on the (usuario_id, receta_id) pair. Attempting to add a recipe that is already favorited returns a 400 with a database-level constraint error message.

Example request

curl --request POST \
  --url https://your-app.vercel.app/api/favoritos \
  --header 'Content-Type: application/json' \
  --header 'Cookie: sb-access-token=<your-session-token>' \
  --data '{
    "recetaId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
  }'

Example responses

201 Created
{
  "message": "Añadido a favoritos"
}
401 Unauthorized
{
  "error": "No autorizado"
}
400 Duplicate
{
  "error": "duplicate key value violates unique constraint \"favoritos_usuario_id_receta_id_key\""
}

Build docs developers (and LLMs) love