Table of Contents

Categories

Create a new Category

Legacy Newsletter

Request

1
curl -X POST https://api.sendgrid.com/api/newsletter/category/create.json -F category="Legacy Newsletter Category" -F api_user=SENDGRID_USERNAME -F api_key=SENDGRID_PASSWORD

Response

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

Marketing Campaigns

With marketing campaigns, categories are created when you create your campaign. Simply include the categories you require in the categories object as an array of strings.

Request

1
2
3
4
5
6
curl --request POST \
--url https://api.sendgrid.com/v3/campaigns \
--header 'accept: application/json' \
--header 'authorization: Bearer SENDGRID_API_KEY' \
--header 'content-type: application/json' \
--data '{"title":"Legacy Newsletter","subject":"subject from Legacy Newsletter","html_content":"html content from Legacy Newsletter", "plain_content":"text content from Legacy Newsletter", "categories": ["Legacy Newsletter Category"]}'

Response

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
  "id": 1,
  "title": "Legacy Newsletter",
  "ip_pool": "",
  "categories": [
    "legacy newsletter category"
  ],
  "plain_content": "",
  "html_content": "html content from Legacy Newsletter",
  "subject": "subject from Legacy Newsletter",
  "sender_id": null,
  "list_ids": [],
  "segment_ids": [],
  "suppression_group_id": null,
  "custom_unsubscribe_url": "",
  "status": "Draft"
}

Assign a Category to an Existing Marketing Email

This is achieved when you Create a new Category, there is no separate Marketing Campaigns API call required.

Remove specific Categories, or all Categories from a Marketing Email

There is no equivalent API call in Marketing Campaigns. You may remove categories directly in the SendGrid UI. Click on the campaign that you want to edit and click the x on the category label to remove it.

List all Categories

Legacy Newsletter

Request

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

Response

1
2
3
4
[
  { "category": "CATEGORY1" },
  { "category": "CATEGORY2" }
]

Marketing Campaigns

With Marketing Campaigns, categories are created when you create your campaign. Simply include the categories you require in the categories object as an array of strings.

Request

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

Response

1
2
3
4
[
  {"category": "CATEGORY1"},
  {"category": "CATEGORY2"}
]