Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Delete a list



API Overview

api-overview page anchor

Lists are static collections of Marketing Campaigns contacts. This API allows you to interact with the list objects themselves. To add contacts to a list, you must use the Contacts API.

You can also manage your lists using the Contacts menu in the Marketing Campaigns UI(link takes you to an external page). For more information about lists and best practices for building them, see "Building your Contact List".


DELETE/v3/marketing/lists/{id}

Base url: https://api.sendgrid.com

This endpoint allows you to deletes a specific list.

Optionally, you can also delete contacts associated to the list. The query parameter, delete_contacts=true, will delete the list and start an asynchronous job to delete associated contacts.


Authentication

authentication page anchor
Property nameTypeRequiredDescription
Authorizationstringrequired
Default: Bearer <<YOUR_API_KEY_HERE>>
Property nameTypeRequiredDescription
idstringrequired

The ID of the list on which you want to perform the operation.

Property nameTypeRequiredDescription
delete_contactsbooleanOptional

Flag indicates that all contacts on the list are also to be deleted.

Default: false
200204404

The delete has been accepted and is processing.

SchemaExample
Property nameTypeRequiredDescriptionChild properties
job_idstring

job_id of the async job

Delete a list

delete-a-list page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
curl

_19
const client = require('@sendgrid/client');
_19
client.setApiKey(process.env.SENDGRID_API_KEY);
_19
_19
const id = "ZGkrHSypTsudrGkmdpJJ";
_19
_19
const request = {
_19
url: `/v3/marketing/lists/${id}`,
_19
method: 'DELETE',
_19
_19
}
_19
_19
client.request(request)
_19
.then(([response, body]) => {
_19
console.log(response.statusCode);
_19
console.log(response.body);
_19
})
_19
.catch(error => {
_19
console.error(error);
_19
});


Rate this page: