Topolo Docs Topolo Platform
Open workspace

Create a reusable offer — Campaigns

Stores one workspace offer with kind, numeric value, optional label and rules. This neither activates a campaign nor issues a code.

Create a reusable offer

Stores one workspace offer with kind, numeric value, optional label and rules. This neither activates a campaign nor issues a code.

Outcome and boundaries

Stores one workspace offer with kind, numeric value, optional label and rules. This neither activates a campaign nor issues a code.

Before you start

  • Confirm the intended environment and current credential organization using whoami; discover the exact application/action before any call.
  • Required application permission: app_topolo_campaigns.offers:write. Catalog discoverability is not permission to execute.
  • Discover an authorized canonical workspace and bind resourceType workspace/resourceId separately from action input.
  • All worked cases in this guide are hypothetical source-reviewed illustrations; no business action, live fixture, customer data or provider request was executed.
  • Canonical workspace minimum access is read_write in addition to the application permission. After grant verification, the first request may create an app-local identity/recipient mirror even before the later app-permission check; this is not campaign-domain completion.

Discover the intended identifiers

  • Discover the workspace and offers.list; choose a descriptive label and the intended offer kind before writing.

Action: app_topolo_campaigns.offers.create · POST /api/offers.

Input fields

FieldRequiredMeaning and validation
kindYesOffer kind from the exact enum. Financial interpretation must follow the owning consuming service; no charge is made here. string; enum=["discount_pct", "discount_fixed", "trial_extension", "gift", "credit"]
valueNoNumeric meaning depends on kind. discount_pct is a percentage value; other kinds have no currency/unit enforcement in this store. Do not infer cents, payment collection or payout. number
labelNoHuman-readable stored label; no external delivery or printing occurs. string
rulesNoStored object. Code evaluation reads validFrom, validTo and maxRedemptions; redeem additionally reads maxPerUser when redeemedBy exists. No blanket enforcement of arbitrary rule keys is claimed. object

Safe call sequence

Write the reviewed input to payload.json; fixture identifiers below are unusable examples. Validate before planning, bind the discovered resource separately, and execute only within actual authority.

topolo actions validate app_topolo_campaigns.offers.create --data @payload.json --json
topolo actions plan app_topolo_campaigns.offers.create --resource-type workspace --resource-id "$CAMPAIGNS_WORKSPACE_ID" --data @payload.json --json

The published action requires confirmation. Only after the exact mutation is authorized, use that same payload/context with --confirm on plan/call; no operation in this guide has been executed.

Worked cases

Every response below is synthetic and source-reviewed, not captured. HTTP status and body are explained independently; a structurally valid body alone never proves successful execution. Middleware may add a different error envelope.

Store a percent offer with source-recognized dates · HTTP 201

Input:

{
  "kind": "discount_pct",
  "value": 15,
  "label": "Illustrative 15 percent",
  "rules": {
    "validFrom": "2026-10-20T00:00:00Z",
    "validTo": "2026-11-20T00:00:00Z"
  }
}

Illustrative response:

{
  "offer": {
    "id": "offer_example",
    "kind": "discount_pct",
    "value": 15,
    "label": "Illustrative 15 percent",
    "rules": {
      "validFrom": "2026-10-20T00:00:00Z",
      "validTo": "2026-11-20T00:00:00Z"
    },
    "createdAt": "2026-10-20T00:00:00.000Z",
    "updatedAt": "2026-10-20T00:00:00.000Z"
  }
}

Minimal offer uses zero/default fields · HTTP 201

Input:

{
  "kind": "gift"
}

Illustrative response:

{
  "offer": {
    "id": "offer_example",
    "kind": "gift",
    "value": 0,
    "label": "",
    "rules": {},
    "createdAt": "2026-10-20T00:00:00.000Z",
    "updatedAt": "2026-10-20T00:00:00.000Z"
  }
}

Permission refusal · HTTP 403

Input:

{
  "kind": "gift"
}

