Kampanie e-mail i segmenty
Endpointy „Kampanie e-mail i segmenty” Zanfia Workspace API — ze schematami i przykładami kodu.
Jednorazowe wysyłki e-mail i segmenty odbiorców, do których trafiają. Kampanię tworzy się jako szkic i wysyła (lub planuje do 30 dni w przód) osobnym endpointem — wysyłka jest nieodwracalna, więc najpierw sprawdź odbiorców przez POST /segments/preview. Wszystkie endpointy wymagają nagłówka Authorization: Bearer — zobacz Uwierzytelnianie.
Lista kampanii e-mail
/campaignsAuthorization
bearerAuth API key from Dashboard → Integrations → API, MCP and CLI.
In: header
Response Body
application/json
application/json
curl -X GET "https://example.com/campaigns"{ "count": 0, "campaigns": [ { "id": "string", "name": "string", "status": "draft", "category": "platform-announcements", "newsletterId": "string", "subject": "string", "preheader": "string", "contentMarkdown": "string", "sender": { "fromName": "string", "replyTo": "string", "fromEmail": "string" }, "theme": { "backgroundColor": "string", "contentBackgroundColor": "string", "linkColor": "string" }, "audience": { "type": "segment", "segmentId": "string" }, "recipientCount": 0, "scheduledAt": "string", "sendStartedAt": "string", "completedAt": "string", "stats": { "sent": 0, "delivered": 0, "bounced": 0, "complained": 0, "failed": 0, "skippedSuppressed": 0, "skippedMuted": 0, "uniqueClicks": 0, "trackedRecipients": 0 }, "createdAt": "string", "updatedAt": "string" } ]}{ "error": "string"}Utwórz szkic kampanii
/campaignsAuthorization
bearerAuth API key from Dashboard → Integrations → API, MCP and CLI.
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Creates a DRAFT campaign — nothing is emailed. Everything beyond the name is optional at draft time; completeness is enforced by the send route.
Response Body
application/json
application/json
curl -X POST "https://example.com/campaigns" \ -H "Content-Type: application/json" \ -d '{ "name": "string" }'{ "campaign": { "id": "string", "name": "string", "status": "draft", "category": "platform-announcements", "newsletterId": "string", "subject": "string", "preheader": "string", "contentMarkdown": "string", "sender": { "fromName": "string", "replyTo": "string", "fromEmail": "string" }, "theme": { "backgroundColor": "string", "contentBackgroundColor": "string", "linkColor": "string" }, "audience": { "type": "segment", "segmentId": "string" }, "recipientCount": 0, "scheduledAt": "string", "sendStartedAt": "string", "completedAt": "string", "stats": { "sent": 0, "delivered": 0, "bounced": 0, "complained": 0, "failed": 0, "skippedSuppressed": 0, "skippedMuted": 0, "uniqueClicks": 0, "trackedRecipients": 0 }, "createdAt": "string", "updatedAt": "string" }}{ "error": "string"}Pobierz kampanię
/campaigns/{campaignId}Authorization
bearerAuth API key from Dashboard → Integrations → API, MCP and CLI.
In: header
Path Parameters
Response Body
application/json
application/json
curl -X GET "https://example.com/campaigns/string"{ "campaign": { "id": "string", "name": "string", "status": "draft", "category": "platform-announcements", "newsletterId": "string", "subject": "string", "preheader": "string", "contentMarkdown": "string", "sender": { "fromName": "string", "replyTo": "string", "fromEmail": "string" }, "theme": { "backgroundColor": "string", "contentBackgroundColor": "string", "linkColor": "string" }, "audience": { "type": "segment", "segmentId": "string" }, "recipientCount": 0, "scheduledAt": "string", "sendStartedAt": "string", "completedAt": "string", "stats": { "sent": 0, "delivered": 0, "bounced": 0, "complained": 0, "failed": 0, "skippedSuppressed": 0, "skippedMuted": 0, "uniqueClicks": 0, "trackedRecipients": 0 }, "createdAt": "string", "updatedAt": "string" }}{ "error": "string"}Edytuj szkic kampanii
/campaigns/{campaignId}Authorization
bearerAuth API key from Dashboard → Integrations → API, MCP and CLI.
In: header
Path Parameters
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Drafts only — a campaign past draft is immutable except cancel.
Response Body
application/json
application/json
curl -X PATCH "https://example.com/campaigns/string" \ -H "Content-Type: application/json" \ -d '{}'{ "campaign": { "id": "string", "name": "string", "status": "draft", "category": "platform-announcements", "newsletterId": "string", "subject": "string", "preheader": "string", "contentMarkdown": "string", "sender": { "fromName": "string", "replyTo": "string", "fromEmail": "string" }, "theme": { "backgroundColor": "string", "contentBackgroundColor": "string", "linkColor": "string" }, "audience": { "type": "segment", "segmentId": "string" }, "recipientCount": 0, "scheduledAt": "string", "sendStartedAt": "string", "completedAt": "string", "stats": { "sent": 0, "delivered": 0, "bounced": 0, "complained": 0, "failed": 0, "skippedSuppressed": 0, "skippedMuted": 0, "uniqueClicks": 0, "trackedRecipients": 0 }, "createdAt": "string", "updatedAt": "string" }}{ "error": "string"}Usuń kampanię
/campaigns/{campaignId}Authorization
bearerAuth API key from Dashboard → Integrations → API, MCP and CLI.
In: header
Path Parameters
Response Body
application/json
application/json
curl -X DELETE "https://example.com/campaigns/string"{ "campaignId": "string", "deleted": true}{ "error": "string"}Wyślij lub zaplanuj kampanię
/campaigns/{campaignId}/sendAuthorization
bearerAuth API key from Dashboard → Integrations → API, MCP and CLI.
In: header
Path Parameters
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
⚠️ HIGHEST-STAKES ROUTE: this SENDS the campaign — real bulk email to the resolved audience (every subscribed client, or the saved segment). Once the fan-out starts, delivered mail cannot be recalled; the only recovery is POST /campaigns/:campaignId/cancel, which stops REMAINING sends only.
The use case guards: draft-only (CAS status transition doubles as the double-send guard), completeness check (subject/content/sender), non-empty audience, and a ≤ 30-days-out schedule ceiling. Omit scheduledAt to send immediately.
Response Body
application/json
application/json
curl -X POST "https://example.com/campaigns/string/send" \ -H "Content-Type: application/json" \ -d '{}'{ "campaign": { "id": "string", "name": "string", "status": "draft", "category": "platform-announcements", "newsletterId": "string", "subject": "string", "preheader": "string", "contentMarkdown": "string", "sender": { "fromName": "string", "replyTo": "string", "fromEmail": "string" }, "theme": { "backgroundColor": "string", "contentBackgroundColor": "string", "linkColor": "string" }, "audience": { "type": "segment", "segmentId": "string" }, "recipientCount": 0, "scheduledAt": "string", "sendStartedAt": "string", "completedAt": "string", "stats": { "sent": 0, "delivered": 0, "bounced": 0, "complained": 0, "failed": 0, "skippedSuppressed": 0, "skippedMuted": 0, "uniqueClicks": 0, "trackedRecipients": 0 }, "createdAt": "string", "updatedAt": "string" }}{ "error": "string"}Anuluj zaplanowaną/wysyłaną kampanię
/campaigns/{campaignId}/cancelAuthorization
bearerAuth API key from Dashboard → Integrations → API, MCP and CLI.
In: header
Path Parameters
Response Body
application/json
application/json
curl -X POST "https://example.com/campaigns/string/cancel"{ "campaign": { "id": "string", "name": "string", "status": "draft", "category": "platform-announcements", "newsletterId": "string", "subject": "string", "preheader": "string", "contentMarkdown": "string", "sender": { "fromName": "string", "replyTo": "string", "fromEmail": "string" }, "theme": { "backgroundColor": "string", "contentBackgroundColor": "string", "linkColor": "string" }, "audience": { "type": "segment", "segmentId": "string" }, "recipientCount": 0, "scheduledAt": "string", "sendStartedAt": "string", "completedAt": "string", "stats": { "sent": 0, "delivered": 0, "bounced": 0, "complained": 0, "failed": 0, "skippedSuppressed": 0, "skippedMuted": 0, "uniqueClicks": 0, "trackedRecipients": 0 }, "createdAt": "string", "updatedAt": "string" }}{ "error": "string"}Lista odbiorców kampanii
/campaigns/{campaignId}/recipientsAuthorization
bearerAuth API key from Dashboard → Integrations → API, MCP and CLI.
In: header
Path Parameters
Response Body
application/json
application/json
curl -X GET "https://example.com/campaigns/string/recipients"{ "recipients": [ { "id": "string", "email": "string", "status": "pending", "statusDetails": "string", "processedAt": "string" } ], "nextCursor": "string"}{ "error": "string"}Lista segmentów odbiorców
/segmentsAuthorization
bearerAuth API key from Dashboard → Integrations → API, MCP and CLI.
In: header
Response Body
application/json
application/json
curl -X GET "https://example.com/segments"{ "count": 0, "segments": [ { "id": "string", "name": "string", "type": "dynamic", "conditions": [ { "field": "tag", "operator": "has", "tagId": "string" } ], "lastEvaluatedCount": 0, "lastEvaluatedAt": "string", "createdAt": "string", "updatedAt": "string" } ]}{ "error": "string"}Utwórz segment odbiorców
/segmentsAuthorization
bearerAuth API key from Dashboard → Integrations → API, MCP and CLI.
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
curl -X POST "https://example.com/segments" \ -H "Content-Type: application/json" \ -d '{ "name": "string", "conditions": [ { "field": "tag", "operator": "has", "tagId": "string" } ] }'{ "segment": { "id": "string", "name": "string", "type": "dynamic", "conditions": [ { "field": "tag", "operator": "has", "tagId": "string" } ], "lastEvaluatedCount": 0, "lastEvaluatedAt": "string", "createdAt": "string", "updatedAt": "string" }}{ "error": "string"}Edytuj segment odbiorców
/segments/{segmentId}Authorization
bearerAuth API key from Dashboard → Integrations → API, MCP and CLI.
In: header
Path Parameters
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
curl -X PATCH "https://example.com/segments/string" \ -H "Content-Type: application/json" \ -d '{}'{ "segment": { "id": "string", "name": "string", "type": "dynamic", "conditions": [ { "field": "tag", "operator": "has", "tagId": "string" } ], "lastEvaluatedCount": 0, "lastEvaluatedAt": "string", "createdAt": "string", "updatedAt": "string" }}{ "error": "string"}Usuń segment odbiorców
/segments/{segmentId}Authorization
bearerAuth API key from Dashboard → Integrations → API, MCP and CLI.
In: header
Path Parameters
Response Body
application/json
application/json
curl -X DELETE "https://example.com/segments/string"{ "segmentId": "string", "deleted": true}{ "error": "string"}Podgląd odbiorców segmentu
/segments/previewAuthorization
bearerAuth API key from Dashboard → Integrations → API, MCP and CLI.
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Stateless evaluation of a condition set — nothing is persisted.
Response Body
application/json
application/json
curl -X POST "https://example.com/segments/preview" \ -H "Content-Type: application/json" \ -d '{ "conditions": [ { "field": "tag", "operator": "has", "tagId": "string" } ] }'{ "count": 0}{ "error": "string"}Czy ten artykuł był pomocny?

