RocketChat/Rocket.Chat · error · Meteor.Error
error-param-required
error-param-required
Error message
The required "roomId" query param is missing
What it means
Thrown by GET chat.syncMessages when the required 'roomId' query parameter is missing. The endpoint also requires either 'type' or 'lastUpdate' (see error 364). roomId is checked first at chat.ts:716; without it the history/sync query cannot be scoped.
Source
Thrown at apps/meteor/server/api/v1/chat.ts:715
},
},
required: ['updated', 'deleted'],
additionalProperties: false,
},
success: { type: 'boolean', enum: [true] },
},
required: ['result', 'success'],
additionalProperties: false,
}),
400: validateBadRequestErrorResponse,
401: validateUnauthorizedErrorResponse,
},
},
async function action() {
const { roomId, lastUpdate, fromTs, count, next, previous, type } = this.queryParams;
if (!roomId) {
throw new Meteor.Error('error-param-required', 'The required "roomId" query param is missing');
}
if (!lastUpdate && !type) {
throw new Meteor.Error('error-param-required', 'The "type" or "lastUpdate" parameters must be provided');
}
if (lastUpdate && isNaN(Date.parse(lastUpdate))) {
throw new Meteor.Error('error-lastUpdate-param-invalid', 'The "lastUpdate" query parameter must be a valid date');
}
const getMessagesQuery = {
...(lastUpdate && { lastUpdate: new Date(lastUpdate) }),
...(fromTs && { fromTs: new Date(fromTs) }),
...(next && { next }),
...(previous && { previous }),
...(count && { count }),
...(type && { type }),
};View on GitHub (pinned to f9d3ec372b)
Solutions
- Append ?roomId=<GENERAL> to the GET chat.syncMessages URL.
- Also include either lastUpdate (ISO date) or type to satisfy error 364.
- Use the canonical room _id from rooms.info, not the room name.
Example fix
// before GET /api/v1/chat.syncMessages?rid=GENERAL // after GET /api/v1/chat.syncMessages?roomId=GENERAL&lastUpdate=2024-01-01T00:00:00Z
Defensive patterns
Strategy: validation
Validate before calling
function buildSyncUrl(roomId: string, opts: { lastUpdate?: string; type?: string }) {
if (!roomId) throw new Error('roomId query param is required for chat.syncMessages');
const u = new URL('/api/v1/chat.syncMessages', location.origin);
u.searchParams.set('roomId', roomId);
if (opts.lastUpdate) u.searchParams.set('lastUpdate', opts.lastUpdate);
else if (opts.type) u.searchParams.set('type', opts.type);
else throw new Error('either lastUpdate or type is required');
return u;
} Type guard
const hasRoomId = (q: Record<string, unknown>): q is { roomId: string } & Record<string, unknown> =>
typeof q.roomId === 'string' && q.roomId.length > 0; Try / catch
try {
await GET(buildSyncUrl(roomId, opts));
} catch (e) {
if ((e as any)?.error === 'error-param-required' && /roomId/.test(String((e as any)?.reason))) {
// roomId missing — fix caller before retry
}
throw e;
} Prevention
- Use URLSearchParams / a typed client so params land in the query string, not the body.
- Always pair roomId with lastUpdate or type.
- Reuse one URL-builder helper across sync calls.
When it happens
Trigger: GET /api/v1/chat.syncMessages without a roomId query string, or with roomId spelled 'rid'/'room'/'room_id'. Query params must be URL-encoded in the query string, not the JSON body.
Common situations: Confusing this GET endpoint with POST endpoints that take rid in the body; passing the room id as a path segment; SDK version that names the param differently.
Related errors
- error-lastUpdate-param-invalid
- error-updatedSince-param-invalid
- error-roomId-param-not-provided
- error-searchText-param-not-provided
- error-room-id-param-not-provided
AI-assisted analysis of RocketChat/Rocket.Chat@f9d3ec372b (2026-08-12).
Data as JSON: /api/errors/386267d8011e8749.
Report an issue: GitHub.