Illustrative response:

{
  "error": "forbidden"
}

Verify the outcome

  • Use offers.list to match offer.id, kind, value and rules, then pass the id only to a same-workspace campaign.

Refusals and recovery

  • HTTP 400 invalid_offer_kind: Correct the named input or retain the authoritative refusal in the same context.
  • HTTP 403 forbidden: Raw handler permission refusal. SDKs can normalize it to permission_denied. Keep the same intended resource; do not widen access.
  • HTTP 403 workspace_forbidden: The canonical workspace grant refused the selected resource. Resolve it with the access owner, not a guessed workspace.

No deletion or exact undo is published for this record. Preserve the returned identifier and inspect the corresponding list before considering another separately authorized operation. A timeout does not prove that nothing was written.

Source and catalog limits

Published name_required is not a source check: label is optional. Existing illustrative startsAt/expiresAt keys are not the validFrom/validTo fields read by code evaluation. Source stores arbitrary rules; minPurchase is declared in the interface but not checked by evaluateCode. No offer update or deletion action is published.

Exact schemas and provenance

Input schema:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "kind": {
      "type": "string",
      "enum": [
        "discount_pct",
        "discount_fixed",
        "trial_extension",
        "gift",
        "credit"
      ]
    },
    "value": {
      "type": "number"
    },
    "label": {
      "type": "string"
    },
    "rules": {
      "type": "object",
      "properties": {},
      "additionalProperties": {}
    }
  },
  "required": [
    "kind"
  ],
  "additionalProperties": false
}

Output schema:

{
  "type": "object",
  "title": "Create offer response",
  "description": "Operation result returned by offers.create.",
  "properties": {
    "success": {
      "type": "boolean"
    },
    "id": {
      "type": "string"
    },
    "data": {
      "anyOf": [
        {
          "type": "object",
          "title": "offer record",
          "properties": {
            "id": {
              "type": "string",
              "description": "Stable identifier when the offer exposes one."
            }
          },
          "additionalProperties": true
        },
        {
          "type": "object",
          "additionalProperties": true
        }
      ]
    },
    "result": {
      "type": "object",
      "additionalProperties": true
    },
    "message": {
      "type": "string"
    }
  },
  "additionalProperties": true,
  "x-topolo-contract-source": "derived-action-metadata",
  "x-topolo-contract-precision": "structural"
}

Reviewed immutable source: TopoloCampaigns@cacbb8b12b4e19a662cf82d03a927aef3c3a35e8, apps/api/src/campaigns-store.ts. Fresh production catalog was read on 2026-10-20. Its publication metadata is not proof that this source is loaded. Output examples are not widened or rewritten to force schema success; the accompanying validation record classifies exact success, refusal, no-body and structural-schema limits.

  • List workspace offers — Campaigns: Lists stored offers in the bound organization/workspace, newest creation first. Reading an offer does not establish that any campaign or code uses it.
  • Create a draft campaign — Campaigns: Creates one draft campaign. Optional offerId must resolve in the selected organization/workspace. Creating it neither activates redemption nor issues codes.

Local input rejection example

This deliberately invalid input belongs to a pure schema check; it is never a planned or executed request. The closed action input schema must reject the extra field. It has no HTTP status or server response.

{
  "kind": "discount_pct",
  "value": 15,
  "label": "Illustrative 15 percent",
  "rules": {
    "validFrom": "2026-10-20T00:00:00Z",
    "validTo": "2026-11-20T00:00:00Z"
  },
  "__unsupported_field": true
}

The hidden companion labels this as ILLUSTRATIVE_LOCAL_SCHEMA_CHECK; its validation representation is not an action output.

Published output validation limits

Current published output qualification: the output schema accepts an empty object, a partial success marker, a partial data object and a refusal body. It therefore establishes only broad structure. Require the documented HTTP/domain result and source-shaped fields; missing fields or a schema-valid error are not success.

These observations come from pure checks of the exact published schema; they are not server responses or production captures.