add campaign api (#274)

This commit is contained in:
KM Koushik
2025-10-18 10:31:43 +11:00
committed by GitHub
parent e631f16c85
commit a5ca3b2f87
31 changed files with 2093 additions and 187 deletions
@@ -0,0 +1,3 @@
---
openapi: post /v1/campaigns
---
@@ -0,0 +1,3 @@
---
openapi: get /v1/campaigns/{campaignId}
---
@@ -0,0 +1,3 @@
---
openapi: post /v1/campaigns/{campaignId}/pause
---
@@ -0,0 +1,3 @@
---
openapi: post /v1/campaigns/{campaignId}/resume
---
@@ -0,0 +1,3 @@
---
openapi: post /v1/campaigns/{campaignId}/schedule
---
+525
View File
@@ -1910,6 +1910,531 @@
}
}
}
},
"/v1/campaigns": {
"post": {
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"name": {
"type": "string",
"minLength": 1
},
"from": {
"type": "string",
"minLength": 1
},
"subject": {
"type": "string",
"minLength": 1
},
"previewText": {
"type": "string"
},
"contactBookId": {
"type": "string",
"minLength": 1
},
"content": {
"type": "string",
"minLength": 1
},
"html": {
"type": "string",
"minLength": 1
},
"replyTo": {
"anyOf": [
{
"type": "string",
"minLength": 1
},
{
"type": "array",
"items": {
"type": "string",
"minLength": 1
}
}
]
},
"cc": {
"anyOf": [
{
"type": "string",
"minLength": 1
},
{
"type": "array",
"items": {
"type": "string",
"minLength": 1
}
}
]
},
"bcc": {
"anyOf": [
{
"type": "string",
"minLength": 1
},
{
"type": "array",
"items": {
"type": "string",
"minLength": 1
}
}
]
},
"sendNow": {
"type": "boolean"
},
"scheduledAt": {
"type": "string",
"description": "Timestamp in ISO 8601 format or natural language (e.g., 'tomorrow 9am', 'next monday 10:30')"
},
"batchSize": {
"type": "integer",
"minimum": 1,
"maximum": 100000
}
},
"required": [
"name",
"from",
"subject",
"contactBookId"
]
}
}
}
},
"responses": {
"200": {
"description": "Create a campaign",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"from": {
"type": "string"
},
"subject": {
"type": "string"
},
"previewText": {
"type": "string",
"nullable": true
},
"contactBookId": {
"type": "string",
"nullable": true
},
"html": {
"type": "string",
"nullable": true
},
"content": {
"type": "string",
"nullable": true
},
"status": {
"type": "string"
},
"scheduledAt": {
"type": "string",
"nullable": true,
"format": "date-time"
},
"batchSize": {
"type": "integer"
},
"batchWindowMinutes": {
"type": "integer"
},
"total": {
"type": "integer"
},
"sent": {
"type": "integer"
},
"delivered": {
"type": "integer"
},
"opened": {
"type": "integer"
},
"clicked": {
"type": "integer"
},
"unsubscribed": {
"type": "integer"
},
"bounced": {
"type": "integer"
},
"hardBounced": {
"type": "integer"
},
"complained": {
"type": "integer"
},
"replyTo": {
"type": "array",
"items": {
"type": "string"
}
},
"cc": {
"type": "array",
"items": {
"type": "string"
}
},
"bcc": {
"type": "array",
"items": {
"type": "string"
}
},
"createdAt": {
"type": "string",
"format": "date-time"
},
"updatedAt": {
"type": "string",
"format": "date-time"
}
},
"required": [
"id",
"name",
"from",
"subject",
"previewText",
"contactBookId",
"html",
"content",
"status",
"scheduledAt",
"batchSize",
"batchWindowMinutes",
"total",
"sent",
"delivered",
"opened",
"clicked",
"unsubscribed",
"bounced",
"hardBounced",
"complained",
"replyTo",
"cc",
"bcc",
"createdAt",
"updatedAt"
]
}
}
}
}
}
}
},
"/v1/campaigns/{campaignId}": {
"get": {
"parameters": [
{
"schema": {
"type": "string",
"minLength": 1,
"example": "cmp_123"
},
"required": true,
"name": "campaignId",
"in": "path"
}
],
"responses": {
"200": {
"description": "Get campaign details",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"from": {
"type": "string"
},
"subject": {
"type": "string"
},
"previewText": {
"type": "string",
"nullable": true
},
"contactBookId": {
"type": "string",
"nullable": true
},
"html": {
"type": "string",
"nullable": true
},
"content": {
"type": "string",
"nullable": true
},
"status": {
"type": "string"
},
"scheduledAt": {
"type": "string",
"nullable": true,
"format": "date-time"
},
"batchSize": {
"type": "integer"
},
"batchWindowMinutes": {
"type": "integer"
},
"total": {
"type": "integer"
},
"sent": {
"type": "integer"
},
"delivered": {
"type": "integer"
},
"opened": {
"type": "integer"
},
"clicked": {
"type": "integer"
},
"unsubscribed": {
"type": "integer"
},
"bounced": {
"type": "integer"
},
"hardBounced": {
"type": "integer"
},
"complained": {
"type": "integer"
},
"replyTo": {
"type": "array",
"items": {
"type": "string"
}
},
"cc": {
"type": "array",
"items": {
"type": "string"
}
},
"bcc": {
"type": "array",
"items": {
"type": "string"
}
},
"createdAt": {
"type": "string",
"format": "date-time"
},
"updatedAt": {
"type": "string",
"format": "date-time"
}
},
"required": [
"id",
"name",
"from",
"subject",
"previewText",
"contactBookId",
"html",
"content",
"status",
"scheduledAt",
"batchSize",
"batchWindowMinutes",
"total",
"sent",
"delivered",
"opened",
"clicked",
"unsubscribed",
"bounced",
"hardBounced",
"complained",
"replyTo",
"cc",
"bcc",
"createdAt",
"updatedAt"
]
}
}
}
}
}
}
},
"/v1/campaigns/{campaignId}/schedule": {
"post": {
"parameters": [
{
"schema": {
"type": "string",
"minLength": 1,
"example": "cmp_123"
},
"required": true,
"name": "campaignId",
"in": "path"
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"scheduledAt": {
"type": "string",
"description": "Timestamp in ISO 8601 format or natural language (e.g., 'tomorrow 9am', 'next monday 10:30')"
},
"batchSize": {
"type": "integer",
"minimum": 1,
"maximum": 100000
}
}
}
}
}
},
"responses": {
"200": {
"description": "Schedule a campaign",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
}
},
"required": [
"success"
]
}
}
}
}
}
}
},
"/v1/campaigns/{campaignId}/pause": {
"post": {
"parameters": [
{
"schema": {
"type": "string",
"minLength": 1,
"example": "cmp_123"
},
"required": true,
"name": "campaignId",
"in": "path"
}
],
"responses": {
"200": {
"description": "Pause a campaign",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
}
},
"required": [
"success"
]
}
}
}
}
}
}
},
"/v1/campaigns/{campaignId}/resume": {
"post": {
"parameters": [
{
"schema": {
"type": "string",
"minLength": 1,
"example": "cmp_123"
},
"required": true,
"name": "campaignId",
"in": "path"
}
],
"responses": {
"200": {
"description": "Resume a campaign",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
}
},
"required": [
"success"
]
}
}
}
}
}
}
}
}
}