Skip to main content
DELETE
/
interests
/
{id}
Delete Interest
curl --request DELETE \
  --url https://api.example.com/interests/{id}
{
  "message": "<string>"
}

Endpoint

DELETE /interests/{id}

Description

Deletes an interest from the MayTravel system. This permanently removes the interest and may affect users who have this interest associated with their profiles.
Deleting an interest is a permanent action. Make sure to handle any foreign key constraints with user-interest associations before deleting.

Request

Path Parameters

id
integer
required
The unique identifier of the interest to delete

Headers

No special headers are required for this endpoint.

Response

message
string
A success message confirming the deletion

Success Response (200 OK)

{
  "message": "Interest ID 3 was eliminated succesfully"
}

Error Response (500 Internal Server Error)

{
  "error": "Interest not found"
}
{
  "error": "Cannot delete interest: foreign key constraint violation"
}
{
  "error": "Invalid interest ID"
}

Code Examples

const interestId = 3;

const response = await fetch(`http://your-api-base-url.com/interests/${interestId}`, {
  method: 'DELETE',
  headers: {
    'Content-Type': 'application/json'
  }
});

const result = await response.json();
console.log(result.message);

Validation

  • The id parameter must be a valid integer
  • The interest with the specified ID should exist in the database

Important Considerations

Before deleting an interest, consider the following:
  • User Associations: If users have this interest linked to their profiles, you may need to remove those associations first
  • Data Integrity: Database foreign key constraints may prevent deletion if references exist
  • Permanent Action: Deleted interests cannot be recovered

Best Practices

  1. Check for Dependencies: Query for users associated with this interest before deletion
  2. Soft Delete Alternative: Consider implementing a soft delete (marking as inactive) instead of permanent deletion
  3. Audit Trail: Log interest deletions for auditing purposes
  4. User Notification: If this interest is widely used, consider notifying affected users

Notes

  • The deletion is permanent and cannot be undone
  • If the interest ID doesn’t exist, the operation will complete but no rows will be affected
  • Foreign key constraints in the database may prevent deletion if the interest is referenced elsewhere

Build docs developers (and LLMs) love