The JavaScript client and the REST API
The client is what the React, Vue and web component packages are built on. It has no dependencies, works in the browser, on a server and in an edge runtime, and is fully typed. Use it when you want to draw a page yourself, render a changelog on your server, or write a script.
Not using JavaScript? The REST endpoints at the end of this page are the whole contract. The package is in beta; see the SDKs overview for what you need first.
Install
npm install @decuga/clientCreate a client
import { DecugaClient } from '@decuga/client'
const decuga = new DecugaClient({ projectId: 'YOUR_PROJECT_ID' })
const { items, hasMore } = await decuga.changelog.page({ page: 0, size: 5 })| Option | Default | What it does |
|---|---|---|
projectId | required | Your project id. |
baseUrl | https://decuga.com | Where Decuga is served. Change it only for a test server. |
storage | "session" | Where a signed-in visitor and their votes are kept: "session" (until the tab closes), "local" (between visits), "memory", or your own object with getItem, setItem and removeItem. Falls back to memory when the browser refuses storage. |
fetch | global fetch | A fetch of your own: for a server without one, tests, or to add caching or tracing. |
timeoutMs | 20000 | Give up on a request after this long. |
session | none | Signs the customer in to the helpdesk with a session your own server asked Decuga for: the session object, or a function that fetches one. No emailed code, no sign-in step. See helpdesk auto-login. |
The client sends no cookies, and a plain read sends no custom header, so the browser does not need a pre-flight request to make it.
Changelog
| Call | Returns |
|---|---|
changelog.page({ page, size, signal }) | One page of published entries, newest first, with total and hasMore. size is 1 to 50 (default 5). |
changelog.get(entryId) | One published entry. |
changelog.entries() | An async iterator over every published entry, a page at a time. |
import { changelogEntryView, formatDate } from '@decuga/client'
for await (const entry of decuga.changelog.entries({ size: 20 })) {
const view = changelogEntryView(entry, 'en-GB')
// view.title, view.version, view.dateText, view.summary, view.sections: [{ key, label, items }]
}An entry is dated by when its sprint was completed or its release was released, not by when it was written. changelogEntryView gives you the date as text and as ISO, the summary, and only the sections that have something in them. parseChangelogContent reads the raw content and never throws: broken content comes back empty.
Roadmap
| Call | What it does |
|---|---|
roadmap.list() | The public items. hasVoted is true for the signed-in visitor's own votes (remembered in storage). |
roadmap.info() | The project name and the roadmap page's title and description. |
roadmap.requestCode(email) | Step 1 of signing in: emails the visitor a code. |
roadmap.verifyCode(email, code) | Step 2: checks the code and keeps the visitor signed in. |
roadmap.vote(itemId) / unvote(itemId) | Votes, or takes the vote back. Voting twice is harmless. Needs a signed-in visitor. |
roadmap.submitRequest({ title, description }) | Suggests a feature. It waits in your roadmap inbox for review and is not shown until you publish it. Signing in is optional. |
roadmap.session / onSessionChange(fn) / signOut() | The signed-in visitor, a way to follow sign-ins and sign-outs, and a way to sign out. |
await decuga.roadmap.requestCode('[email protected]')
await decuga.roadmap.verifyCode('[email protected]', '123456')
const items = await decuga.roadmap.list()
const updated = await decuga.roadmap.vote(items[0].id) // updated.hasVoted === truegroupRoadmap(items) groups items by status, most voted first, and quarterLabel('2026-Q4') gives "Q4 2026".
Helpdesk
| Call | What it does |
|---|---|
helpdesk.settings() | The portal's name, logo and welcome text. |
helpdesk.forms() | The forms the visitor can use (public forms, or all active forms once signed in), with fields in order. |
helpdesk.submitTicket(request) | Sends a request. Works without signing in; when signed in, it is linked to the customer and their company. |
helpdesk.sendCode(email) / verifyCode(email, code) | Sign in with an emailed code. The session is kept in storage. Not used when your site gives the client a session, and refused then. |
helpdesk.start() / hosted | When the client was given a session, start() gets it (calling your function if there is one) and hosted is true: there is no sign-in or sign-out, and sendCode is refused. The session is kept in memory only. |
helpdesk.myTickets() / companyTickets() | The signed-in customer's requests, or those of their company. |
helpdesk.ticket(id) | One request with its replies and attachments. |
helpdesk.comment(id, body) | Adds a reply. Plain text is fine. |
helpdesk.uploadAttachment(id, file) / downloadAttachment(id, attachmentId) | Attach a file (up to 25 MB, five per request) or fetch one as a Blob. |
import { validateTicket, buildTicketRequest } from '@decuga/client'
const [form] = await decuga.helpdesk.forms()
const input = { email: '[email protected]', description: 'The export button does nothing.', fields: { [form.fields[0].id]: 'Safari' } }
const errors = validateTicket(form, input) // {} when fine, otherwise { email, description, <fieldId>: message }
if (!Object.keys(errors).length) {
const ticket = await decuga.helpdesk.submitTicket(buildTicketRequest(form, input))
console.log(ticket.ticketNumber)
}validateTicket checks what the portal checks: a description, a valid email, each required field, email and number fields, a choice from a select's options, and at most 20 people to notify. buildTicketRequest uses the form's name as the title when none is given and leaves out the priority when the form does not let customers choose one.
Signed in by your own site
If your app already signs the customer in, skip the emailed code: give the client a session that your server asked Decuga for. Pass the session object, or a function that fetches one. The function is better: the client calls it when it needs a session, shares one call between requests made at the same moment, and calls it again when the session is about to end or the server refuses it.
const decuga = new DecugaClient({
projectId: 'YOUR_PROJECT_ID',
session: () => fetch('/decuga-session', { method: 'POST', credentials: 'include' }).then(r => r.json()),
})
decuga.helpdesk.hosted // true: the site signs customers in
await decuga.helpdesk.start() // asks your function now, if you want the session before the first call
const mine = await decuga.helpdesk.myTickets()
const theirCompany = await decuga.helpdesk.companyTickets()// The whole answer of your server's call, as it came. It cannot be renewed: reload the page when it ends.
const decuga = new DecugaClient({ projectId: 'YOUR_PROJECT_ID', session: sessionFromYourServer })While a session is given, signOut() does nothing and sendCode and verifyCode are refused, because the site decides who is signed in. The session is kept in memory only. If the function fails, calls that need a session reject with session-expired, and public calls such as forms() still work. Your server makes the call to Decuga with a project API key that must never reach the browser: see the helpdesk auto-login guide.
Errors
Every failure is a DecugaError, so one catch is enough. It has a status, a message (the server's own words when it gave one) and a code:
| Code | Meaning |
|---|---|
network | No answer: offline, blocked, or timed out. status is 0. |
not-found | The project, item or page does not exist, or is not available on the project's plan. |
session-expired | The visitor has to sign in (again). The stored session has been cleared. With a session from your site, it could not be renewed: ask your server for a new one, or reload the page. |
rate-limited | Too many requests. Wait and try again. |
invalid | The server did not accept what was sent; the message says why. |
server | Any other error from the server. |
import { isDecugaError } from '@decuga/client'
try {
await decuga.roadmap.vote(itemId)
} catch (e) {
if (isDecugaError(e) && e.code === 'session-expired') showSignIn()
else throw e
}Pass an AbortSignal as signal to a read to cancel it. A cancelled call rejects with the browser's own AbortError, not a DecugaError.
On a server
The client needs only fetch, which Node 18 and newer, Deno, Bun and edge runtimes have. A server render is the way to get release notes into HTML that search engines read:
import { DecugaClient, changelogEntryView, escapeHtml } from '@decuga/client'
const decuga = new DecugaClient({ projectId: process.env.DECUGA_PROJECT_ID! })
const page = await decuga.changelog.page({ size: 10 })
const html = page.items.map(e => {
const v = changelogEntryView(e, 'en-US')
return `<article><h2>${escapeHtml(v.title)}</h2><time datetime="${v.dateIso}">${escapeHtml(v.dateText)}</time></article>`
}).join('') renderRichText(value), which sanitises it (in a browser) or reduces it to escaped text (where there is no DOM).REST endpoints
These are the public endpoints the client calls, on https://decuga.com. They need no API key. Send JSON with Content-Type: application/json. Reads of a project that does not exist, or is not on a plan that includes the page, answer 404. Replace {p} with your project id.
Changelog (Pro plan or higher)
| Method and path | Notes |
|---|---|
GET /api/changelog/{p}/page?page=0&size=5 | A page of published entries, newest first: items, page, size, total, hasMore, publishedTotal. |
GET /api/changelog/{p} | Every published entry, not paged. |
GET /api/changelog/{p}/{entryId} | One published entry. |
Roadmap (Pro plan or higher)
| Method and path | Notes |
|---|---|
GET /api/roadmap/{p} | Public items, most voted first. hasVoted is always false here: the server does not know who is asking. |
GET /api/public/projects/{p}/info | name, roadmapTitle, roadmapDescription. |
POST /api/roadmap/otp/request | Body { email, projectId }. Emails a code. 204. |
POST /api/roadmap/otp/verify | Body { email, otp, projectId }. Returns { voterToken, email }. |
POST /api/roadmap/{p}/{itemId}/vote | Header X-Voter-Token. Returns the item. Voting twice is harmless. |
DELETE /api/roadmap/{p}/{itemId}/vote | Header X-Voter-Token. Returns the item. |
POST /api/roadmap/{p}/request | Body { title, description }. Optional header X-Voter-Token. Waits in the roadmap inbox for review. |
Helpdesk portal (Business plan or higher)
| Method and path | Notes |
|---|---|
GET /api/portal/{p}/settings | Name, logo and welcome text. |
GET /api/portal/{p}/forms | Public forms; with a customer token, all active forms. |
POST /api/portal/{p}/auth/send-otp | Body { email }. |
POST /api/portal/{p}/auth/verify-otp | Body { email, otp }. Returns a session with a token. Send it as Authorization: Bearer. |
POST /api/portal/{p}/tickets | Body { formId, title, description, customerEmail, priority?, observers?, formData }. Works without a token. |
GET /api/portal/{p}/my-tickets | Needs the token. Also /company-tickets. |
GET /api/portal/{p}/tickets/{id} | Needs the token. The request with its replies and attachments. |
POST /api/portal/{p}/tickets/{id}/comments | Needs the token. Body { body }. |
POST /api/portal/{p}/tickets/{id}/attachments | Needs the token. multipart/form-data with a file field. |