← Receivers

discounts:create

discounts family

Mint a storefront discount code as a scoped coupon row — the workspace is the attested caller, never a body field

Effect
ask
Awaits an outcome — the call returns the response below.
Caller
member
The class of authority the caller must already hold, decided from the attested context with no round trip.
Cost
free
What one call costs, so you can budget before acting.
Reversible
yes
The effect can be undone by a later call.
Idempotent
no
Not safe to blind-retry — dedupe on the envelope idempotencyKey.

Send it with your agent

One click hands your coding agent a prompt that registers the substrate, reads this contract, and makes the call. Launch opens the app; the others copy the prompt.

Claude Code
Codex
Cursor
Gemini CLI
Claude Desktop
ChatGPT
curl -X POST https://one.ie/api/ask/discounts:create \
  -H "Authorization: Bearer $ONE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"data": { "code": <string>, "discount_type": <percentage | fixed_cents>, "discount_value": <number> }}'

The key is never in a link. npx -y @oneie/cli login writes it to ~/.config/oneie/key on your machine.

Request

Validated before dispatch — an invalid payload is refused with the fix, never half-applied.

  • code string required The code a shopper types. Upper-cased and globally unique: a code another seller already owns answers `code_taken`.
  • name string optional Human label for the seller's console. Defaults to the code.
  • discount_type percentage | fixed_cents required `percentage` is unitless and prices both rails. `fixed_cents` is MONEY and prices a cart only — `fixed_credits` is the billing unit and this door will not mint it.
  • discount_value number required Percent (1-100) or whole cents off. Must be finite and positive: a negative value would invert into a surcharge.
  • currency string optional Currency a `fixed_cents` value is denominated in. Defaults to usd; ignored for a percentage.
  • scope storefront | both optional `both` runs one sale on the credits rail AND the shop. Defaults to `storefront`. This door never writes `billing`.
  • cadence once | repeating | forever optional Billing-rail redemption cadence, carried on the shared row. Defaults to `forever`.
  • max_redemptions number optional Total redemptions across all buyers before the code answers `exhausted`. Absent = unlimited.
  • valid_until number optional Unix SECONDS after which the code answers `expired`. Absent = no expiry.

Response

What comes back from the call.

  • ok boolean
  • code string
  • scope string
  • workspace string
  • error string

Traffic

Every call to discounts:create, counted where it is dispatched — over HTTP or in-process alike. Aggregate only — no actor, no payload, no workspace.

Counting…

Wiring

Every place in the open source that names discounts:create, and the file that answers it. Read from the tree at build time — a receiver is reached by NAME through one door, so there is no import edge to follow and a grep is the honest shape of the question. Structure, not volume — the count is in Traffic above.

Called from

UI 1
  • one.ie/web/src/components/studio/DiscountManager.tsx:75

Answered by

discounts:create one.ie/web/src/lib/resolvers/storefront/discounts.ts:340 Dispatched through POST /api/ask/discounts:create, after the envelope validates the payload.

discounts family · 2 more

JSON Schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "code": {
      "type": "string",
      "description": "The code a shopper types. Upper-cased and globally unique: a code another seller already owns answers `code_taken`."
    },
    "name": {
      "description": "Human label for the seller's console. Defaults to the code.",
      "type": "string"
    },
    "discount_type": {
      "type": "string",
      "enum": [
        "percentage",
        "fixed_cents"
      ],
      "description": "`percentage` is unitless and prices both rails. `fixed_cents` is MONEY and prices a cart only — `fixed_credits` is the billing unit and this door will not mint it."
    },
    "discount_value": {
      "type": "number",
      "exclusiveMinimum": 0,
      "description": "Percent (1-100) or whole cents off. Must be finite and positive: a negative value would invert into a surcharge."
    },
    "currency": {
      "description": "Currency a `fixed_cents` value is denominated in. Defaults to usd; ignored for a percentage.",
      "type": "string"
    },
    "scope": {
      "description": "`both` runs one sale on the credits rail AND the shop. Defaults to `storefront`. This door never writes `billing`.",
      "type": "string",
      "enum": [
        "storefront",
        "both"
      ]
    },
    "cadence": {
      "description": "Billing-rail redemption cadence, carried on the shared row. Defaults to `forever`.",
      "type": "string",
      "enum": [
        "once",
        "repeating",
        "forever"
      ]
    },
    "max_redemptions": {
      "description": "Total redemptions across all buyers before the code answers `exhausted`. Absent = unlimited.",
      "type": "integer",
      "exclusiveMinimum": 0,
      "maximum": 9007199254740991
    },
    "valid_until": {
      "description": "Unix SECONDS after which the code answers `expired`. Absent = no expiry.",
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991
    }
  },
  "required": [
    "code",
    "discount_type",
    "discount_value"
  ]
}
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "ok": {
      "type": "boolean"
    },
    "code": {
      "type": "string"
    },
    "scope": {
      "type": "string"
    },
    "workspace": {
      "type": "string"
    },
    "error": {
      "type": "string"
    }
  }
}