Skip to main content

Comments & Favorites

Endpoints for adding comments to templates and managing favorites.

Comments

Users can add comments to templates for collaboration and discussion. Comments are threaded and support replies.

GET /api/templates/{id}/comments

Get all top-level comments for a template (replies accessed via comment endpoints).

Authentication: Required (session)

Pre-blocks: template.lookup(params.id)

Query Parameters:

ParameterTypeDescription
sortstringSort order (default: -createdAt)
limitintegerMaximum results to return

Response:

{
"_links": {
"self": { "href": "/api/templates/{id}/comments" }
},
"_embedded": {
"inf:comment": [
{
"id": "comment-123",
"templateId": "abc123",
"userId": "john",
"message": "This template looks great! Just a few suggestions...",
"parentId": null,
"createdAt": "2024-01-15T10:30:00Z",
"updatedAt": "2024-01-15T10:30:00Z",
"_embedded": {
"inf:user": {
"username": "john",
"displayName": "John Doe",
"email": "john@example.com",
"_links": {
"self": { "href": "/api/users/john" }
}
}
},
"_links": {
"self": { "href": "/api/comments/comment-123" },
"inf:comments": { "href": "/api/comments/comment-123/replies" }
}
}
]
},
"start": 0,
"count": 1,
"total": 1
}

POST /api/templates/{id}/comments

Add a comment to a template.

Authentication: Required (session)

Pre-blocks: template.lookup(params.id)

Request Body:

FieldTypeRequiredDescription
messagestringYesComment text

Example Request:

{
"message": "Great template! Could we add a chart showing trends?"
}

Response:

Returns the created comment object with 201 Created status and Location header.

{
"id": "comment-456",
"templateId": "abc123",
"userId": "jane",
"message": "Great template! Could we add a chart showing trends?",
"parentId": null,
"createdAt": "2024-01-15T14:22:00Z",
"updatedAt": "2024-01-15T14:22:00Z",
"_links": {
"self": { "href": "/api/comments/comment-456" }
}
}

Side Effects:

  • Creates activity log entry for template comment
  • Notifies template owner and other participants

Favorites

Users can mark templates as favorites for quick access.

GET /api/templates/{id}/favorite

Check if the current user has favorited this template.

Authentication: Required (session)

Pre-blocks: template.lookup(params.id)

Response:

{
"templateId": "abc123",
"userId": "john",
"createdAt": "2024-01-15T10:30:00Z"
}

Error Response:

Returns 404 Not Found if template is not favorited by current user.


PUT /api/templates/{id}/favorite

Add template to current user's favorites.

Authentication: Required (session)

Pre-blocks: template.lookup(params.id)

Response:

Returns the created favorite object.

{
"templateId": "abc123",
"userId": "john",
"createdAt": "2024-01-15T10:30:00Z"
}

DELETE /api/templates/{id}/favorite

Remove template from current user's favorites.

Authentication: Required (session)

Pre-blocks: template.lookup(params.id)

Response:

Returns 204 No Content on successful deletion.


User Settings

Templates support per-user settings for customizing the editing experience.

GET /api/templates/{id}/settings

Get the current user's settings for this template.

Authentication: Required (session)

Pre-blocks: template.lookup(params.id)

Response:

{
"settings": {
"editorTheme": "dark",
"autoSave": true,
"showLineNumbers": true
},
"_links": {
"self": { "href": "/api/templates/abc123/settings" },
"inf:restore": { "href": "/api/templates/abc123/settings/_restore" }
}
}

Returns empty object {} if no settings exist for this user.


PUT /api/templates/{id}/settings

Update the current user's settings for this template.

Authentication: Required (session)

Pre-blocks: template.lookup(params.id)

Request Body:

Object containing user-specific settings.

Example Request:

{
"editorTheme": "light",
"autoSave": false,
"fontSize": 14
}

Response:

Returns the updated settings object.


POST /api/templates/{id}/settings/_restore

Restore template settings to defaults by deleting user-specific settings.

Authentication: Required (session)

Pre-blocks: template.lookup(params.id)

Response:

Returns 204 No Content on successful deletion of user settings.