Skip to main content
POST
/
interests
Create Interest
curl --request POST \
  --url https://api.example.com/interests \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>"
}
'
{
  "success": [
    {}
  ]
}

Endpoint

POST /interests

Description

Creates a new interest in the MayTravel system. Once created, this interest can be associated with user profiles to personalize their travel experience.

Request

Headers

Content-Type: application/json

Body Parameters

name
string
required
The name of the interest to create. This should be a descriptive name that users can easily understand.

Request Example

{
  "name": "Scuba Diving"
}

Response

success
array
Array containing the result of the creation operation. The response format is database-specific.

Success Response (201 Created)

The interest has been successfully created in the database.
[]
The response returns an empty array on successful creation. This is the standard response from the PostgreSQL database when using INSERT operations.

Error Response (500 Internal Server Error)

{
  "error": "Duplicate interest name"
}
{
  "error": "name is required"
}

Code Examples

const response = await fetch('http://your-api-base-url.com/interests', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: 'Scuba Diving'
  })
});

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

Validation

  • The name field is required in the request body
  • Interest names should be unique in the database
  • Empty or null names will result in an error

Notes

  • The API returns a 201 status code on successful creation
  • Duplicate interest names may cause database constraint errors
  • The response array is empty on success due to the nature of the INSERT operation

Build docs developers (and LLMs) love