Comment on a ticket
POST /tickets/{ticketId}/comments posts a comment, and GET on the same path lists the
ticket’s comments, oldest first. Posting needs Board — read & write access.
// Comment on a ticket, then read the ticket's comments back.//// node comment.ts <ticketId>import { createClient } from './saw.ts';
const ticketId = process.argv[2];if (!ticketId) throw new Error('Usage: node comment.ts <ticketId>');
const saw = createClient();
const comment = await saw.post('/tickets/{ticketId}/comments', { path: { ticketId }, body: { body: 'Posted by the comment recipe through the SAW API.' },});console.log(`Posted comment ${comment.id}.`);
const comments = await saw.get('/tickets/{ticketId}/comments', { path: { ticketId } });console.log(`The ticket has ${comments.length} comment(s):`);for (const c of comments) console.log(` ${c.createdAt} ${c.body}`);
if (!comments.some((c) => c.id === comment.id)) throw new Error('The new comment is missing from the list.');SAW_API_KEY=saw_live_… node --experimental-strip-types comment.ts <ticketId>Things to know
Section titled “Things to know”- Replies.
parentCommentIdreplies to a comment, one level deep. - Polling. Pass the newest
createdAtyou have seen assince(ISO 8601). Only comments created strictly after it are returned. - Author. A comment posted with an API key is attributed to the key. The key can edit
(
PATCH) and delete (DELETE …/comments/{commentId}) only its own comments.