Lifecycle & Status
This page explains how Operations move across statuses and what you can change at each step.
Keep in mind
- Author in DRAFT. Publish to ACTIVE when ready. Deactivate to INACTIVE.
- Buyers can only use Operations that are ACTIVE and within the [startDate, endDate] window.
- Automatic rule: when
endDate
passes, an ACTIVE Operation becomes INACTIVE.
🧭 State model at a glance
stateDiagram-v2 [*] --> DRAFT DRAFT --> ACTIVE: Publish (manual) ACTIVE --> INACTIVE: Deactivate (manual) ACTIVE --> INACTIVE: endDate passed (auto) INACTIVE --> ACTIVE: Re-activate (manual)<br>(ensure now < endDate) note right of DRAFT: Editable (metadata, lines, accounts, dates)<br>Type PUBLIC/PRIVATE is immutable once set. note right of ACTIVE: Buyer-visible only when now ∈ [startDate, endDate].<br>Most fields locked to protect existing orders. note right of INACTIVE: Hidden from buyers, may be re-activated after adjusting dates.
🛠️ What you can do in each status
Action / Field | DRAFT | ACTIVE | INACTIVE |
---|---|---|---|
Edit name/description/locales | ✅ | 🔒 | ✅ |
Edit external ID | ✅ | 🔒 | ✅ |
Set type (PUBLIC/PRIVATE) | ✅ (initial choice) | 🔒 (immutable) | 🔒 (immutable) |
Set startDate / endDate | ✅ | 🔒 | ✅ |
Manage lines (add/update/remove) | ✅ | 🔒 (locked; avoid breaking orders) | ✅ (prepare reactivation) |
Attach/detach Accounts (PRIVATE) | ✅ | 🔒 | ✅ |
Publish (→ ACTIVE) | ✅ | — | — |
Deactivate (→ INACTIVE) | — | ✅ (manual) | — |
Re-activate (→ ACTIVE) | — | — | ✅ (ensurenow < endDate ) |
Duplicate | ✅ (new copy is DRAFT) | ✅ (copy current snapshot) | ✅ |
Delete | ✅ (if no orders linked) | ❌ | ❌ |
Locked = strongly discouraged/blocked to avoid inconsistencies with existing orders. Your admin UI should prevent these changes in ACTIVE.
📅 Dates & buyer visibility
- An Operation becomes buyer-visible when:
status = ACTIVE AND
now ∈ [startDate, endDate]
AND the Account/Store/Locale rules are satisfied. - If you set ACTIVE while
now < startDate
, the Operation is scheduled: it will appear to buyers starting atstartDate
(no auto-activation step is needed). - When
endDate
passes, the platform automatically sets status to INACTIVE (if it was ACTIVE).
Practical scheduling Set up everything in DRAFT, then publish (ACTIVE). If the campaign starts later, use a futurestartDate
— the system will gate buyer visibility until that date.
👮 Ownership & permissions (recap)
- Only the creator/owner can modify an Operation.
- Operator users can see any Operation and can set PUBLIC type.
- Customer Users (admin) require a specific right to create/manage Operations and can only attach Accounts they are attached to.
- Standard Djust headers are required on all calls (e.g.,
dj-client
,dj-api-key
, optionaldj-store
,dj-store-view
).
🤖 Automation rules
- Auto-deactivation: if
status=ACTIVE
andnow > endDate
, status becomes INACTIVE automatically. - No auto-activation from DRAFT: activation is manual (publish). Use
startDate
to gate visibility after activation. - Background processing should be idempotent; re-running checks must not flip states incorrectly.
flowchart TD A[Publish request<br>status=ACTIVE] --> B{Valid dates?} B -->|startDate <= endDate| C[Set status=ACTIVE] B -->|invalid| E[Reject & explain] C --> D{now >= startDate?} D -->|yes| V[Buyer-visible] D -->|no| S[Scheduled: hidden until startDate] subgraph Periodic auto job J[now > endDate AND status=ACTIVE?] -->|yes| K[Set status=INACTIVE] J -->|no| L[No change] end
🧪 Common scenarios
Schedule a future campaign
- Create in DRAFT → add lines/accounts → set
startDate
in the future → setendDate
. - Publish (→ ACTIVE).
- Buyers will see it starting at
startDate
.
Pause early
- Set status to INACTIVE before
endDate
. - Optionally adjust dates and re-activate later.
Re-run a past campaign
- Duplicate the finished Operation (new copy in DRAFT).
- Update dates/lines/accounts as needed → publish.
Cannot delete?
- Ensure no cart or order is linked to the Operation. Otherwise, deletion is blocked by design.
🔗 API quicklinks
Status change
- PATCH /admin/operations/(operationId) — ADM-OPERATION-201 (Update Operation status (activate / deactivate)).
Dates & metadata
- PUT /admin/operations/(operationId) — ADM-OPERATION-200 (Update an Operation (e.g., startDate, endDate, name/description)).
- Most edits are DRAFT-only; use PATCH above to change status.
Read / verify
- GET /admin/operations/(operationId) — ADM-OPERATION-500 (Get Operation by ID).
- GET /admin/operations — ADM-OPERATION-550 (List Operations).
- Useful filters: status, ids, name, type, startDateFrom, startDateTo, endDateFrom, endDateTo, ownerIds (also sort, locale).
Deletion (end-of-life)
- DELETE /admin/operations/(operationId) — ADM-OPERATION-300 (Delete Operation).
- Rejected if any cart/order is linked.
Shop (for visibility checks)
- 🔜 GET /shop/operations — Returns only ACTIVE Operations within the current date window.
- 🔜 GET /shop/operations/(id) — Returns 404 if not ACTIVE or outside the window.
Updated 17 days ago