Can I access the payload object from a custom endpoint on a collection?

default discord avatar
3 months ago

Wanted to access the Payload object on a custom endpoint on a collection to send an email through Payload. Is this better suited for the local API?

  • default discord avatar
    3 months ago

    What do you mean exactly? The req should have payload object on it right? And in that case you would be able to us the local API to send the email

  • default discord avatar
    3 months ago

    Ah, for some reason I didn't realize the payload object is on the req!

    Thanks @jarrod69420

    For anyone who finds this, I did...

      endpoints: [
          path: "/verify",
          method: "post",
          handler: async (req, res, next) => {
            try {
              const msg: Message = {
                from: "",
                subject: "Example",
                html: `The id posted was ${}`,
              await req.payload.sendEmail(msg);
            } catch (error) {
                ok: false,
                error: "Error while sending verification email.",
Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!


Connect with the Payload Community on Discord



Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.