QuantumNous/new-api · error · Error
Failed to create channel
Error message
Failed to create channel
What it means
Fallback thrown by the channels form mutation when createChannel(payload) responds with success falsy and no message. The admin API refused to create the channel; transformFormDataToCreatePayload built the body, but the server rejected it. onError shows the thrown message or, failing that, the same generic text via getErrorMessage.
Source
Thrown at web/src/features/channels/hooks/use-channel-mutate-form.ts:131
...payload,
key_mode: data.key_mode,
}
: payload
const response = await updateChannel(
props.currentRow.id,
payloadWithKeyMode
)
if (!response.success) {
throw new Error(response.message || t(ERROR_MESSAGES.UPDATE_FAILED))
}
return SUCCESS_MESSAGES.UPDATED
}
const payload = transformFormDataToCreatePayload(data)
const response = await createChannel(payload)
if (!response.success) {
throw new Error(response.message || t(ERROR_MESSAGES.CREATE_FAILED))
}
return SUCCESS_MESSAGES.CREATED
},
onSuccess: (messageKey) => {
toast.success(t(messageKey))
props.onSuccess()
},
onError: (error: unknown) => {
toast.error(getErrorMessage(error) || t(ERROR_MESSAGES.CREATE_FAILED))
},
})
}
View on GitHub (pinned to e2c7aa7b10)
Solutions
- Inspect the POST /api/channel response body for the server's specific message.
- Re-check required fields: name, type, key, base_url, models.
- Trim the API key and ensure multi-line keys match the server's expected multi-key format.
- Confirm the admin session is still valid (re-login) if the response is a 401-shaped envelope.
Defensive patterns
Strategy: try-catch
Validate before calling
const required = [data.name, data.type, data.key, data.base_url]
if (required.some((v) => !v || !String(v).trim())) {
toast.error('Fill all required fields: name, type, key, base URL')
return
} Type guard
const isCreateChannelPayload = (p: unknown): boolean =>
typeof p === 'object' && p !== null &&
typeof (p as { name?: unknown }).name === 'string' &&
(p as { name: string }).name.trim().length > 0 Try / catch
onError: (error: unknown) => {
toast.error(getErrorMessage(error) || t(ERROR_MESSAGES.CREATE_FAILED))
// keep the modal open with entered values for quick correction
} Prevention
- Validate required form fields client-side before POST
- Trim pasted API keys and normalize multi-key newlines
- Watch the POST /api/channel response body for the specific rejected field
When it happens
Trigger: POST /api/channel with a payload failing server validation; duplicate channel name/type constraint; invalid or empty multi-key input; non-admin session calling the admin route.
Common situations: First-time channel setup with a typo'd base_url or key; pasting a key with trailing whitespace/newlines the backend rejects; permission or login expired while the form was open.
Related errors
- Failed to update channel
- Failed to initialize OAuth
- Failed to start verification
- Passkey verification failed
- Failed to load API keys
AI-assisted analysis of QuantumNous/new-api@e2c7aa7b10 (2026-08-15).
Data as JSON: /api/errors/1ffd4f5fa213897f.
Report an issue: GitHub.