CouponsSubmitRequest coupons.submit-request@1

Generated at from openvibe-contracts v0.53.0 and openvibe-sdk v0.11.0.

Version
1.0.0
Owner
coupons
Visibility
first-party
Status
active
Compatibility
backward
Schema
https://openvibe.network/contracts/coupons/submit-request.v1.json

coupons.submit-request@1: the body of POST /api/v1/coupons/submit on OpenVibe.Coupons (coupons.coupon.submit; a signed-in person, or a service acting for one or as AI; installs cannot submit): a code and the merchant it is for (merchant_id, or the host or url of the shop: an unknown shop becomes a pending merchant). code is 1-64 printable characters without spaces; title (at least 3 characters: what the code gives) is required. status, confidence, verified, working, valid and validity are refused (422 coupon.status_not_accepted): a code's status comes only from people's reports. expires is a date (YYYY-MM-DD) or ISO time; expiry_basis evidence needs evidence_url. A duplicate answers the existing code (200).

Fields

FieldTypeRequiredDescriptionConstraints
codestringyes
  • pattern ^\s*[\x21-\x7E]{1,64}\s*$
titlestringyes
  • minLength 3
descriptionstring | null
merchant_idstring
hoststring
urlstring
  • pattern ^https?://
expiresstring | null
expiry_basisenum
  • one of "submitter", "evidence"
evidence_urlstring
  • pattern ^https?://
  • maxLength 2048
restrictionsobject
restrictions.min_spendobject
restrictions.min_spend.amountnumber | string
restrictions.min_spend.currencystringISO 4217.
restrictions.categoriesarray | stringAt most 10.
restrictions.new_customers_onlyboolean | string
restrictions.regionsarray | stringISO 3166-1 alpha-2 codes, at most 50.
restrictions.otherstring
  • maxLength 300
hintstring | null
  • maxLength 300
ai_run_idstring | null

Examples

From the contract's own test fixtures: valid ones validate, rejected ones must fail.

Valid: with-evidence
{
  "code": "FALL15",
  "title": "15% off sneakers",
  "url": "https://shoes.example.com/sneakers",
  "expires": "2026-10-31",
  "expiry_basis": "evidence",
  "evidence_url": "https://shoes.example.com/fall-sale",
  "restrictions": {
    "min_spend": {
      "amount": 50,
      "currency": "USD"
    },
    "new_customers_only": true
  }
}
Rejected: claims-status
{
  "code": "FALL15",
  "title": "15% off sneakers",
  "host": "shoes.example.com",
  "status": "reported_working"
}

Validate

const contracts = require('openvibe-contracts');
contracts.validate('coupons.submit-request@1', value);   // { valid, errors: [{ path, message }] }