Skip to contentSkip to navigationSkip to topbar
On this page

Create 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".

(information)

Info

You can create a maximum of 1000 lists.


POST/v3/marketing/lists

Base url: https://api.sendgrid.com (The Twilio SendGrid v3 API)

This endpoint creates a new contacts list.

Once you create a list, you can use the UI to trigger an automation every time you add a new contact to the list.

A link to the newly created object is in _metadata.


Authentication

authentication page anchor
Property nameTypeRequiredDescription
Authorizationstringrequired
Default: Bearer <<YOUR_API_KEY_HERE>>
Encoding type:application/json
SchemaExample
Property nameTypeRequiredDescriptionChild properties
namestringrequired

Your name for your list

Min length: 1Max length: 100
200400
SchemaExample
Property nameTypeRequiredDescriptionChild properties
idstring

The generated ID for your list.

Min length: 36Max length: 36

namestring

The name you gave your list.


contact_countinteger

The number of contacts currently stored on the list.


_metadataobject
Create ListLink to code sample: Create List
1
const client = require('@sendgrid/client');
2
client.setApiKey(process.env.SENDGRID_API_KEY);
3
4
const data = {
5
"name": "list-name"
6
};
7
8
const request = {
9
url: `/v3/marketing/lists`,
10
method: 'POST',
11
body: data
12
}
13
14
client.request(request)
15
.then(([response, body]) => {
16
console.log(response.statusCode);
17
console.log(response.body);
18
})
19
.catch(error => {
20
console.error(error);
21
});