Create a campaign
post
https://api.flactrum.com/v1/campaigns
| Required scope | campaigns.write |
| Success status | 201 |
| Returns | One Campaign object |
Request body
| Field | Type | Description |
|---|---|---|
| name * | string | — |
| description | string|null | — |
| discount_type * | string | — |
| discount_value * | number | Percentage discounts cannot exceed 100. |
| starts_at * | string | — |
| ends_at * | string | Must be after starts_at. |
| is_active | boolean | — |
| priority | integer | — |
| branch_ids | array | Omit or send empty for a brand-wide campaign. |
| product_ids | array | — |
| category_ids | array | Leave both target lists empty to cover the whole menu. |
Response fields
| Field | Type | Description |
|---|---|---|
| id | string | — |
| name | string | — |
| description | string|null | — |
| discount_type | string | — |
| discount_value | number | — |
| discount_label | string | Human-readable summary, e.g. "%20 indirim". |
| starts_at | string | — |
| ends_at | string | — |
| is_active | boolean | — |
| priority | integer | When several campaigns hit one product, the highest priority wins. Campaigns never stack. |
| is_running | boolean | — |
| status | string | — |
| branch_ids | array | Empty means the campaign is brand-wide. |
| product_ids | array | — |
| category_ids | array | — |
| targets_whole_menu | boolean | True when no product or category was targeted. |
Examples
Recorded from the test suite — these are real requests and their real responses.
curl -X POST 'https://api.flactrum.com/v1/campaigns' \
-H 'Authorization: Bearer flk_your_key:your_secret' \
-H 'Content-Type: application/json' \
-d '{
"name": "Öğrenci indirimi",
"discount_type": "percent",
"discount_value": 15,
"starts_at": "2026-10-04T00:00:00+00:00",
"ends_at": "2026-11-04T14:26:12+00:00",
"category_ids": [
"01m43mxr5baccj0x7w99cwxd9y"
],
"branch_ids": [
"01m43mxr503htvc04sjffmvhmb"
],
"priority": 10
}'
HTTP 201 · application/json
{
"data": {
"id": "01m43mxr6xzz9nzb8a1d183b37",
"name": "Öğrenci indirimi",
"description": null,
"discount_type": "percent",
"discount_value": 15,
"discount_label": "%15 indirim",
"starts_at": "2026-10-04T00:00:00+00:00",
"ends_at": "2026-11-04T14:26:12+00:00",
"is_active": true,
"priority": 10,
"is_running": true,
"status": "Yayında",
"branch_ids": [
"01m43mxr503htvc04sjffmvhmb"
],
"product_ids": [],
"category_ids": [
"01m43mxr5baccj0x7w99cwxd9y"
],
"targets_whole_menu": false,
"created_at": "2026-10-04T14:26:12+00:00",
"updated_at": "2026-10-04T14:26:12+00:00"
}
}
curl -X POST 'https://api.flactrum.com/v1/campaigns' \
-H 'Authorization: Bearer flk_your_key:your_secret' \
-H 'Content-Type: application/json' \
-d '{
"name": "Hatalı",
"discount_type": "percent",
"discount_value": 150,
"starts_at": "2026-10-04T14:26:12+00:00",
"ends_at": "2026-10-05T14:26:12+00:00"
}'
HTTP 422 · application/json
{
"error": {
"code": "validation_failed",
"message": "The submitted data is invalid.",
"details": {
"fields": {
"discount_value": [
"A percentage discount cannot exceed 100."
]
}
}
}
}