> For the complete documentation index, see [llms.txt](https://docs.parcellab.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.parcellab.com/docs/developers/campaign-manager/campaigns.md).

# Campaigns

## Overview

These requests allow you to get campaign data based on targeting parameters and gain insights into your campaign performance with a single HTTPS request.

You can retrieve active campaigns through these APIs using set parameters (for example: language and campaign medium) in order to find matching campaigns for evaluation. Additionally, you can track campaign event data for analytics purposes and monitor how your campaigns are performing.

## Get Campaign Data

You can retrieve campaign data of active campaigns based on the parameters provided using the `v4/campaign/evaluate` endpoint.

## Evaluate Campaign Targeting

> Evaluates active campaigns for given targeting parameters and returns campaign data, if there\
> is a matching campaign.

```json
{"openapi":"3.1.0","info":{"title":"parcelLab API","version":"v4"},"security":[{"HeaderToken":[]}],"components":{"securitySchemes":{"HeaderToken":{"type":"apiKey","in":"header","name":"Authorization","description":"Send `Authorization: Parcellab-API-Token <encoded-token>`.\n\n`<encoded-token>` = `base64(account_id:token)` as provided in the portal."}},"schemas":{"ContentBlocksResponse":{"type":"object","properties":{"campaignId":{"type":["string","null"],"maxLength":24},"trackingId":{"type":["string","null"],"maxLength":24},"customerSegmentationId":{"type":["string","null"],"maxLength":24},"audienceId":{"type":["string","null"],"maxLength":24},"openTrackingUrl":{"type":"string","maxLength":1024},"analyticsBaseUrl":{"type":"string","maxLength":1024},"values":{"type":"object","additionalProperties":{}},"placeholders":{"type":"object","additionalProperties":{}},"typedValues":{"type":"object","additionalProperties":{}},"accountHasActiveCampaigns":{"type":["boolean","null"]}},"required":["accountHasActiveCampaigns","campaignId","placeholders","trackingId","values"]},"Error400Response":{"type":"object","properties":{"type":{"type":"string"},"errors":{"type":"array","items":{"$ref":"#/components/schemas/GenericErrorItem"}}},"required":["errors","type"]},"GenericErrorItem":{"type":"object","properties":{"code":{"type":"string"},"detail":{"type":"string"},"attr":{"type":["string","null"]}},"required":["code","detail"]},"ErrorResponse404":{"type":"object","properties":{"type":{"$ref":"#/components/schemas/ClientErrorEnum"},"errors":{"type":"array","items":{"$ref":"#/components/schemas/Error404"}}},"required":["errors","type"]},"ClientErrorEnum":{"enum":["client_error"],"type":"string","description":"* `client_error` - Client Error"},"Error404":{"type":"object","properties":{"code":{"$ref":"#/components/schemas/ErrorCode404Enum"},"detail":{"type":"string"},"attr":{"type":["string","null"]}},"required":["attr","code","detail"]},"ErrorCode404Enum":{"enum":["not_found"],"type":"string","description":"* `not_found` - Not Found"}}},"paths":{"/v4/campaign/evaluate/":{"get":{"operationId":"campaign_evaluate_retrieve","description":"Evaluates active campaigns for given targeting parameters and returns campaign data, if there\nis a matching campaign.","summary":"Evaluate Campaign Targeting","parameters":[{"in":"query","name":"accountId","schema":{"type":"integer"}},{"in":"query","name":"campaignId","schema":{"type":"string","minLength":1,"maxLength":24}},{"in":"query","name":"language","schema":{"type":"string","minLength":1,"maxLength":5}},{"in":"query","name":"medium","schema":{"enum":["email","web","returns"],"type":"string","minLength":1},"description":"* `email` - Email\n* `web` - Web\n* `returns` - Returns Portal"},{"in":"query","name":"message","schema":{"type":"string","minLength":1,"maxLength":255}},{"in":"query","name":"orderNumber","schema":{"type":"string","minLength":1}},{"in":"query","name":"preview","schema":{"type":"boolean"}},{"in":"query","name":"status","schema":{"type":"string","minLength":1,"maxLength":255}},{"in":"query","name":"trackingId","schema":{"type":"string"},"description":"24-char hex MongoDB ObjectId of the tracking document"}],"tags":["Campaign"],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContentBlocksResponse"}}},"description":""},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error400Response"}}},"description":""},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse404"}}},"description":""}}}}}}
```

## Get Campaign Analytics

You can retrieve analytics data for campaign events using the `v4/campaign/redirect` endpoint.

## Campaign Analytics Service

> Collects campaign event data (clicks & opens) for analytics purposes and forwards the\
> user to the redirect URL if provided.

```json
{"openapi":"3.1.0","info":{"title":"parcelLab API","version":"v4"},"security":[{"HeaderToken":[]}],"components":{"securitySchemes":{"HeaderToken":{"type":"apiKey","in":"header","name":"Authorization","description":"Send `Authorization: Parcellab-API-Token <encoded-token>`.\n\n`<encoded-token>` = `base64(account_id:token)` as provided in the portal."}},"schemas":{"ContentBlocksResponse":{"type":"object","properties":{"campaignId":{"type":["string","null"],"maxLength":24},"trackingId":{"type":["string","null"],"maxLength":24},"customerSegmentationId":{"type":["string","null"],"maxLength":24},"audienceId":{"type":["string","null"],"maxLength":24},"openTrackingUrl":{"type":"string","maxLength":1024},"analyticsBaseUrl":{"type":"string","maxLength":1024},"values":{"type":"object","additionalProperties":{}},"placeholders":{"type":"object","additionalProperties":{}},"typedValues":{"type":"object","additionalProperties":{}},"accountHasActiveCampaigns":{"type":["boolean","null"]}},"required":["accountHasActiveCampaigns","campaignId","placeholders","trackingId","values"]},"Error400Response":{"type":"object","properties":{"type":{"type":"string"},"errors":{"type":"array","items":{"$ref":"#/components/schemas/GenericErrorItem"}}},"required":["errors","type"]},"GenericErrorItem":{"type":"object","properties":{"code":{"type":"string"},"detail":{"type":"string"},"attr":{"type":["string","null"]}},"required":["code","detail"]},"ErrorResponse404":{"type":"object","properties":{"type":{"$ref":"#/components/schemas/ClientErrorEnum"},"errors":{"type":"array","items":{"$ref":"#/components/schemas/Error404"}}},"required":["errors","type"]},"ClientErrorEnum":{"enum":["client_error"],"type":"string","description":"* `client_error` - Client Error"},"Error404":{"type":"object","properties":{"code":{"$ref":"#/components/schemas/ErrorCode404Enum"},"detail":{"type":"string"},"attr":{"type":["string","null"]}},"required":["attr","code","detail"]},"ErrorCode404Enum":{"enum":["not_found"],"type":"string","description":"* `not_found` - Not Found"}}},"paths":{"/v4/campaign/redirect/":{"get":{"operationId":"campaign_redirect_retrieve","description":"Collects campaign event data (clicks & opens) for analytics purposes and forwards the\nuser to the redirect URL if provided.","summary":"Campaign Analytics Service","parameters":[{"in":"query","name":"c","schema":{"type":"string","minLength":1,"maxLength":24}},{"in":"query","name":"campaignId","schema":{"type":"string","minLength":1,"maxLength":24}},{"in":"query","name":"contentType","schema":{"type":"string","minLength":1,"maxLength":1024}},{"in":"query","name":"customerSegmentationId","schema":{"type":"string","minLength":1,"maxLength":24}},{"in":"query","name":"e","schema":{"type":"string"},"description":"24-char hex MongoDB ObjectId of the email document"},{"in":"query","name":"emailId","schema":{"type":"string"},"description":"24-char hex MongoDB ObjectId of the email document"},{"in":"query","name":"eventType","schema":{"enum":["open","click"],"type":"string","minLength":1},"description":"* `open` - open\n* `click` - click","required":true},{"in":"query","name":"medium","schema":{"enum":["email","web","returns"],"type":"string","minLength":1},"description":"* `email` - Email\n* `web` - Web\n* `returns` - Returns Portal"},{"in":"query","name":"redirectUrl","schema":{"type":"string","minLength":1,"maxLength":1024}},{"in":"query","name":"s","schema":{"type":"string","minLength":1,"maxLength":24}},{"in":"query","name":"trackingId","schema":{"type":"string"},"description":"24-char hex MongoDB ObjectId of the tracking document"}],"tags":["Campaign"],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContentBlocksResponse"}}},"description":""},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error400Response"}}},"description":""},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse404"}}},"description":""}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.parcellab.com/docs/developers/campaign-manager/campaigns.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
