Skip to content
On this page

Custom Vendor

Usend is built upon a default vendor implementation, but it also provides the flexibility to customize and create your own vendor. This allows you to tailor the email sending functionality to meet your specific requirements. To create a custom vendor, follow these steps:

Steps to create a custom vendor

1. Clone the Usend repository

Be sure to have Git installed on your system. Then, clone the Usend repository using the following command:

git clone

2. Go to the vendor directory and install dependencies

Go to the vendor directory in the Usend repository and install the dependencies using the following command:

cd usend/vendor && npm install

3. Copy environment variables file and replace it

Now, inside the vendor directory, copy the .env.example file to .env:

cp .env.example .env

And replace the USEND_VENDOR_API_KEY values with your own credential.


4. Deploy your custom vendor on Cloudflare Workers

To deploy your custom vendor on Cloudflare Workers, you need to have a Cloudflare account. Then, you can deploy your custom vendor using the following command:

npm run deploy

The command will prompt you to log in to Cloudflare to authenticate your account. Once executed successfully, it will output the URL of your custom vendor. You can use this URL to configure your Usend application.

Uploaded usend-vendor (1.92 sec)
Published usend-vendor (4.08 sec)
Current Deployment ID: yyyyyyyyyyyyyyyyyyyyyyyyyyy

5. Update the Domain Lockdown™ TXT record

Update the Domain Lockdown™ TXT record in your DNS settings provider with the following details:

Content TXT v=mc1

Don't forget to replace with your domain name and the value xxxxx with your own Cloudflare ID.

6. Configure your application

To configure your application to use your custom vendor, you need to update the vendor configuration setting in Usend constructor. Before doing so, make sure that the USEND_VENDOR_URL and USEND_VENDOR_API_KEY variables are up-to-date in your .env file. You can accomplish this by adding the following code to your Usend application:

import { Usend } from "usend-email";

const usend = new Usend({
  vendorUrl: process.env.USEND_VENDOR_URL, // or ""
  vendorApiKey: process.env.USEND_VENDOR_API_KEY, // or "..."

(async () => {
  await usend.sendEmail({
    from: "[email protected]",
    to: "[email protected]",
    subject: "Hello from Usend",
    html: "<h1>It works!</h1>",

Enjoy it! 🎉

By leveraging the capability to create a custom vendor, you have the freedom to tailor Usend according to your unique requirements and integrate it seamlessly into your existing email infrastructure. Enjoy the flexibility and power of Usend's custom vendor functionality.