Workspace API

Kampanie e-mail i segmenty

Endpointy „Kampanie e-mail i segmenty” Zanfia Workspace API — ze schematami i przykładami kodu.

7 min czytaniaOstatnia aktualizacja: 26 lip 2026

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

GET/campaigns

Authorization

bearerAuth
AuthorizationBearer <token>

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

POST/campaigns

Authorization

bearerAuth
AuthorizationBearer <token>

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ę

GET/campaigns/{campaignId}

Authorization

bearerAuth
AuthorizationBearer <token>

API key from Dashboard → Integrations → API, MCP and CLI.

In: header

Path Parameters

campaignId*string

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

PATCH/campaigns/{campaignId}

Authorization

bearerAuth
AuthorizationBearer <token>

API key from Dashboard → Integrations → API, MCP and CLI.

In: header

Path Parameters

campaignId*string

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ę

DELETE/campaigns/{campaignId}

Authorization

bearerAuth
AuthorizationBearer <token>

API key from Dashboard → Integrations → API, MCP and CLI.

In: header

Path Parameters

campaignId*string

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ę

POST/campaigns/{campaignId}/send

Authorization

bearerAuth
AuthorizationBearer <token>

API key from Dashboard → Integrations → API, MCP and CLI.

In: header

Path Parameters

campaignId*string

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ę

POST/campaigns/{campaignId}/cancel

Authorization

bearerAuth
AuthorizationBearer <token>

API key from Dashboard → Integrations → API, MCP and CLI.

In: header

Path Parameters

campaignId*string

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

GET/campaigns/{campaignId}/recipients

Authorization

bearerAuth
AuthorizationBearer <token>

API key from Dashboard → Integrations → API, MCP and CLI.

In: header

Path Parameters

campaignId*string

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

GET/segments

Authorization

bearerAuth
AuthorizationBearer <token>

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

POST/segments

Authorization

bearerAuth
AuthorizationBearer <token>

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

PATCH/segments/{segmentId}

Authorization

bearerAuth
AuthorizationBearer <token>

API key from Dashboard → Integrations → API, MCP and CLI.

In: header

Path Parameters

segmentId*string

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

DELETE/segments/{segmentId}

Authorization

bearerAuth
AuthorizationBearer <token>

API key from Dashboard → Integrations → API, MCP and CLI.

In: header

Path Parameters

segmentId*string

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

POST/segments/preview

Authorization

bearerAuth
AuthorizationBearer <token>

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?

Powiązane artykuły

Coś się nie zgadza? Napisz do nas na support@zanfia.com.