Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/docs/api-reference/campaigns/delete-campaign.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
openapi: delete /v1/campaigns/{campaignId}
---
3 changes: 3 additions & 0 deletions apps/docs/api-reference/contacts/bulk-create-contact.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
openapi: post /v1/contactBooks/{contactBookId}/contacts/bulk
---
3 changes: 3 additions & 0 deletions apps/docs/api-reference/contacts/bulk-delete-contacts.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
openapi: delete /v1/contactBooks/{contactBookId}/contacts/bulk
---
269 changes: 251 additions & 18 deletions apps/docs/api-reference/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -1790,10 +1947,9 @@
"enum": [
"DRAFT",
"SCHEDULED",
"IN_PROGRESS",
"RUNNING",
"PAUSED",
"COMPLETED",
"CANCELLED"
"SENT"
],
"example": "DRAFT"
},
Expand Down Expand Up @@ -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" },
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand All @@ -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,
Expand Down
7 changes: 5 additions & 2 deletions apps/docs/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand All @@ -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"
]
}
]
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/server/api/routers/campaign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ export const campaignRouter = createTRPCRouter({
return campaign;
}),

deleteCampaign: campaignProcedure.mutation(async ({ input }) => {
return await campaignService.deleteCampaign(input.campaignId);
deleteCampaign: campaignProcedure.mutation(async ({ ctx: { team }, input }) => {
return await campaignService.deleteCampaign(input.campaignId, team.id);
}),

getCampaign: campaignProcedure.query(async ({ ctx: { db, team }, input }) => {
Expand Down
Loading