Sign in

Create

POST https://{organization}.myguper.com/api/loyalty/campaign/rule

Adds a rule to a campaign. A rule NARROWS what the campaign matches — the order, the items or the audience — so the campaign only rewards when every rule passes.

A rule is a code (which rule) plus params (the values it checks). The three things that trip people up:

  1. Each code expects a DIFFERENT params format — cents for amounts, arrays of IDs for categories/brands, an object for tier level. Using the wrong shape silently makes the rule never match. The per-code format is listed under params below.
  2. Monetary params are in CENTS. ["250001"] on code 1 means R$ 2.500,01 — not 250k.
  3. The rule's SCOPE must match the campaign's trigger. Codes 1–16 are campaign scope (normal campaigns). Codes 17–18 are member-event scope and only work on a campaign whose trigger is member-event. Mixing them makes the rule dead weight.

The authoritative list comes from GET /api/loyalty/rule; the table below is a snapshot.

Try-it values populated from environment ACME (Demo)


Authentication

Token

Send your user token in the x-guper-authorization header. Endpoints that support a Public mode (e.g. acúmulo and resgate previews) accept the same request without the header — Private mode adds customer data and a confirmation token to the response.

Headers

Name Type Description
x-guper-authorization * string User token issued by Guper. Omit only on endpoints that explicitly support a Public mode.
Content-Type * string Always `application/json` for endpoints that accept a JSON body.

Request body

Content-Type: application/json

{
    "campaign": 1,
    "code": 1,                                                  // 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 16 | 19 | 20 | 17 | 18
    "params": [
        "250001"
    ],
    "reverse": false                                            // optional
}

Responses

Copied to clipboard