Overview / Stock & supply / Create the suggested campaign as a draft

Create the suggested campaign as a draft

post https://api.flactrum.com/v1/stock-expiry/campaign

Recalculates the batch from its key and opens an inactive campaign on the products that use the item, in that branch, until the end of the best-before day. Review it and switch it on to affect sales.

Required scope stock.read campaigns.write
Success status201
Returns One Campaign object

Request body

FieldTypeDescription
key * string —
days integer The window the key was listed in.

Response fields

FieldTypeDescription
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/stock-expiry/campaign' \
  -H 'Authorization: Bearer flk_your_key:your_secret' \
  -H 'Content-Type: application/json' \
  -d '{
    "key": "branch:01m43sqbhgme40fvbkxj7hxw6x:01m43sqbmmrbg30va7tx30apnj:2026-10-06",
    "days": 7
}'

HTTP 201 · application/json

{
    "data": {
        "id": "01m43sqbs85stdgtc47vhgt7nr",
        "name": "SKT: Süt — Nişantaşı",
        "description": "Son kullanma tarihi 06 Eki 2026 olan stoğu eritmek için önerildi.",
        "discount_type": "percent",
        "discount_value": 30,
        "discount_label": "%30 indirim",
        "starts_at": "2026-10-04T15:50:05+00:00",
        "ends_at": "2026-10-06T20:59:59+00:00",
        "is_active": false,
        "priority": 0,
        "is_running": false,
        "status": "Pasif",
        "branch_ids": [
            "01m43sqbhgme40fvbkxj7hxw6x"
        ],
        "product_ids": [
            "01m43sqbmxbs8rnwx9nrh8j6w7"
        ],
        "category_ids": [],
        "targets_whole_menu": false,
        "created_at": "2026-10-04T15:50:05+00:00",
        "updated_at": "2026-10-04T15:50:05+00:00"
    }
}