RocketChat/Rocket.Chat · error · Error
error-token-param-not-provided
Error message
error-token-param-not-provided
What it means
Thrown in the GET handler of 'livechat/messages.history/:rid' (message.ts:204-206) when the token query parameter is missing or falsy. Unlike POST/DELETE endpoints that read token from bodyParams, this GET endpoint reads from this.queryParams.token. The explicit check fires before findGuest is ever called.
Source
Thrown at apps/meteor/server/api/v1/omnichannel/message.ts:205
});
}
return API.v1.failure();
},
},
);
API.v1.addRoute(
'livechat/messages.history/:rid',
{ validateParams: isGETLivechatMessagesHistoryRidParams },
{
async get() {
const { offset } = await getPaginationItems(this.queryParams);
const { token } = this.queryParams;
const { rid } = this.urlParams;
if (!token) {
throw new Error('error-token-param-not-provided');
}
const guest = await findGuest(token);
if (!guest) {
throw new Error('invalid-token');
}
const room = await findRoom(token, rid);
if (!room) {
throw new Error('invalid-room');
}
let ls = undefined;
if (this.queryParams.ls) {
ls = new Date(this.queryParams.ls);
}
let end = undefined;View on GitHub (pinned to f9d3ec372b)
Solutions
- Add the token query parameter: GET /api/v1/livechat/messages.history/:rid?token=YOUR_VISITOR_TOKEN.
- Ensure the token is URL-encoded if it contains special characters.
- Verify your HTTP client attaches query params correctly for GET requests (not in the body).
Example fix
// before GET /api/v1/livechat/messages.history/abc123 // throws 'error-token-param-not-provided' // after GET /api/v1/livechat/messages.history/abc123?token=visitor-token-here
Defensive patterns
Strategy: validation
Validate before calling
// Ensure token is present before making the GET request
if (!token || token.trim() === '') {
throw new Error('token query parameter is required for messages.history');
}
const url = `/api/v1/livechat/messages.history/${rid}?token=${encodeURIComponent(token)}`; Try / catch
try {
const res = await fetch(`/livechat/messages.history/${rid}?token=${encodeURIComponent(token)}`);
} catch (err) {
if (err.message === 'error-token-param-not-provided') {
// ensure token is set and URL-encoded before retrying
if (!token) token = await getVisitorToken();
}
} Prevention
- Always construct GET request URLs with a URL builder that validates required query params.
- Write a client wrapper that enforces token presence for all livechat visitor endpoints.
- Use encodeURIComponent() on token values to avoid URL encoding issues.
When it happens
Trigger: Calling GET /api/v1/livechat/messages.history/:rid without a token query parameter, or with an empty string value. Example: GET /livechat/messages.history/abc123 with no ?token=... appended.
Common situations: Developer forgot to append the token query param for the GET request; client SDK bug that omits query params for GET; URL encoding issue stripping the param; testing without providing credentials; using a POST-style body for a GET request.
Related errors
AI-assisted analysis of RocketChat/Rocket.Chat@f9d3ec372b (2026-08-12).
Data as JSON: /api/errors/d9d8a4b2939f5bcc.
Report an issue: GitHub.