feat(emails): add POST /emails/schedule for programmatic campaign creation#310
Open
brayanjeshua wants to merge 1 commit into
Open
feat(emails): add POST /emails/schedule for programmatic campaign creation#310brayanjeshua wants to merge 1 commit into
brayanjeshua wants to merge 1 commit into
Conversation
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
There was a problem hiding this comment.
Orca Security Scan Summary
| Status | Check | Issues by priority | |
|---|---|---|---|
| Infrastructure as Code | View in Orca | ||
| SAST | View in Orca | ||
| Secrets | View in Orca | ||
| Vulnerabilities | View in Orca |
🛡️ The following IaC misconfigurations have been detected
| NAME | FILE | ||
|---|---|---|---|
| Response on operations that should have a body has undefined schema | apps/emails.json | View in code | |
| Response on operations that should have a body has undefined schema | apps/emails.json | View in code | |
| Response on operations that should have a body has undefined schema | apps/emails.json | View in code | |
| Response on operations that should have a body has undefined schema | apps/emails.json | View in code | |
| Response on operations that should have a body has undefined schema | apps/emails.json | View in code | |
| Response Code Missing (v3) | apps/emails.json | View in code | |
| Object Without Required Property | apps/emails.json | View in code | |
| Object Without Required Property | apps/emails.json | View in code | |
| Object Without Required Property | apps/emails.json | View in code | |
| Object Without Required Property | apps/emails.json | View in code | |
| Object Without Required Property | apps/emails.json | View in code | |
| Object Without Required Property | apps/emails.json | View in code | |
| Object Without Required Property | apps/emails.json | View in code | |
| Default Invalid | apps/emails.json | View in code | |
| Template Path With No Corresponding Path Parameter | apps/emails.json | View in code | |
| Template Path With No Corresponding Path Parameter | apps/emails.json | View in code | |
| Template Path With No Corresponding Path Parameter | apps/emails.json | View in code | |
| Components Object Fixed Field Key Improperly Named | apps/emails.json | View in code | |
| Components Object Fixed Field Key Improperly Named | apps/emails.json | View in code | |
| Components Object Fixed Field Key Improperly Named | apps/emails.json | View in code | |
| Security Requirement Object With Wrong Scopes | apps/emails.json | View in code | |
| Security Requirement Object With Wrong Scopes | apps/emails.json | View in code | |
| Security Requirement Object With Wrong Scopes | apps/emails.json | View in code | |
| Security Requirement Object With Wrong Scopes | apps/emails.json | View in code | |
| Security Requirement Object With Wrong Scopes | apps/emails.json | View in code | |
| ... | ... | ... | ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Currently the Email Marketing API only exposes
GET /emails/schedule(read campaigns) andPOST /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/schedulewith scopeemails/schedule.write.Request body (
CreateScheduleDto)locationIdnamesubjectcampaignTypedraft/send_now/schedule_laterhtmltemplateId)templateIdPOST /emails/builderfromfromNamedateScheduledschedule_later)sendDayshasTrackinghasUtmTrackingenableResendToUnopenedresendInfoExample: schedule a campaign for Monday at 12:00 UTC
Real-world use case
Many agencies and SaaS builders using GHL as a white-label CRM need to:
POST /emails/builderworks)Without step 3, the entire workflow requires manual UI intervention, defeating the purpose of API-first integration.
Changes
apps/emails.json: AddedPOST /emails/scheduleendpoint,CreateScheduleDtorequest schema, andCreateScheduleSuccessfulResponseDtoresponse schema.Happy to iterate on the schema or add more examples. Thanks for maintaining the public API docs! 🙏