Skip to main content
Glama

create_campaign

Create email campaigns for newsletters with customizable content, sender selection, and recipient targeting using Liquid templates.

Instructions

Create a new email campaign. Does NOT send it — use send_campaign after.

The body supports Liquid templates: {{ contact.first_name }}, {{ contact.email }}.

Args: subject: Email subject line. text_body: Email body content (markdown by default). sender_id: Sender ID to send from (e.g. "ms_12345"). Use list_senders to find IDs. settings_type: Content type — "markdown", "text", "mjml", or "block" (default: "markdown"). segment_id: Optional segment ID to restrict recipients (e.g. "sgm_12345"). preview_text: Optional preview text shown in email clients.

Returns: The created campaign record.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
subjectYes
text_bodyYes
sender_idYes
settings_typeNomarkdown
segment_idNo
preview_textNo

Implementation Reference

  • mcp_server.py:125-146 (registration)
    The tool 'create_campaign' is registered here using @mcp.tool(). It acts as a wrapper that calls the underlying _client.create_campaign method.
    @mcp.tool()
    def create_campaign(subject: str, text_body: str, sender_id: str,
                        settings_type: str = "markdown", segment_id: str | None = None,
                        preview_text: str | None = None) -> dict:
        """
        Create a new email campaign. Does NOT send it — use send_campaign after.
    
        The body supports Liquid templates: {{ contact.first_name }}, {{ contact.email }}.
    
        Args:
            subject: Email subject line.
            text_body: Email body content (markdown by default).
            sender_id: Sender ID to send from (e.g. "ms_12345"). Use list_senders to find IDs.
            settings_type: Content type — "markdown", "text", "mjml", or "block" (default: "markdown").
            segment_id: Optional segment ID to restrict recipients (e.g. "sgm_12345").
            preview_text: Optional preview text shown in email clients.
    
        Returns:
            The created campaign record.
        """
        return _client.create_campaign(subject=subject, text_body=text_body, sender_id=sender_id,
                                       settings_type=settings_type, segment_id=segment_id, preview_text=preview_text)
  • The actual implementation of create_campaign, which prepares the request data for the API.
    def create_campaign(self, subject: str, text_body: str, sender_id: str,
                        settings_type: str = "markdown", segment_id: str | None = None,
                        preview_text: str | None = None, data: dict | None = None) -> dict:
        """Create a new campaign."""
        campaign_data = {
            "subject": subject,
            "text_body": text_body,
            "sender_id": sender_id,
            "settings": {"type": settings_type},
        }
        if segment_id:
            campaign_data["segment_id"] = segment_id
        if preview_text:
            campaign_data["preview_text"] = preview_text
        if data:
            campaign_data["data"] = data
        resp = self.session.post(f"{self.url}/api/v1/campaigns", json={"data": campaign_data}, headers=self._headers(), timeout=30)
        resp.raise_for_status()

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/gwbischof/keila-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server