Campaigns (BETA)

Use the campaigns tool to campaigns to create, manage, and report on a single marketing campaign using multiple assets in one place. For example, you can create a campaign using marketing emails and social posts and raise awareness of a new product or an event. To use the campaigns tool and its corresponding endpoints, you'll need a Marketing Hub Professional or Enterprise subscription. 

You can use campaign endpoints to create, read, update, and delete marketing campaign data. For example, you can use these endpoints to create and manage HubSpot campaigns from your external applications. You can also transfer campaign data to external data warehouses for analytics.

You can also create, read, update, and delete multiple campaigns with the associated batch endpoints, click the Endpoints tab at the top of this article for a full list of endpoints and the associated parameters available.

Scope requirements

The following scopes are required to use the campaigns API, based on the endpoints you're using:

  • marketing.campaigns.read: provides access to view details about marketing campaigns and their associated assets.
  • marketing.campaigns.write: grants access to create, delete, and modify marketing campaigns.
  • marketing.campaigns.revenue.read: provides access to view revenue details and deal amounts attributed to a marketing campaign.

Create a campaign

To create a campaign, make a POST request to /marketing/v3/campaigns.

Create a campaign with the given properties and return the campaign object, including the campaignGuid and created properties. For example, to create a new campaign, you would make a POST request with the following request body.  

//Example create request body { "properties": { "hs_name": "Inbound", "hs_start_date": "2024-10-30", "hs_notes": "Campaign notes" } }

The response will include a campaignGuid, a unique identifier for the campaign. This will be formatted as a UUID. In the following example, the campaignGuid is edb9b6c3-d2e2-4ca8-8396-832262aed0d4.

//Example create response body {   "id": "edb9b6c3-d2e2-4ca8-8396-832262aed0d4",   "properties": {     "hs_name": "Inbound",     "hs_start_date": "2024-10-30",     "hs_notes": "Campaign notes"   },   "createdAt": "2024-10-30T03:30:17.883Z",   "updatedAt": "2024-12-07T16:50:06.678Z" }

Retrieve a campaign

To retrieve the details of an existing campaign, make a GET request to /marketing/v3/campaigns/{campaignGuid}.

This endpoint will return the campaign information. Depending on the query parameters used, this can also be used to return information about the assets and the corresponding assets' metrics. When using this endpoint, you can use the following query parameters. 

  • properties: a comma-separated list of the properties to be returned in the response. For example, hs_name, hs_campaign_status, hs_notes. If any of the specified properties has an empty value on the requested object, it will be ignored and not returned in response. If the parameter is empty, the response will include an empty properties map.
  • startDate: the start date to fetch asset metrics, formatted as YYYY-MM-DD. This is used to fetch the metrics associated with the assets for a specified period.  If no date is specified, no asset metrics will be retrieved.    
  • endDate: the end date to fetch asset metrics, formatted as YYYY-MM-DD. This is used to fetch the metrics associated with the assets for a specified period. If no date is specified, no asset metrics will be retrieved.

For example, if you made a POST request with /marketing/v3/campaigns/edb9b6c3-d2e2-4ca8-8396-832262aed0d4?properties=hs_name,hs_start_date, this would result in the following response body:

//Example get response body { "id": "edb9b6c3-d2e2-4ca8-8396-832262aed0d4", "properties": { "hs_name": "Inbound", "hs_start_date": "2024-10-30", }, "assets": { "EMAIL": { "paging": { "next": { "link": "?after=NTI1Cg%3D%3D", "after": "NTI1Cg%3D%3D" }, "results": [ { "id": "832", "name": "My email" } ] } } }, "createdAt": "2024-10-30T03:30:17.883Z", "updatedAt": "2024-12-07T16:50:06.678Z" }

List assets

To retrieve the assets associated with a campaign make a GET request to /marketing/v3/campaigns/{campaignId}/assets/{assetType}.

This endpoint lists all assets of the campaign by asset type. The assetType parameter is required, and each request can only fetch assets of a single type. The following are required:

  • campaignGuid: the UUID of the campaign.
  • assetType: the type of asset to be fetched.

You can use the following query parameters with the endpoint:

  • after: a cursor for pagination. If provided, the results will start after the given cursor. For example, you can use the value NTI1Cg%3D%3D.  
  • limit: define the maximum number of results to return. The allowed values range from 1 to 100. If no limit is specified, it will be set to 10 assets by default.
  • startDate: the start date to fetch asset metrics, formatted as YYYY-MM-DD. This is used to fetch the metrics associated with the assets for a specified period. If no date is specified, no asset metrics will be retrieved.   
  • endDate: the end date to fetch asset metrics, formatted as YYYY-MM-DD. This is used to fetch the metrics associated with the assets for a specified period. If no date is specified, no asset metrics will be retrieved.

The following is a list of available asset types and metrics related to the assets that are returned in response.:

