CouponsCouponUpdatedPayload coupons.coupon.updated@1
Generated at from
openvibe-contracts v0.34.2 and
openvibe-sdk v0.5.0.
- Version
- 1.0.0
- Owner
- coupons
- Visibility
- first-party
- Status
- active
- Compatibility
- backward
- Schema
https://openvibe.network/contracts/events/payloads/coupons.coupon.updated.v1.json
coupons.coupon.updated v1 (OpenVibe.Coupons server/domain/coupons.js recompute, approve and setExpiry, payload from lifecyclePayload). Emitted in the transaction of the change when (a) a code's status moved to unknown, reported_working or reported_failed: people's reports through the confidence formula (reason report), evidence added or withdrawn (evidence), old reports decaying (decay), or staff or a service re-enabling a disabled or expired code (staff, service:<client>[:<note>]); (b) staff published a code that waited for review (reason approved; status unchanged, so previous_status equals status and may be any status); or (c) the code's expiry was set or cleared (reason expiry_changed, no previous_status; setExpiry has no HTTP route yet). A move to expired or disabled is coupons.coupon.expired or coupons.coupon.disabled instead, and a confidence change without a status change emits only coupons.confidence.changed. Staff notes are reduced to reason staff; a service's note is copied into the reason. Never names a submitter, reporter or staff member. Envelope: subject { type: coupon, id: cpn_… }, visibility public when the code is publicly listed after the change (recompute: before or after), otherwise internal, priority important (not set: the Events default), actor service:coupons. No known consumers.
Fields
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
merchant_id | string | yes | The merchant the code belongs to. |
|
status | enum | yes | Status after the change. expired and disabled occur only with reason approved or expiry_changed (neither moves the status). |
|
confidence | number | null | yes | Report confidence after the change, rounded to 2 decimals; null = no counted report in the last 30 days. |
|
review_state | enum | yes |
| |
expires_at | string | null | yes | Known expiry (UTC); null = expiry unknown. |
|
canonical_url | string | yes | The code's page on Coupons (<origin>/c/<coupon id>). |
|
previous_status | enum | Status before the change. Absent with reason expiry_changed. |
| |
reason | one of | yes | Why it changed: report, evidence, decay, staff, approved, expiry_changed, or service:<client>[:<note>] when a service holding coupons.status.update re-enabled it. |
Examples
From the contract's own test fixtures: valid ones validate, rejected ones must fail.
Valid: expiry-changed
{
"merchant_id": "mer_01K5R7A1B2C3D4E5F6G7H8J9KM",
"status": "unknown",
"confidence": null,
"review_state": "published",
"expires_at": "2026-12-31T23:59:59.999Z",
"canonical_url": "https://openvibe.coupons/c/cpn_01K5R8Z3Q4M2N7P9T1V6W8X0YA",
"reason": "expiry_changed"
}Valid: report-working
{
"merchant_id": "mer_01K5R7A1B2C3D4E5F6G7H8J9KM",
"status": "reported_working",
"confidence": 0.67,
"review_state": "published",
"expires_at": null,
"canonical_url": "https://openvibe.coupons/c/cpn_01K5R8Z3Q4M2N7P9T1V6W8X0YA",
"previous_status": "unknown",
"reason": "report"
}Valid: service-reenabled
{
"merchant_id": "mer_01K5R7A1B2C3D4E5F6G7H8J9KM",
"status": "unknown",
"confidence": null,
"review_state": "published",
"expires_at": null,
"canonical_url": "https://openvibe.coupons/c/cpn_01K5R8Z3Q4M2N7P9T1V6W8X0YA",
"previous_status": "disabled",
"reason": "service:moderation:takedown reviewed, code restored"
}Rejected: bad-merchant-id
{
"merchant_id": "acme-outdoor",
"status": "reported_working",
"confidence": 0.67,
"review_state": "published",
"expires_at": null,
"canonical_url": "https://openvibe.coupons/c/cpn_01K5R8Z3Q4M2N7P9T1V6W8X0YA",
"previous_status": "unknown",
"reason": "report"
}Rejected: free-text-reason
{
"merchant_id": "mer_01K5R7A1B2C3D4E5F6G7H8J9KM",
"status": "reported_failed",
"confidence": 0.33,
"review_state": "published",
"expires_at": null,
"canonical_url": "https://openvibe.coupons/c/cpn_01K5R8Z3Q4M2N7P9T1V6W8X0YA",
"previous_status": "unknown",
"reason": "staff:customer complained"
}Rejected: missing-reason
{
"merchant_id": "mer_01K5R7A1B2C3D4E5F6G7H8J9KM",
"status": "reported_working",
"confidence": 0.67,
"review_state": "published",
"expires_at": null,
"canonical_url": "https://openvibe.coupons/c/cpn_01K5R8Z3Q4M2N7P9T1V6W8X0YA",
"previous_status": "unknown"
}Validate
const contracts = require('openvibe-contracts');
contracts.validate('coupons.coupon.updated@1', value); // { valid, errors: [{ path, message }] }