X Enterprises
fastify-xemail

lists-delete

Delete a SendGrid Marketing contact list by ID.

deleteList

Delete a contact list from SendGrid Marketing by list ID. Returns true if the deletion was accepted (status 200, 202, or 204).

Note: Deleting a list does not delete the contacts in it. Contacts remain in your SendGrid account unless separately deleted.

Signature

fastify.xEmail.deleteList(listId: string): Promise<boolean>

Params

NameTypeRequiredDescription
listIdstringYesSendGrid list ID to delete.

Returns

Promise<boolean>true if SendGrid returned status 200, 202, or 204.

Throws

  • [xEmail] 'listId' (string) is required for deleteList().
  • [xEmail] Failed to delete list: <reason> — SendGrid API error.

Examples

Basic — delete a list by ID

fastify.delete("/admin/email-lists/:id", async (request) => {
  const deleted = await fastify.xEmail.deleteList(request.params.id);
  return { deleted };
});

Realistic — delete old campaign lists after archiving

fastify.post("/campaigns/:id/archive", async (request) => {
  const campaign = await db.campaigns.findById(request.params.id);

  if (campaign.listId) {
    await fastify.xEmail.deleteList(campaign.listId);
  }

  await db.campaigns.archive(campaign.id);

  return { archived: true };
});

See Also

AI Context

package: "@xenterprises/fastify-xemail"
method: fastify.xEmail.listsDelete(listId)
use-when: Delete a SendGrid Marketing contact list by ID (does not delete the contacts)
params: listId (string)
returns: Promise<void>
Copyright © 2026