Skip to content

feat(emails): add POST /emails/schedule for programmatic campaign creation#310

Open
brayanjeshua wants to merge 1 commit into
GoHighLevel:mainfrom
brayanjeshua:feat/email-schedule-create-endpoint
Open

feat(emails): add POST /emails/schedule for programmatic campaign creation#310
brayanjeshua wants to merge 1 commit into
GoHighLevel:mainfrom
brayanjeshua:feat/email-schedule-create-endpoint

Conversation

@brayanjeshua

Copy link
Copy Markdown

Problem

Currently the Email Marketing API only exposes GET /emails/schedule (read campaigns) and POST /emails/builder (create templates). There is no endpoint to create or schedule email campaigns programmatically.

This forces developers to use the GHL UI manually for every campaign, even when they have fully automated workflows that create contacts, build HTML templates via API, and need to schedule sends without human intervention.

Proposed Solution

Add POST /emails/schedule with scope emails/schedule.write.

Request body (CreateScheduleDto)

Field Type Required Description
locationId string Sub-account ID
name string Campaign name
subject string Email subject line
campaignType enum draft / send_now / schedule_later
html string Full HTML body (or use templateId)
templateId string ID from POST /emails/builder
from string Sender email (verified domain)
fromName string Sender display name
dateScheduled number Unix ms timestamp (required for schedule_later)
sendDays string[] Allowed send days
hasTracking boolean Enable open/click tracking
hasUtmTracking boolean Append UTM params to links
enableResendToUnopened boolean Auto-resend to non-openers
resendInfo object Resend subject + duration config

Example: schedule a campaign for Monday at 12:00 UTC

curl -X POST https://services.leadconnectorhq.com/emails/schedule \
  -H "Authorization: Bearer pit-xxx" \
  -H "Version: 2021-07-28" \
  -H "Content-Type: application/json" \
  -d '{
    "locationId": "8Nua7uN3cDjUVlpiK9D0",
    "name": "Product Launch — Jul 14",
    "subject": "Something new is coming your way",
    "campaignType": "schedule_later",
    "status": "scheduled",
    "templateId": "6a526c938708da5288f5c149",
    "from": "info@yourdomain.com",
    "fromName": "Your Company",
    "dateScheduled": 1752487200000,
    "hasTracking": true,
    "hasUtmTracking": true
  }'

Real-world use case

Many agencies and SaaS builders using GHL as a white-label CRM need to:

  1. Import contacts via API ✅ (already works)
  2. Build email HTML via API ✅ (POST /emails/builder works)
  3. Create and schedule the campaign via API ❌ missing — this PR

Without step 3, the entire workflow requires manual UI intervention, defeating the purpose of API-first integration.

Changes

  • apps/emails.json: Added POST /emails/schedule endpoint, CreateScheduleDto request schema, and CreateScheduleSuccessfulResponseDto response schema.

Happy to iterate on the schema or add more examples. Thanks for maintaining the public API docs! 🙏

Add missing endpoint to create and schedule email marketing campaigns
via the API. Currently only GET /emails/schedule exists, making it
impossible to programmatically create draft or scheduled campaigns.

New endpoint: POST /emails/schedule
New scope: emails/schedule.write
New schemas: CreateScheduleDto, CreateScheduleSuccessfulResponseDto

Supports:
- Draft campaigns (campaignType: draft)
- Immediate send (campaignType: send_now)
- Scheduled send (campaignType: schedule_later + dateScheduled ms timestamp)
- Optional resend-to-unopened configuration
- HTML content directly or via templateId from POST /emails/builder
- UTM and open/click tracking flags

@orca-security-us orca-security-us Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 6   info 22 View in Orca
Passed Passed SAST high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Vulnerabilities high 0   medium 0   low 0   info 0 View in Orca
🛡️ The following IaC misconfigurations have been detected
NAME FILE
low Response on operations that should have a body has undefined schema apps/emails.json View in code
low Response on operations that should have a body has undefined schema apps/emails.json View in code
low Response on operations that should have a body has undefined schema apps/emails.json View in code
low Response on operations that should have a body has undefined schema apps/emails.json View in code
low Response on operations that should have a body has undefined schema apps/emails.json View in code
low Response Code Missing (v3) apps/emails.json View in code
info Object Without Required Property apps/emails.json View in code
info Object Without Required Property apps/emails.json View in code
info Object Without Required Property apps/emails.json View in code
info Object Without Required Property apps/emails.json View in code
info Object Without Required Property apps/emails.json View in code
info Object Without Required Property apps/emails.json View in code
info Object Without Required Property apps/emails.json View in code
info Default Invalid apps/emails.json View in code
info Template Path With No Corresponding Path Parameter apps/emails.json View in code
info Template Path With No Corresponding Path Parameter apps/emails.json View in code
info Template Path With No Corresponding Path Parameter apps/emails.json View in code
info Components Object Fixed Field Key Improperly Named apps/emails.json View in code
info Components Object Fixed Field Key Improperly Named apps/emails.json View in code
info Components Object Fixed Field Key Improperly Named apps/emails.json View in code
info Security Requirement Object With Wrong Scopes apps/emails.json View in code
info Security Requirement Object With Wrong Scopes apps/emails.json View in code
info Security Requirement Object With Wrong Scopes apps/emails.json View in code
info Security Requirement Object With Wrong Scopes apps/emails.json View in code
info Security Requirement Object With Wrong Scopes apps/emails.json View in code
... ... ... ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant