With the Campaign API you can create and manage email marketing campaigns for a Wix site, including composing content, publishing to contacts, and tracking engagement statistics.
With the Campaign API, you can:
Use Create Campaign to create a new draft campaign from editor data. Pass the composerDataJson field with the campaign's content and set campaignEditorType to match the format you're using.
The composerDataJson field supports three formats, determined by campaignEditorType:
WEB: Wix proprietary JSON format for the classic drag-and-drop editor.MOBILE: A subset of the WEB format for the classic mobile editor.MJML: MJML markup wrapped in a JSON object under key "mjml".Passing a format that doesn't match the specified campaignEditorType doesn't return an immediate error, but causes the campaign to fail silently when previewing or sending. MJML is the most straightforward format to generate programmatically.
You can also set an optional emailPreheader when creating or updating a campaign. This is short preview text shown after the subject line in many email clients and can improve open rates.
After creating a campaign, you can update its content with Update Composer or render a preview with Preview Campaign.
The campaignEditorType can't be changed after a campaign is created. Passing a composerDataJson in a different format when calling Update Composer causes a silent failure when sending or previewing.
If your campaign content contains dynamic placeholders for personalization, pass a placeholders map to Preview Campaign to resolve those tokens in the preview. Set default placeholder values in composer.defaultValues to use as fallbacks when actual recipient values aren't available.
To retrieve a campaign's subject line, use Get Composer. The emailSubject field on the Campaign object is deprecated.
To publish a campaign, sender details must be set up for the site. Call Identify Sender Address to determine which email address will appear as the "From" address.
Call Publish Campaign to send the campaign:
emailDistributionOptions to distribute the campaign by email to contacts. Campaigns can only be sent to Wix site contacts, defined by contact IDs, contact labels, or segment IDs.emailDistributionOptions to publish the campaign as a landing page only, without sending any emails. This decision is permanent — once published as a landing page only, the campaign can't be sent by email. Use Reuse Campaign to create a new draft copy if you need to send emails later.The response always includes a landingPageUrl that can be shared on social media, regardless of whether emails are sent.
You can schedule a campaign to send at a future time by passing emailDistributionOptions.sendAt. The scheduled time must be at least 30 minutes in the future. Use Pause Scheduling and Reschedule to adjust a scheduled campaign before it sends.
After publishing with email distribution, the campaign moves through the following distributionStatus values:
SAMPLING: A small subset of the audience receives the email first. The system checks for issues such as spam-trap hits or excessive bounce rates.SENDING: Sampling passed and the email is being sent to the full audience.DISTRIBUTED: The email has been sent to all recipients.TERMINATED: Sampling failed due to quality issues. The campaign is stopped before reaching the full audience. A terminated campaign can be reused with Reuse Campaign to create a new draft for republishing.REJECTED: The campaign was identified as abusive and blocked before sending.When a scheduled campaign is paused with Pause Scheduling, the original audience settings are preserved. Use Get Audience to retrieve those audience settings so you can pass them back when republishing the campaign.
Use Resend to Non-Openers to send a follow-up to recipients who didn't open the original campaign email. The following conditions must be met:
An optional different subject line can be passed to improve open rates on the follow-up.
It's important to note the following points before starting to code:
composerDataJson and the email subject.composerDataJson. Options are WEB, MOBILE, MJML.emailPreheader on Create Campaign or Update Composer.Last updated: 4 September 2026