RocketChat/Rocket.Chat · error · Error
Param must be an array
Error message
Param ${params.teams.key} must be an array What it means
Validation error from POST channels.create: the optional teams parameter was provided but is not an array. teams must be an array of team identifiers to add the new channel to; a single team ID string or an object fails this check (unlike the other messages, this one interpolates the key without quotes).
Solutions
- Wrap team IDs in an array: teams: ["teamId123"]
- Prefer the dedicated teamId parameter when creating a channel inside one team via the teams API semantics — check the endpoint docs for which is expected
- Omit teams when the channel should not belong to any team
Example fix
// before
{ "name": "dev-talk", "teams": "teamId123" }
// after
{ "name": "dev-talk", "teams": ["teamId123"] } Defensive patterns
Strategy: type-guard
Validate before calling
if (body.teams !== undefined && !Array.isArray(body.teams)) {
body.teams = [String(body.teams)];
} Type guard
const isTeamsArray = (t: unknown): t is string[] => t === undefined || Array.isArray(t);
Try / catch
try { await POST('/api/v1/channels.create', body); } catch (e) {
if (/teams.*must be an array/.test(e.message)) { /* wrap single ID in array, retry */ }
} Prevention
- Always wrap team IDs in an array even for a single team
- Do not confuse the teams array parameter with the singular teamId parameter
When it happens
Trigger: POST /api/v1/channels.create with teams: "teamId123" instead of teams: ["teamId123"], or teams: {teamId: true} from a checkbox-style form payload.
Common situations: Adding a channel to exactly one team and skipping the array wrapper; client serializers collapsing single-element arrays; confusing the teams array-of-IDs with the teamId single-ID parameter used for creating inside a team.
Related errors
- Param " " must be an object if provided
- Param " " must be an array if provided
- Param " " is required
- error-not-allowed
- error-room-archived
AI-assisted analysis of RocketChat/Rocket.Chat@e4b8178b20 (2026-08-18).
Data as JSON: /api/errors/2fd773dcd00a9dce.
Report an issue: GitHub.
Appendix: source
Thrown at apps/meteor/server/api/v1/channels.ts:1031
(teamId && team && !(await hasPermissionAsync(params.user.value, 'create-team-channel', team.roomId)))
) {
throw new Error('unauthorized');
}
if (!params.name?.value) {
throw new Error(`Param "${params.name?.key}" is required`);
}
if (params.members?.value && !Array.isArray(params.members.value)) {
throw new Error(`Param "${params.members.key}" must be an array if provided`);
}
if (params.customFields?.value && !(typeof params.customFields.value === 'object')) {
throw new Error(`Param "${params.customFields.key}" must be an object if provided`);
}
if (params.teams?.value && !Array.isArray(params.teams.value)) {
throw new Error(`Param ${params.teams.key} must be an array`);
}
}
async function createChannel(
userId: string,
params: {
name?: string;
members?: string[];
customFields?: Record<string, any>;
extraData?: Record<string, any>;
readOnly?: boolean;
excludeSelf?: boolean;
},
): Promise<{ channel: IRoom }> {
const readOnly = typeof params.readOnly !== 'undefined' ? params.readOnly : false;
const id = await createChannelMethod(
userId,
params.name || '',View on GitHub (pinned to e4b8178b20)