Table of Contents

Create a new Recipient List

Legacy Newsletter

Request

1
curl -X POST https://api.sendgrid.com/api/newsletter/lists/add.json -F api_user=SENDGRID_USERNAME -F api_key=SENDGRID_PASSWORD -F 'list=my_list'

Response

1
2
3
{
  "message": "success"
}

Marketing Campaigns

Request

1
2
3
4
5
6
curl --request POST \
--url https://api.sendgrid.com/v3/contactdb/lists \
--header 'accept: application/json' \
--header 'authorization: Bearer SENDGRID_API_KEY' \
--header 'content-type: application/json' \
--data '{"name":"My List"}'

Response

1
2
3
4
5
{
  "id": 1,
  "name": "My List",
  "recipient_count": 0
}

Rename a Recipient List

Legacy Newsletter

Request

1
curl -X POST https://api.sendgrid.com/api/newsletter/lists/edit.json -F api_user=SENDGRID_USERNAME -F api_key=SENDGRID_PASSWORD -F 'list=my_list' -F 'newlist=my_new_list'

Response

1
2
3
{
  "message": "success"
}

Marketing Campaigns

First, we get the list id:

Request

1
2
3
4
5
curl --request GET \
--url https://api.sendgrid.com/v3/contactdb/lists \
--header 'accept: application/json' \
--header 'authorization: Bearer SENDGRID_API_KEY' \
--header 'content-type: application/json'

Response

1
2
3
4
5
6
7
8
9
{
  "lists": [
    {
      "id": 1,
      "name": "My List",
      "recipient_count": 0
    }
  ]
}

Now we can edit the list name:

Request

1
2
3
4
5
6
curl --request PATCH \
--url https://api.sendgrid.com/v3/contactdb/lists/{list_id} \
--header 'accept: application/json' \
--header 'authorization: Bearer SENDGRID_API_KEY' \
--header 'content-type: application/json' \
--data '{"name":"My NEW List"}'

Response

1
2
3
4
5
{
"id": 1,
"name": "My NEW List",
"recipient_count": 1234
}

List all Recipient Lists on your account, or check if a particular Recipient List exists

Legacy Newsletter

Request

1
curl -X POST https://api.sendgrid.com/api/newsletter/lists/get.json -F api_user=SENDGRID_USERNAME -F api_key=SENDGRID_PASSWORD

Response

1
2
3
4
5
6
[
  {
    "id": 1,
    "list": "my_list"
  }
]

Marketing Campaigns

Request

1
2
3
4
5
curl --request GET \
--url https://api.sendgrid.com/v3/contactdb/lists \
--header 'accept: application/json' \
--header 'authorization: Bearer SENDGRID_API_KEY' \
--header 'content-type: application/json'

Response

1
2
3
4
5
6
7
8
9
{
  "lists": [
    {
      "id": 1,
      "name": "My List",
      "recipient_count": 0
    }
  ]
}

Remove a Recipient List from your account

Legacy Newsletter

Request

1
curl -X POST https://api.sendgrid.com/api/newsletter/lists/delete.json -F api_user=SENDGRID_USERNAME -F api_key=SENDGRID_PASSWORD -F 'list=my_list'

Response

1
2
3
{
  "message": "success"
}

Marketing Campaigns

First, we get the list id:

Request

1
2
3
4
5
curl --request GET \
--url https://api.sendgrid.com/v3/contactdb/lists \
--header 'accept: application/json' \
--header 'authorization: Bearer SENDGRID_API_KEY' \
--header 'content-type: application/json'

Response

1
2
3
4
5
6
7
8
9
{
  "lists": [
    {
      "id": 1,
      "name": "My List",
      "recipient_count": 0
    }
  ]
}

Request

1
2
3
4
5
curl --request DELETE \
--url https://api.sendgrid.com/v3/contactdb/lists/{list_id} \
--header 'accept: application/json' \
--header 'authorization: Bearer SENDGRID_API_KEY' \
--header 'content-type: application/json'

Response

1
HTTP/1.1 202