```html API Reference – Knowledge Base

API Reference

Authentication

POST /api/v1/auth/login

Obtain a JWT token for authorized requests.

{
  "email": "user@example.com",
  "password": "yourPassword"
}

Response:

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6..."
}

Headers: Content-Type: application/json

POST /api/v1/auth/register

Create a new user account.

{
  "name": "John Doe",
  "email": "john@example.com",
  "password": "StrongPass123"
}

Response:

{
  "id": "a1b2c3d4",
  "email": "john@example.com",
  "created_at": "2025-09-17T12:34:56Z"
}

Users

GET /api/v1/users

Retrieve a paginated list of users.

Query Parameters:

  • page – page number (default: 1)
  • limit – items per page (default: 20)

Response:

{
  "data": [
    {"id":"1","name":"Alice","email":"alice@example.com"},
    {"id":"2","name":"Bob","email":"bob@example.com"}
  ],
  "meta": {"page":1,"limit":20,"total":45}
}

Headers: Authorization: Bearer <token>

GET /api/v1/users/:id

Retrieve details for a specific user.

Response:

{
  "id":"1",
  "name":"Alice",
  "email":"alice@example.com",
  "created_at":"2025-08-01T09:15:00Z"
}
PUT /api/v1/users/:id

Update a user's profile.

{
  "name":"Alice Smith",
  "email":"alice.smith@example.com"
}

Response: 204 No Content

DELETE /api/v1/users/:id

Remove a user account.

Response: 204 No Content

Posts

GET /api/v1/posts

List public posts with optional filters.

Query Parameters:

  • tag – filter by tag
  • author_id – filter by author

Response:

{
  "data":[
    {"id":"p1","title":"First Post","author_id":"1"},
    {"id":"p2","title":"Another Post","author_id":"2"}
  ]
}
POST /api/v1/posts

Create a new post (authenticated).

{
  "title":"My New Post",
  "content":"Markdown **content** goes here...",
  "tags":["tech","api"]
}

Response:

{
  "id":"p123",
  "title":"My New Post",
  "created_at":"2025-09-17T13:00:00Z"
}

Error Codes

CodeDescription
400Bad Request – validation failed
401Unauthorized – missing/invalid token
403Forbidden – insufficient permissions
404Not Found – resource does not exist
500Internal Server Error
```