feat: add contactBooks to sdk, add delete campaign public endpoint (#352)

* feat: add contactBooks to sdk, add delete campaign public endpoint

* fix: pr review notes

* refactor: pr feedback

* feat: bulk delete/create contacts

* refactor: rename a few methods for consistency

* refactor: update openapi docs based on pr feedback

* refactor: update open api docs, based on pr feedback

* fix: delete campaign security issue

* refactor: delete campaign requires team id (from context)

* fix: enums
This commit is contained in:
Dave Stockley
2026-03-03 20:10:43 +00:00
committed by GitHub
parent 73416dc481
commit 7428a1fbfa
22 changed files with 1365 additions and 218 deletions
@@ -0,0 +1,3 @@
---
openapi: delete /v1/campaigns/{campaignId}
---
@@ -0,0 +1,3 @@
---
openapi: post /v1/contactBooks/{contactBookId}/contacts/bulk
---
@@ -0,0 +1,3 @@
---
openapi: delete /v1/contactBooks/{contactBookId}/contacts/bulk
---
+251 -18
View File
@@ -1585,6 +1585,163 @@
}
}
},
"/v1/contactBooks/{contactBookId}/contacts/bulk": {
"delete": {
"parameters": [
{
"schema": {
"type": "string",
"minLength": 3,
"example": "cuiwqdj74rygf74"
},
"required": true,
"name": "contactBookId",
"in": "path"
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"contactIds": {
"type": "array",
"items": { "type": "string" },
"minItems": 1,
"maxItems": 1000
}
},
"required": ["contactIds"]
}
}
}
},
"responses": {
"200": {
"description": "Bulk delete contacts from a contact book",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": { "type": "boolean" },
"count": { "type": "number" }
},
"required": ["success", "count"]
}
}
}
},
"403": {
"description": "Forbidden - API key doesn't have access",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": { "error": { "type": "string" } },
"required": ["error"]
}
}
}
},
"404": {
"description": "Contact book not found",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": { "error": { "type": "string" } },
"required": ["error"]
}
}
}
}
}
},
"post": {
"parameters": [
{
"schema": {
"type": "string",
"minLength": 3,
"example": "cuiwqdj74rygf74"
},
"required": true,
"name": "contactBookId",
"in": "path"
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"type": "object",
"properties": {
"email": { "type": "string" },
"firstName": { "type": "string" },
"lastName": { "type": "string" },
"properties": {
"type": "object",
"additionalProperties": { "type": "string" }
},
"subscribed": { "type": "boolean" }
},
"required": ["email"]
},
"minItems": 1,
"maxItems": 1000
}
}
}
},
"responses": {
"200": {
"description": "Bulk add contacts to a contact book",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": { "type": "string" },
"count": { "type": "number" }
},
"required": ["message", "count"]
}
}
}
},
"403": {
"description": "Forbidden - API key doesn't have access",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": { "error": { "type": "string" } },
"required": ["error"]
}
}
}
},
"404": {
"description": "Contact book not found",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": { "error": { "type": "string" } },
"required": ["error"]
}
}
}
}
}
}
},
"/v1/contactBooks/{contactBookId}/contacts/{contactId}": {
"patch": {
"parameters": [
@@ -1790,10 +1947,9 @@
"enum": [
"DRAFT",
"SCHEDULED",
"IN_PROGRESS",
"RUNNING",
"PAUSED",
"COMPLETED",
"CANCELLED"
"SENT"
],
"example": "DRAFT"
},
@@ -1829,7 +1985,7 @@
"subject": { "type": "string" },
"createdAt": { "type": "string", "format": "date-time" },
"updatedAt": { "type": "string", "format": "date-time" },
"status": { "type": "string" },
"status": { "type": "string", "enum": ["DRAFT", "SCHEDULED", "RUNNING", "PAUSED", "SENT"] },
"scheduledAt": { "type": "string", "nullable": true, "format": "date-time" },
"total": { "type": "integer" },
"sent": { "type": "integer" },
@@ -1935,7 +2091,7 @@
"contactBookId": { "type": "string", "nullable": true },
"html": { "type": "string", "nullable": true },
"content": { "type": "string", "nullable": true },
"status": { "type": "string" },
"status": { "type": "string", "enum": ["DRAFT", "SCHEDULED", "RUNNING", "PAUSED", "SENT"] },
"scheduledAt": {
"type": "string",
"nullable": true,
@@ -1997,19 +2153,19 @@
}
},
"/v1/campaigns/{campaignId}": {
"parameters": [
{
"schema": {
"type": "string",
"minLength": 1,
"example": "cmp_123"
},
"required": true,
"name": "campaignId",
"in": "path"
}
],
"get": {
"parameters": [
{
"schema": {
"type": "string",
"minLength": 1,
"example": "cmp_123"
},
"required": true,
"name": "campaignId",
"in": "path"
}
],
"responses": {
"200": {
"description": "Get campaign details",
@@ -2026,7 +2182,84 @@
"contactBookId": { "type": "string", "nullable": true },
"html": { "type": "string", "nullable": true },
"content": { "type": "string", "nullable": true },
"status": { "type": "string" },
"status": { "type": "string", "enum": ["DRAFT", "SCHEDULED", "RUNNING", "PAUSED", "SENT"] },
"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"
]
}
}
}
}
}
},
"delete": {
"responses": {
"200": {
"description": "Delete 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", "enum": ["DRAFT", "SCHEDULED", "RUNNING", "PAUSED", "SENT"] },
"scheduledAt": {
"type": "string",
"nullable": true,
+5 -2
View File
@@ -77,9 +77,11 @@
"api-reference/contacts/get-contact",
"api-reference/contacts/get-contacts",
"api-reference/contacts/create-contact",
"api-reference/contacts/bulk-create-contact",
"api-reference/contacts/update-contact",
"api-reference/contacts/upsert-contact",
"api-reference/contacts/delete-contact"
"api-reference/contacts/delete-contact",
"api-reference/contacts/bulk-delete-contacts"
]
},
{
@@ -100,7 +102,8 @@
"api-reference/campaigns/get-campaign",
"api-reference/campaigns/schedule-campaign",
"api-reference/campaigns/pause-campaign",
"api-reference/campaigns/resume-campaign"
"api-reference/campaigns/resume-campaign",
"api-reference/campaigns/delete-campaign"
]
}
]