You are viewing the Legacy Marketing Campaigns API reference. For guidance migrating to the current version of Marketing Campaigns, see Migrating from Legacy Marketing Campaigns
For the most up-to-date information on the Sender Identities API, please visit the new Marketing Campaigns Single Sends API.
The Campaigns API allows you to create and manage marketing campaigns. You can create campaigns, manage campaign content, and schedule campaigns to be sent at a later time.
This endpoint allows you to create a campaign.
In order to send or schedule the campaign, you will be required to provide a subject, sender ID, content (we suggest both html and plain text), and at least one list or segment ID. This information is not required when you create a campaign.
Bearer <<YOUR_API_KEY_HERE>>
Optional
The on-behalf-of
header allows you to make API calls from a parent account on behalf of the parent's Subusers or customer accounts. You will use the parent account's API key when using this header. When making a call on behalf of a customer account, the property value should be "account-id" followed by the customer account's ID (e.g., on-behalf-of: account-id <account-id>
). When making a call on behalf of a Subuser, the property value should be the Subuser's username (e.g., on-behalf-of: <subuser-username>
). See On Behalf Of for more information.
application/json
The display title of your campaign. This will be viewable by you in the Marketing Campaigns UI.
Optional
The subject of your campaign that your recipients will see.
Optional
The ID of the "sender" identity that you have created. Your recipients will see this as the "from" on your marketing emails.
Optional
The IDs of the lists you are sending this campaign to. You can have both segment IDs and list IDs
Optional
The segment IDs that you are sending this list to. You can have both segment IDs and list IDs. Segments are limited to 10 segment IDs.
Optional
The categories you would like associated to this campaign.
Optional
The suppression group that this marketing email belongs to, allowing recipients to opt-out of emails of this type.
Optional
This is the url of the custom unsubscribe page that you provide for customers to unsubscribe from your suppression groups.
Optional
The pool of IPs that you would like to send this email from.
Optional
The HTML of your marketing email.
Optional
The plain text content of your emails.
Optional
The editor used in the UI.
code
design
The display title of your campaign. This will be viewable by you in the Marketing Campaigns UI.
The subject of your campaign that your recipients will see.
The ID of the "sender" identity that you have created. Your recipients will see this as the "from" on your marketing emails.
The IDs of the lists you are sending this campaign to. You can have both segment IDs and list IDs
The segment IDs that you are sending this list to. You can have both segment IDs and list IDs. Segments are limited to 10 segment IDs.
The categories you would like associated to this campaign.
The suppression group that this marketing email belongs to, allowing recipients to opt-out of emails of this type.
This is the url of the custom unsubscribe page that you provide for customers to unsubscribe from your suppression groups.
The pool of IPs that you would like to send this email from.
The HTML of your marketing email.
The plain text content of your emails.
The editor used in the UI.
code
design
The status of your campaign.
1const client = require("@sendgrid/client");2client.setApiKey(process.env.SENDGRID_API_KEY);34const data = {5id: 986724,6title: "May Newsletter",7subject: "New Products for Summer!",8sender_id: 124451,9list_ids: [110, 124],10segment_ids: [110],11categories: ["summer line"],12suppression_group_id: 42,13custom_unsubscribe_url: "",14ip_pool: "marketing",15html_content:16"<html><head><title></title></head><body><p>Check out our summer line!</p></body></html>",17plain_content: "Check out our summer line!",18status: "Draft",19};2021const request = {22url: `/v3/campaigns`,23method: "POST",24body: data,25};2627client28.request(request)29.then(([response, body]) => {30console.log(response.statusCode);31console.log(response.body);32})33.catch((error) => {34console.error(error);35});