This document outlines the available endpoints for the User API.
Base URL: http://localhost:3000
Fetches a list of all users.
- Method:
GET - URL:
/api/users - Request Body: None
[
{
"id": 1,
"name": "Alice",
"created_at": "2025-10-06T20:06:28.000Z"
},
{
"id": 2,
"name": "Bob",
"created_at": "2025-10-06T20:06:28.000Z"
}
]Adds a new user to the database.
- Method:
POST - URL:
/api/users - Request Body: None
[
{
"name": "Charlie"
},
{
"id": 3,
"name": "Charlie",
"created_at": "2025-10-06T20:06:28.000Z"
},
][
{
"error": "Name is required"
}
]Fetches a single user by their unique ID.
- Method:
GET - URL:
/api/users/:id(e.g., /api/users/1) - Request Body: None
[
{
"id": 1,
"name": "Alice",
"created_at": "2025-10-06T20:06:28.000Z"
}
][
{
"error": "User not found"
}
]Updates the name of a specific user.
- Method:
PATCH - URL:
/api/users/:id(e.g., /api/users/1) - Request Body: None
[
{
"id": 1,
"name": "Alice Smith",
"created_at": "2025-10-06T20:06:28.000Z"
},
][
{
"error": "User not found"
}
]Permanently deletes a user from the database.
- Method:
DELETE - URL:
/api/users/:id(e.g., /api/users/1) - Request Body: None
[
{
"error": "User not found"
}
]