AlmondTill/G3N API

Run a promotion

An automatic price rule — create it, adjust it while it runs, and switch it off when it ends; it keeps its history and can come back.

Promotions & loyalty · a play in 3 steps.

The steps

  1. Create the promotion — the automatic rule the till and the storefront apply. — createPromotion
  2. Adjust it while it runs — every edit writes a new revision. — updatePromotion
  3. Switch it off when it ends — it keeps its history. — deactivatePromotion

The calls

Every operation this use case runs, in the order it first appears, with the request and the response its reference page shows.

createPromotion

createPromotion — mutation · Create a new promotion — an automatic price rule at your organization.

Example request

mutation ExampleCreatePromotion($input: NewPromotionInput!) {
  createPromotion(input: $input) {
    id
    sysId
    type
    caption
    status
    parentId
    rootId
    createdAt
    updatedAt
    revisionNum
    revision
    startAt
    endAt
    priority
    exclusive
    combinableGroup
    maxDiscountPerLineMinor
    maxDiscountPerOrderMinor
    totalRedemptionsCap
    couponGated
    code
  }
}

Variables:

{
  "input": {
    "caption": "Blue jeans",
    "effect": {
      "kind": "percent_off",
      "percentPpm": 1
    }
  }
}

Send it with the envelope naming the version: "extensions": {"at": {"version": {"name":"genesis","number":0}}}.

Example response

{
  "data": {
    "createPromotion": {
      "id": "01900000-0000-7000-8000-37386ae00000",
      "sysId": "PM-EXMP-0000-000F",
      "type": "Promotion",
      "caption": "Blue jeans",
      "status": "active",
      "parentId": "01900000-0000-7000-8000-065235280000",
      "rootId": "01900000-0000-7000-8000-a093dd800000",
      "createdAt": "2027-01-31T00:00:00.000Z",
      "updatedAt": "2027-01-31T00:00:00.000Z",
      "revisionNum": 1,
      "revision": "01900000-0000-7000-8000-b7960e180000",
      "startAt": "2027-01-31T00:00:00.000Z",
      "endAt": "2027-01-31T00:00:00.000Z",
      "priority": 1,
      "exclusive": true,
      "combinableGroup": "<combinable group>",
      "maxDiscountPerLineMinor": 1,
      "maxDiscountPerOrderMinor": 1,
      "totalRedemptionsCap": 1,
      "couponGated": true,
      "code": "BJ-001"
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}

updatePromotion

updatePromotion — mutation · Edit a promotion — an automatic price rule — change its details.

Example request

mutation ExampleUpdatePromotion($id: ID!, $revision: ID!, $input: EditPromotionInput!) {
  updatePromotion(id: $id, revision: $revision, input: $input) {
    id
    sysId
    type
    caption
    status
    parentId
    rootId
    createdAt
    updatedAt
    revisionNum
    revision
    startAt
    endAt
    priority
    exclusive
    combinableGroup
    maxDiscountPerLineMinor
    maxDiscountPerOrderMinor
    totalRedemptionsCap
    couponGated
    code
  }
}

Variables:

{
  "id": "01900000-0000-7000-8000-37386ae00000",
  "revision": "01900000-0000-7000-8000-b7960e180000",
  "input": {
    "caption": "Blue jeans"
  }
}

Send it with the envelope naming the version: "extensions": {"at": {"version": {"name":"genesis","number":0}}}.

Example response

{
  "data": {
    "updatePromotion": {
      "id": "01900000-0000-7000-8000-37386ae00000",
      "sysId": "PM-EXMP-0000-000F",
      "type": "Promotion",
      "caption": "Blue jeans",
      "status": "active",
      "parentId": "01900000-0000-7000-8000-065235280000",
      "rootId": "01900000-0000-7000-8000-a093dd800000",
      "createdAt": "2027-01-31T00:00:00.000Z",
      "updatedAt": "2027-01-31T00:00:00.000Z",
      "revisionNum": 1,
      "revision": "01900000-0000-7000-8000-b7960e180000",
      "startAt": "2027-01-31T00:00:00.000Z",
      "endAt": "2027-01-31T00:00:00.000Z",
      "priority": 1,
      "exclusive": true,
      "combinableGroup": "<combinable group>",
      "maxDiscountPerLineMinor": 1,
      "maxDiscountPerOrderMinor": 1,
      "totalRedemptionsCap": 1,
      "couponGated": true,
      "code": "BJ-001"
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}

deactivatePromotion

deactivatePromotion — mutation · Deactivate a promotion — an automatic price rule — it stops being usable but keeps its history and can be reactivated.

Example request

mutation ExampleDeactivatePromotion($id: ID!, $revision: ID!, $reason: String) {
  deactivatePromotion(id: $id, revision: $revision, reason: $reason) {
    id
    sysId
    type
    caption
    status
    parentId
    rootId
    createdAt
    updatedAt
    revisionNum
    revision
    startAt
    endAt
    priority
    exclusive
    combinableGroup
    maxDiscountPerLineMinor
    maxDiscountPerOrderMinor
    totalRedemptionsCap
    couponGated
    code
  }
}

Variables:

{
  "id": "01900000-0000-7000-8000-37386ae00000",
  "revision": "01900000-0000-7000-8000-b7960e180000",
  "reason": "Correcting a miscount."
}

Send it with the envelope naming the version: "extensions": {"at": {"version": {"name":"genesis","number":0}}}.

Example response

{
  "data": {
    "deactivatePromotion": {
      "id": "01900000-0000-7000-8000-37386ae00000",
      "sysId": "PM-EXMP-0000-000F",
      "type": "Promotion",
      "caption": "Blue jeans",
      "status": "active",
      "parentId": "01900000-0000-7000-8000-065235280000",
      "rootId": "01900000-0000-7000-8000-a093dd800000",
      "createdAt": "2027-01-31T00:00:00.000Z",
      "updatedAt": "2027-01-31T00:00:00.000Z",
      "revisionNum": 1,
      "revision": "01900000-0000-7000-8000-b7960e180000",
      "startAt": "2027-01-31T00:00:00.000Z",
      "endAt": "2027-01-31T00:00:00.000Z",
      "priority": 1,
      "exclusive": true,
      "combinableGroup": "<combinable group>",
      "maxDiscountPerLineMinor": 1,
      "maxDiscountPerOrderMinor": 1,
      "totalRedemptionsCap": 1,
      "couponGated": true,
      "code": "BJ-001"
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}