{"record":{"id":"31dab6ed4c5d1202","repo":"payloadcms/payload","slug":"missing-required-data-31dab6","errorCode":null,"errorMessage":"Missing required data.","messagePattern":"Missing required data\\.","errorType":"exception","errorClass":"APIError","httpStatus":400,"severity":"error","filePath":"packages/payload/src/auth/operations/verifyEmail.ts","lineNumber":25,"sourceCode":"import { appendNonTrashedFilter } from '../../utilities/appendNonTrashedFilter.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\n\nexport type Args = {\n  collection: Collection\n  req: PayloadRequest\n  token: string\n}\n\nexport const verifyEmailOperation = async (args: Args): Promise<boolean> => {\n  const { collection, req, token } = args\n\n  if (collection.config.auth.disableLocalStrategy) {\n    throw new Forbidden(req.t)\n  }\n  if (!Object.prototype.hasOwnProperty.call(args, 'token')) {\n    throw new APIError('Missing required data.', httpStatus.BAD_REQUEST)\n  }\n\n  try {\n    const shouldCommit = await initTransaction(req)\n\n    const where = appendNonTrashedFilter({\n      enableTrash: Boolean(collection.config.trash),\n      trash: false,\n      where: {\n        _verificationToken: { equals: token },\n      },\n    })\n\n    const user = await req.payload.db.findOne<any>({\n      collection: collection.config.slug,\n      req,\n      where,\n    })","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/payload/src/auth/operations/verifyEmail.ts#L7-L43","documentation":"Thrown in `verifyEmailOperation` when `args` does not have its own `token` property (`!Object.prototype.hasOwnProperty.call(args, 'token')`). The verification token from the email link is mandatory. `APIError` with HTTP 400 (BAD_REQUEST).","triggerScenarios":"The verify endpoint is hit without a token path/param (e.g. `GET /api/<collection>/verify/` with no token segment, or a Local API call with `args` missing `token`); the route param failed to bind to `args.token`.","commonSituations":"Email link truncated/dropped the token; a custom route forwards the request without extracting the token param; the token is passed as `data` instead of as the top-level `token` arg.","solutions":["Pass the token from the email link as the `token` arg: `payload.verifyEmail({ collection, token, req })`.","Ensure the REST route includes the token segment and the handler binds it to `args.token`.","Validate presence before calling."],"exampleFix":"// before\nawait payload.verifyEmail({ collection, req })\n// after\nawait payload.verifyEmail({ collection, token, req })","handlingStrategy":"validation","validationCode":"// Ensure the token is present before verifying\nif (!token) {\n  throw new Error('Verification token is required')\n}\nawait payload.verifyEmail({ collection, token, req })","typeGuard":"function hasTokenArg(args: unknown): args is { token: string } {\n  return typeof args === 'object' && !!args\n    && Object.prototype.hasOwnProperty.call(args, 'token')\n    && typeof (args as { token: unknown }).token === 'string'\n}","tryCatchPattern":"try {\n  await payload.verifyEmail({ collection, token, req })\n} catch (e) {\n  if (e instanceof APIError && e.status === 400 && /Missing required data/.test(e.message)) {\n    // prompt user / re-request verification email\n  } else throw e\n}","preventionTips":["Pass the token from the email link as the `token` arg.","Ensure the REST route binds the token segment to `args.token`.","Validate presence before calling."],"tags":["auth","verify-email","validation","bad-request"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}