Asset Asset type Metrics
Ad campaigns AD_CAMPAIGN CLICKS, CONTACTS, and COST
Blog posts BLOG_POST CONTACTS_FIRST_TOUCH, CONTACTS_LAST_TOUCH, SUBMISSIONS, and VIEWS
Social posts SOCIAL_BROADCAST FACEBOOK_CLICKS, LINKEDIN_CLICKS, and TWITTER_CLICKS
CTAs WEB_INTERACTIVE CLICKS and VIEWS
CTAs (Legacy) CTA CLICKS, SUBMISSIONS, and VIEWS
External website pages EXTERNAL_WEB_URL VIEWS
Forms FORM CONVERSION_RATE, SUBMISSIONS, and VIEWS
Landing pages LANDING_PAGE CONTACTS_FIRST_TOUCH, CONTACTS_LAST_TOUCH, CUSTOMERS, SUBMISSIONS, and VIEWS
Emails MARKETING_EMAIL CLICKS, OPEN, and SENT
Marketing events MARKETING_EVENT ATTENDEES, CANCELLATIONS, and REGISTRATIONS
Static lists OBJECT_LIST CONTACTS
Website pages SITE_PAGE CONTACTS_FIRST_TOUCH, CONTACTS_LAST_TOUCH, CUSTOMERS, SUBMISSIONS, and VIEWS.
Workflows AUTOMATION_PLATFORM_FLOW CURRENTLY_ENROLLED and STARTED
Marketing SMS MARKETING_SMS SENT, DELIVERED, and UNIQUE_CLICKS

Manage asset associations

To associate an asset with a campaign make a PUT request to /marketing/v3/campaigns/{campaignGuid}/assets/{assetType}/{assetId}.

To remove an asset from a campaign make a DELETE request to /marketing/v3/campaigns/{campaignGuid}/assets/{assetType}/{assetId}.

You can use the endpoints above to create and remove associations for the following asset types. For other asset types, learn how to associate assets and content with a campaign in HubSpot.   

  • FORM
  • OBJECT_LIST
  • EXTERNAL_WEB_URL

Update campaign

To perform a partial update of a campaign identified by the specified campaignGuid, make a PATCH request to /marketing/v3/campaigns/{campaignGuid}.

You can use the following properties to update your campaign. The provided property values will be overwritten. If your request includes read-only or non-existent properties, you will encounter a 400 error. Learn more about which properties can be used. 

//Example update request { "properties": { "hs_name": "Inbound 2024", } }
//Example update response { "id": "edb9b6c3-d2e2-4ca8-8396-832262aed0d4", "properties": { "hs_name": "Inbound 2024", }, "createdAt": "2024-10-30T03:30:17.883Z", "updatedAt": "2024-12-07T16:50:06.678Z" }

Delete a campaign

To delete a campaign, make a DELETE request to /marketing/v3/campaigns?.

This call will always return a 204 No Content response, regardless of whether the campaignGuid provided corresponds to an existing campaign or not.

Search for campaigns

To search for campaigns based on query parameters, make a GET request to /marketing/v3/campaigns/{campaignGuid}.

When using this endpoint, you can use the following query parameters. 

  • name: return all campaigns whose names contain the specified substring. This allows partial matching of campaign names, returning all campaigns that include the given substring in their name. If this parameter is not provided, the search will return all campaigns.
  • sort: the field by which to sort the results. Allowed values are hs_name, createdAt, updatedAt. An optional '-' before the property name will denote descending order. For example, you can use -CREATED_AT to sort your campaigns from newest to oldest. If this is not specified, the list of campaigns will be sorted in alphabetical order by campaign name.  
  • after: a cursor for pagination. If provided, the results will start after the given cursor. For example, you can use the value NTI1Cg%3D%3D.  
  • limit: define the maximum number of results to return. The allowed values range from 1 to 100. If no limit is specified, it will be set to 50 campaigns by default. 
  • properties: a comma-separated list of the properties to be returned in the response. For example, hs_name, hs_campaign_status, hs_notes. If any of the specified properties has an empty value on the requested object, it will be ignored and not returned in response. If the parameter is empty, the response will include an empty properties map.
//Example reponse body // for GET request to https://api.hubapi.com/marketing/v3/campaigns?properties=hs_name&limit=2 { "total": 14, "results": [ { "id": "972e2774-7409-43c2-a8b9-581732dff5a7", "properties": { "hs_name": "Inbound 2023" }, "createdAt": "2023-09-07T10:18:06.320Z", "updatedAt": "2023-09-07T10:18:06.320Z" }, { "id": "703bc2f0-f000-4840-b6ae-b2d74bc09fa0", "properties": { "hs_name": "Inbound 2024" }, "createdAt": "2024-06-25T10:57:26.232Z", "updatedAt": "2024-06-25T10:57:26.232Z" } ], "paging": { "next": { "after": "Mg%3D%3D", "link": "https://api.hubspotqa.com/marketing/v3/campaigns? properties=hs_name&limit=2&after=Mg%3D%3D" } } }

Campaign properties

When using the properties query parameter for your campaign endpoints, you can use the following properties:

Property Name Read Only Format Description
hs_name read & write string The campaign's name. This should be unique, with a max size of 256 characters.
hs_start_date read & write date (YYYY-MM-DD) The campaign's start date.
hs_end_date read & write date (YYYY-MM-DD) The campaign's end date.
hs_notes read & write string Any notes about the campaign.
hs_audience read & write string The campaign's audience.
hs_goal read & write string The campaign's goal.
hs_currency_code read & write ISO currency code The currency code used for the campaign.
hs_campaign_status read & write predefined values The status of the campaign. This includes planned, in_progress, active, paused, and completed.
hs_owner read user id The user id of the user that owns the campaign
hs_color_hex read color id The color of the campaign in hex color code.
hs_created_by_user_id read user id The user id of the user that originally created the campaign
hs_object_id read string The internal CRM object id.
hs_budget_items_sum_amount read monetary value The sum of all budget items. Learn more about managing your campaign budget.
hs_spend_items_sum_amount read monetary value The sum of all spend items. Learn more about managing your campaign budget.

Was this article helpful?
This form is used for documentation feedback only. Learn how to get help with HubSpot.