badges/shields · error · InvalidParameter
must use a monitor-specific api key
Error message
must use a monitor-specific api key
What it means
UptimeRobot's ensureIsMonitorApiKey throws InvalidParameter when the supplied key does not start with 'm'. UptimeRobot issues monitor-specific API keys prefixed with 'm' (e.g. m780550-...), while account-level keys look different; the badge requires the monitor-specific one. The check runs before the request in fetch().
Source
Thrown at services/uptimerobot/uptimerobot-base.js:45
monitors: Joi.array().length(1).items(monitor).required(),
}).required(),
)
const singleMonitorResponseWithUptime = Joi.alternatives(
errorResponse,
Joi.object({
stat: Joi.equal('ok').required(),
monitors: Joi.array().length(1).items(monitorWithUptime).required(),
}).required(),
)
export default class UptimeRobotBase extends BaseJsonService {
static category = 'monitoring'
static ensureIsMonitorApiKey(value) {
// A monitor API key must start with "m".
if (!value.startsWith('m')) {
throw new InvalidParameter({
prettyMessage: 'must use a monitor-specific api key',
})
}
}
async fetch({ monitorSpecificKey, numberOfDays }) {
this.constructor.ensureIsMonitorApiKey(monitorSpecificKey)
let opts, schema
if (numberOfDays) {
opts = { custom_uptime_ratios: numberOfDays }
schema = singleMonitorResponseWithUptime
} else {
opts = {}
schema = singleMonitorResponse
}
const { stat, error, monitors } = await this._requestJson({
schema,View on GitHub (pinned to 766fd8bc89)
Solutions
- In UptimeRobot, open the monitor's settings and copy the Monitor-specific API key (starts with 'm').
- Replace the account-level main API key in the badge URL with the monitor-specific key.
- Verify no string manipulation is stripping the leading 'm' from the key.
Example fix
// before ?apiKey=u695395-abc123... (account key) // after ?apiKey=m780550-def456... (monitor-specific key)
Defensive patterns
Strategy: validation
Validate before calling
if (!monitorSpecificKey || !monitorSpecificKey.startsWith('m')) throw new Error('monitor-specific API key (starting with m) required') Type guard
const isMonitorKey = (v) => typeof v === 'string' && v.startsWith('m') Try / catch
try { await fetchBadge() } catch (e) { if (e instanceof InvalidParameter) console.error('use the monitor-specific key'); throw e } Prevention
- Always use the per-monitor key (m-prefixed), never the account-level main key.
- Store keys with their prefix intact; avoid regex/format transformations on keys.
- Document in your badge config which key type each field expects.
When it happens
Trigger: Any uptimerobot badge (e.g. response/uptime for a number of days) with a monitorSpecificKey that does not begin with the character 'm', including missing keys where startsWith throws implicitly.
Common situations: Using the main account API key instead of the per-monitor key; copying the monitor id rather than the monitor API key; the key losing its leading 'm' through trimming or template interpolation.
Related errors
- invalid api key
- monitor API key is unvalid
- Invalid flags, must be one of: ${VALID_FLAGS}
- Invalid re2 regex: ${error.message}
- monitor API key is required
AI-assisted analysis of badges/shields@766fd8bc89 (2026-08-30).
Data as JSON: /api/errors/b273269312173fb0.
Report an issue: GitHub.