Docs
Dashboard
On this page

    Discounts

    14 endpoints. Each needs an API key or OAuth token with the scope shown; the key already names its store, so paths start at /v1/store. Generated from the live contract; also in openapi.json.

    Discount codes and automatic discounts with uses and revenue

    GET/v1/store/discounts

    Or name the store: GET /v1/stores/{storeId}/discounts

    marketing:readlistDiscounts

    Parameters

    • tab"all" | "active" | "scheduled" | "expired" | "disabled"query
    • qstring | nullquery

    Response ListDiscountsResponse

    • itemsDiscount[]required
    • countsDiscountCountsrequired

    Example

    curl "https://api.shopfa.st/v1/store/discounts" \
      -H "Authorization: Bearer $SHOPFAST_API_KEY"
    const res = await fetch('https://api.shopfa.st/v1/store/discounts', {
      method: 'GET',
      headers: {
        Authorization: `Bearer ${process.env.SHOPFAST_API_KEY}`,
      },
    });
    if (!res.ok) throw new Error((await res.json()).detail);
    const data = await res.json();
    import os, requests
    
    res = requests.request(
        "GET",
        "https://api.shopfa.st/v1/store/discounts",
        headers={"Authorization": f"Bearer {os.environ['SHOPFAST_API_KEY']}"},
    )
    res.raise_for_status()
    data = res.json()
    req, _ := http.NewRequest("GET", "https://api.shopfa.st/v1/store/discounts", nil)
    req.Header.Set("Authorization", "Bearer "+os.Getenv("SHOPFAST_API_KEY"))
    res, err := http.DefaultClient.Do(req)
    Try it with your key

    Use a test key on a development store. The key stays in this tab (sessionStorage) and is sent only to the base URL above.

    Create a discount

    POST/v1/store/discounts

    Or name the store: POST /v1/stores/{storeId}/discounts

    marketing:writecreateDiscount

    Body

    • kind"code" | "automatic"required
    • codestring | nullrequired
    • titlestringrequired
    • valueType"percent" | "fixed" | "free"required
    • valueintegerrequired
    • scope"all" | "products" | "collections" | "categories"required
    • productIdsprd_…[]required
    • collectionIdscol_…[]required
    • categoryIdspcat_…[]
    • minSubtotalMinorintegerrequired
    • usageLimitinteger | nullrequired
    • perCustomerLimitinteger | nullrequired
    • startsAtstringrequired
    • endsAtstring | nullrequired
    • combinablebooleanrequired
    • autoAddFreeProductsbooleanrequired
    • enabledbooleanrequired
    • disabledMethods"card" | "apple_pay" | "google_pay" | "paypal" | "crypto" | "bank_transfer" | "store_credit" | "manual" | "cash_app" | "skins" | "gift_code"[]
    • variantIdsvar_…[]
    • showInAccountboolean
    • firstOrderOnlyboolean
    • minQuantityinteger
    • durations"1d" | "3d" | "7d" | "14d" | "30d" | "90d" | "180d" | "365d" | "lifetime"[]
    • ruleobject
    • excludeSaleItemsboolean
    • priorityinteger
    • activeHoursobject | null
    • bulkCodesboolean

    Response Discount

    • kindDiscountKindrequired
    • codeDiscountCode | nullrequired
    • titlestringrequired
    • valueTypeDiscountValueTyperequired
    • valueintegerrequired
    • scopeDiscountScoperequired
    • productIdsProductId[]required
    • collectionIdsCollectionId[]required
    • categoryIdsCategoryId[]required
    • minSubtotalMinorMinorUnitsrequired
    26 more fields
    • usageLimitinteger | nullrequired
    • perCustomerLimitinteger | nullrequired
    • startsAtTimestamprequired
    • endsAtTimestamp | nullrequired
    • combinablebooleanrequired
    • autoAddFreeProductsbooleanrequired
    • enabledbooleanrequired
    • disabledMethodsPaymentMethod[]required
    • variantIdsVariantId[]required
    • showInAccountbooleanrequired
    • firstOrderOnlybooleanrequired
    • minQuantityintegerrequired
    • durationsDurationKey[]required
    • ruleDiscountRulerequired
    • excludeSaleItemsbooleanrequired
    • priorityintegerrequired
    • activeHoursActiveHours | nullrequired
    • bulkCodesbooleanrequired
    • idDiscountIdrequired
    • statusDiscountStatusrequired
    • timesUsedintegerrequired
    • revenueMinorMinorUnitsrequired
    • discountedMinorMinorUnitsrequired
    • currencyCurrencyCoderequired
    • createdAtTimestamprequired
    • updatedAtTimestamprequired

    Example

    curl -X POST "https://api.shopfa.st/v1/store/discounts" \
      -H "Authorization: Bearer $SHOPFAST_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
      "kind": "code",
      "code": "string",
      "title": "string",
      "valueType": "percent",
      "value": 0,
      "scope": "all",
      "productIds": [
        "prd_0123456789abcdefghjk"
      ],
      "collectionIds": [
        "col_0123456789abcdefghjk"
      ],
      "categoryIds": [],
      "minSubtotalMinor": 0,
      "usageLimit": 1,
      "perCustomerLimit": 1,
      "startsAt": "2026-10-21T12:00:00.000Z",
      "endsAt": "2026-10-21T12:00:00.000Z",
      "combinable": false,
      "autoAddFreeProducts": false,
      "enabled": false,
      "disabledMethods": [],
      "variantIds": [],
      "showInAccount": false,
      "firstOrderOnly": false,
      "minQuantity": 0,
      "durations": [],
      "rule": {
        "type": "standard"
      },
      "excludeSaleItems": false,
      "priority": 50,
      "activeHours": null,
      "bulkCodes": false
    }'
    const res = await fetch('https://api.shopfa.st/v1/store/discounts', {
      method: 'POST',
      headers: {
        Authorization: `Bearer ${process.env.SHOPFAST_API_KEY}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        "kind": "code",
        "code": "string",
        "title": "string",
        "valueType": "percent",
        "value": 0,
        "scope": "all",
        "productIds": [
          "prd_0123456789abcdefghjk"
        ],
        "collectionIds": [
          "col_0123456789abcdefghjk"
        ],
        "categoryIds": [],
        "minSubtotalMinor": 0,
        "usageLimit": 1,
        "perCustomerLimit": 1,
        "startsAt": "2026-10-21T12:00:00.000Z",
        "endsAt": "2026-10-21T12:00:00.000Z",
        "combinable": false,
        "autoAddFreeProducts": false,
        "enabled": false,
        "disabledMethods": [],
        "variantIds": [],
        "showInAccount": false,
        "firstOrderOnly": false,
        "minQuantity": 0,
        "durations": [],
        "rule": {
          "type": "standard"
        },
        "excludeSaleItems": false,
        "priority": 50,
        "activeHours": null,
        "bulkCodes": false
      }),
    });
    if (!res.ok) throw new Error((await res.json()).detail);
    const data = await res.json();
    import os, requests
    
    res = requests.request(
        "POST",
        "https://api.shopfa.st/v1/store/discounts",
        headers={"Authorization": f"Bearer {os.environ['SHOPFAST_API_KEY']}"},
        json={
          "kind": "code",
          "code": "string",
          "title": "string",
          "valueType": "percent",
          "value": 0,
          "scope": "all",
          "productIds": [
            "prd_0123456789abcdefghjk"
          ],
          "collectionIds": [
            "col_0123456789abcdefghjk"
          ],
          "categoryIds": [],
          "minSubtotalMinor": 0,
          "usageLimit": 1,
          "perCustomerLimit": 1,
          "startsAt": "2026-10-21T12:00:00.000Z",
          "endsAt": "2026-10-21T12:00:00.000Z",
          "combinable": False,
          "autoAddFreeProducts": False,
          "enabled": False,
          "disabledMethods": [],
          "variantIds": [],
          "showInAccount": False,
          "firstOrderOnly": False,
          "minQuantity": 0,
          "durations": [],
          "rule": {
            "type": "standard"
          },
          "excludeSaleItems": False,
          "priority": 50,
          "activeHours": None,
          "bulkCodes": False
        },
    )
    res.raise_for_status()
    data = res.json()
    req, _ := http.NewRequest("POST", "https://api.shopfa.st/v1/store/discounts", strings.NewReader(`{
      "kind": "code",
      "code": "string",
      "title": "string",
      "valueType": "percent",
      "value": 0,
      "scope": "all",
      "productIds": [
        "prd_0123456789abcdefghjk"
      ],
      "collectionIds": [
        "col_0123456789abcdefghjk"
      ],
      "categoryIds": [],
      "minSubtotalMinor": 0,
      "usageLimit": 1,
      "perCustomerLimit": 1,
      "startsAt": "2026-10-21T12:00:00.000Z",
      "endsAt": "2026-10-21T12:00:00.000Z",
      "combinable": false,
      "autoAddFreeProducts": false,
      "enabled": false,
      "disabledMethods": [],
      "variantIds": [],
      "showInAccount": false,
      "firstOrderOnly": false,
      "minQuantity": 0,
      "durations": [],
      "rule": {
        "type": "standard"
      },
      "excludeSaleItems": false,
      "priority": 50,
      "activeHours": null,
      "bulkCodes": false
    }`))
    req.Header.Set("Authorization", "Bearer "+os.Getenv("SHOPFAST_API_KEY"))
    req.Header.Set("Content-Type", "application/json")
    res, err := http.DefaultClient.Do(req)
    Try it with your key

    Use a test key on a development store. The key stays in this tab (sessionStorage) and is sent only to the base URL above.

    Update a discount (orders already paid keep their discount)

    PUT/v1/store/discounts/{discountId}

    Or name the store: PUT /v1/stores/{storeId}/discounts/{discountId}

    marketing:writeupdateDiscount

    Parameters

    • discountIddsc_…pathrequired

    Body

    • kind"code" | "automatic"required
    • codestring | nullrequired
    • titlestringrequired
    • valueType"percent" | "fixed" | "free"required
    • valueintegerrequired
    • scope"all" | "products" | "collections" | "categories"required
    • productIdsprd_…[]required
    • collectionIdscol_…[]required
    • categoryIdspcat_…[]
    • minSubtotalMinorintegerrequired
    • usageLimitinteger | nullrequired
    • perCustomerLimitinteger | nullrequired
    • startsAtstringrequired
    • endsAtstring | nullrequired
    • combinablebooleanrequired
    • autoAddFreeProductsbooleanrequired
    • enabledbooleanrequired
    • disabledMethods"card" | "apple_pay" | "google_pay" | "paypal" | "crypto" | "bank_transfer" | "store_credit" | "manual" | "cash_app" | "skins" | "gift_code"[]
    • variantIdsvar_…[]
    • showInAccountboolean
    • firstOrderOnlyboolean
    • minQuantityinteger
    • durations"1d" | "3d" | "7d" | "14d" | "30d" | "90d" | "180d" | "365d" | "lifetime"[]
    • ruleobject
    • excludeSaleItemsboolean
    • priorityinteger
    • activeHoursobject | null
    • bulkCodesboolean

    Response Discount

    • kindDiscountKindrequired
    • codeDiscountCode | nullrequired
    • titlestringrequired
    • valueTypeDiscountValueTyperequired
    • valueintegerrequired
    • scopeDiscountScoperequired
    • productIdsProductId[]required
    • collectionIdsCollectionId[]required
    • categoryIdsCategoryId[]required
    • minSubtotalMinorMinorUnitsrequired
    26 more fields
    • usageLimitinteger | nullrequired
    • perCustomerLimitinteger | nullrequired
    • startsAtTimestamprequired
    • endsAtTimestamp | nullrequired
    • combinablebooleanrequired
    • autoAddFreeProductsbooleanrequired
    • enabledbooleanrequired
    • disabledMethodsPaymentMethod[]required
    • variantIdsVariantId[]required
    • showInAccountbooleanrequired
    • firstOrderOnlybooleanrequired
    • minQuantityintegerrequired
    • durationsDurationKey[]required
    • ruleDiscountRulerequired
    • excludeSaleItemsbooleanrequired
    • priorityintegerrequired
    • activeHoursActiveHours | nullrequired
    • bulkCodesbooleanrequired
    • idDiscountIdrequired
    • statusDiscountStatusrequired
    • timesUsedintegerrequired
    • revenueMinorMinorUnitsrequired
    • discountedMinorMinorUnitsrequired
    • currencyCurrencyCoderequired
    • createdAtTimestamprequired
    • updatedAtTimestamprequired

    Example

    curl -X PUT "https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk" \
      -H "Authorization: Bearer $SHOPFAST_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
      "kind": "code",
      "code": "string",
      "title": "string",
      "valueType": "percent",
      "value": 0,
      "scope": "all",
      "productIds": [
        "prd_0123456789abcdefghjk"
      ],
      "collectionIds": [
        "col_0123456789abcdefghjk"
      ],
      "categoryIds": [],
      "minSubtotalMinor": 0,
      "usageLimit": 1,
      "perCustomerLimit": 1,
      "startsAt": "2026-10-21T12:00:00.000Z",
      "endsAt": "2026-10-21T12:00:00.000Z",
      "combinable": false,
      "autoAddFreeProducts": false,
      "enabled": false,
      "disabledMethods": [],
      "variantIds": [],
      "showInAccount": false,
      "firstOrderOnly": false,
      "minQuantity": 0,
      "durations": [],
      "rule": {
        "type": "standard"
      },
      "excludeSaleItems": false,
      "priority": 50,
      "activeHours": null,
      "bulkCodes": false
    }'
    const res = await fetch('https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk', {
      method: 'PUT',
      headers: {
        Authorization: `Bearer ${process.env.SHOPFAST_API_KEY}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        "kind": "code",
        "code": "string",
        "title": "string",
        "valueType": "percent",
        "value": 0,
        "scope": "all",
        "productIds": [
          "prd_0123456789abcdefghjk"
        ],
        "collectionIds": [
          "col_0123456789abcdefghjk"
        ],
        "categoryIds": [],
        "minSubtotalMinor": 0,
        "usageLimit": 1,
        "perCustomerLimit": 1,
        "startsAt": "2026-10-21T12:00:00.000Z",
        "endsAt": "2026-10-21T12:00:00.000Z",
        "combinable": false,
        "autoAddFreeProducts": false,
        "enabled": false,
        "disabledMethods": [],
        "variantIds": [],
        "showInAccount": false,
        "firstOrderOnly": false,
        "minQuantity": 0,
        "durations": [],
        "rule": {
          "type": "standard"
        },
        "excludeSaleItems": false,
        "priority": 50,
        "activeHours": null,
        "bulkCodes": false
      }),
    });
    if (!res.ok) throw new Error((await res.json()).detail);
    const data = await res.json();
    import os, requests
    
    res = requests.request(
        "PUT",
        "https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk",
        headers={"Authorization": f"Bearer {os.environ['SHOPFAST_API_KEY']}"},
        json={
          "kind": "code",
          "code": "string",
          "title": "string",
          "valueType": "percent",
          "value": 0,
          "scope": "all",
          "productIds": [
            "prd_0123456789abcdefghjk"
          ],
          "collectionIds": [
            "col_0123456789abcdefghjk"
          ],
          "categoryIds": [],
          "minSubtotalMinor": 0,
          "usageLimit": 1,
          "perCustomerLimit": 1,
          "startsAt": "2026-10-21T12:00:00.000Z",
          "endsAt": "2026-10-21T12:00:00.000Z",
          "combinable": False,
          "autoAddFreeProducts": False,
          "enabled": False,
          "disabledMethods": [],
          "variantIds": [],
          "showInAccount": False,
          "firstOrderOnly": False,
          "minQuantity": 0,
          "durations": [],
          "rule": {
            "type": "standard"
          },
          "excludeSaleItems": False,
          "priority": 50,
          "activeHours": None,
          "bulkCodes": False
        },
    )
    res.raise_for_status()
    data = res.json()
    req, _ := http.NewRequest("PUT", "https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk", strings.NewReader(`{
      "kind": "code",
      "code": "string",
      "title": "string",
      "valueType": "percent",
      "value": 0,
      "scope": "all",
      "productIds": [
        "prd_0123456789abcdefghjk"
      ],
      "collectionIds": [
        "col_0123456789abcdefghjk"
      ],
      "categoryIds": [],
      "minSubtotalMinor": 0,
      "usageLimit": 1,
      "perCustomerLimit": 1,
      "startsAt": "2026-10-21T12:00:00.000Z",
      "endsAt": "2026-10-21T12:00:00.000Z",
      "combinable": false,
      "autoAddFreeProducts": false,
      "enabled": false,
      "disabledMethods": [],
      "variantIds": [],
      "showInAccount": false,
      "firstOrderOnly": false,
      "minQuantity": 0,
      "durations": [],
      "rule": {
        "type": "standard"
      },
      "excludeSaleItems": false,
      "priority": 50,
      "activeHours": null,
      "bulkCodes": false
    }`))
    req.Header.Set("Authorization", "Bearer "+os.Getenv("SHOPFAST_API_KEY"))
    req.Header.Set("Content-Type", "application/json")
    res, err := http.DefaultClient.Do(req)
    Try it with your key

    Use a test key on a development store. The key stays in this tab (sessionStorage) and is sent only to the base URL above.

    Delete a discount that was never used (disable used ones)

    DELETE/v1/store/discounts/{discountId}

    Or name the store: DELETE /v1/stores/{storeId}/discounts/{discountId}

    marketing:writedeleteDiscount

    Parameters

    • discountIddsc_…pathrequired

    Response Ok

    • okbooleanrequired

    Example

    curl -X DELETE "https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk" \
      -H "Authorization: Bearer $SHOPFAST_API_KEY"
    const res = await fetch('https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk', {
      method: 'DELETE',
      headers: {
        Authorization: `Bearer ${process.env.SHOPFAST_API_KEY}`,
      },
    });
    if (!res.ok) throw new Error((await res.json()).detail);
    const data = await res.json();
    import os, requests
    
    res = requests.request(
        "DELETE",
        "https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk",
        headers={"Authorization": f"Bearer {os.environ['SHOPFAST_API_KEY']}"},
    )
    res.raise_for_status()
    data = res.json()
    req, _ := http.NewRequest("DELETE", "https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk", nil)
    req.Header.Set("Authorization", "Bearer "+os.Getenv("SHOPFAST_API_KEY"))
    res, err := http.DefaultClient.Do(req)
    Try it with your key

    Use a test key on a development store. The key stays in this tab (sessionStorage) and is sent only to the base URL above.

    Orders, customers, revenue and a daily series for one discount

    GET/v1/store/discounts/{discountId}/analytics

    Or name the store: GET /v1/stores/{storeId}/discounts/{discountId}/analytics

    marketing:readrole: marketing:readgetDiscountAnalytics

    Parameters

    • discountIddsc_…pathrequired
    • daysinteger | stringquery

    Response DiscountAnalytics

    • discountIdstringrequired
    • currencyCurrencyCoderequired
    • ordersintegerrequired
    • customersintegerrequired
    • revenueMinorMinorUnitsrequired
    • discountedMinorMinorUnitsrequired
    • averageOrderMinorMinorUnitsrequired
    • seriesobject[]required
      • dateIsoDaterequired
      • ordersintegerrequired
      • revenueMinorMinorUnitsrequired
      • discountedMinorMinorUnitsrequired
    • recentobject[]required
      • orderIdOrderIdrequired
      • numberstringrequired
      • emailEmailrequired
      • totalMinorMinorUnitsrequired
      • discountMinorMinorUnitsrequired
      • statusOrderStatusrequired
      • createdAtTimestamprequired

    Example

    curl "https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/analytics" \
      -H "Authorization: Bearer $SHOPFAST_API_KEY"
    const res = await fetch('https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/analytics', {
      method: 'GET',
      headers: {
        Authorization: `Bearer ${process.env.SHOPFAST_API_KEY}`,
      },
    });
    if (!res.ok) throw new Error((await res.json()).detail);
    const data = await res.json();
    import os, requests
    
    res = requests.request(
        "GET",
        "https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/analytics",
        headers={"Authorization": f"Bearer {os.environ['SHOPFAST_API_KEY']}"},
    )
    res.raise_for_status()
    data = res.json()
    req, _ := http.NewRequest("GET", "https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/analytics", nil)
    req.Header.Set("Authorization", "Bearer "+os.Getenv("SHOPFAST_API_KEY"))
    res, err := http.DefaultClient.Do(req)
    Try it with your key

    Use a test key on a development store. The key stays in this tab (sessionStorage) and is sent only to the base URL above.

    Delete the chosen discounts; ones already used in orders are disabled instead so their history stays

    POST/v1/store/discounts/bulk-delete

    Or name the store: POST /v1/stores/{storeId}/discounts/bulk-delete

    marketing:writerole: marketing:writebulkDeleteDiscounts

    Body

    • idsdsc_…[]required

    Response BulkDeleteDiscountsResponse

    • deletedintegerrequired
    • disabledintegerrequired

    Example

    curl -X POST "https://api.shopfa.st/v1/store/discounts/bulk-delete" \
      -H "Authorization: Bearer $SHOPFAST_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
      "ids": [
        "dsc_0123456789abcdefghjk"
      ]
    }'
    const res = await fetch('https://api.shopfa.st/v1/store/discounts/bulk-delete', {
      method: 'POST',
      headers: {
        Authorization: `Bearer ${process.env.SHOPFAST_API_KEY}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        "ids": [
          "dsc_0123456789abcdefghjk"
        ]
      }),
    });
    if (!res.ok) throw new Error((await res.json()).detail);
    const data = await res.json();
    import os, requests
    
    res = requests.request(
        "POST",
        "https://api.shopfa.st/v1/store/discounts/bulk-delete",
        headers={"Authorization": f"Bearer {os.environ['SHOPFAST_API_KEY']}"},
        json={
          "ids": [
            "dsc_0123456789abcdefghjk"
          ]
        },
    )
    res.raise_for_status()
    data = res.json()
    req, _ := http.NewRequest("POST", "https://api.shopfa.st/v1/store/discounts/bulk-delete", strings.NewReader(`{
      "ids": [
        "dsc_0123456789abcdefghjk"
      ]
    }`))
    req.Header.Set("Authorization", "Bearer "+os.Getenv("SHOPFAST_API_KEY"))
    req.Header.Set("Content-Type", "application/json")
    res, err := http.DefaultClient.Do(req)
    Try it with your key

    Use a test key on a development store. The key stays in this tab (sessionStorage) and is sent only to the base URL above.

    A discount's generated codes with their uses

    GET/v1/store/discounts/{discountId}/codes

    Or name the store: GET /v1/stores/{storeId}/discounts/{discountId}/codes

    marketing:readrole: marketing:readlistDiscountCodes

    Parameters

    • discountIddsc_…pathrequired
    • tab"all" | "unused" | "used" | "disabled"query
    • qstringquery
    • pageinteger | stringquery
    • sort"created" | "code" | "uses" | "email" | "source" | "last"query
    • dir"asc" | "desc"query

    Response DiscountCodePage

    • itemsDiscountCodeRow[]required
    • totalintegerrequired
    • countsobjectrequired
      • allintegerrequired
      • unusedintegerrequired
      • usedintegerrequired
      • disabledintegerrequired
    • batchesobject[]required
      • idCodeBatchIdrequired
      • prefixstringrequired
      • countintegerrequired
      • usesPerCodeintegerrequired
      • createdAtTimestamprequired

    Example

    curl "https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/codes" \
      -H "Authorization: Bearer $SHOPFAST_API_KEY"
    const res = await fetch('https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/codes', {
      method: 'GET',
      headers: {
        Authorization: `Bearer ${process.env.SHOPFAST_API_KEY}`,
      },
    });
    if (!res.ok) throw new Error((await res.json()).detail);
    const data = await res.json();
    import os, requests
    
    res = requests.request(
        "GET",
        "https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/codes",
        headers={"Authorization": f"Bearer {os.environ['SHOPFAST_API_KEY']}"},
    )
    res.raise_for_status()
    data = res.json()
    req, _ := http.NewRequest("GET", "https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/codes", nil)
    req.Header.Set("Authorization", "Bearer "+os.Getenv("SHOPFAST_API_KEY"))
    res, err := http.DefaultClient.Do(req)
    Try it with your key

    Use a test key on a development store. The key stays in this tab (sessionStorage) and is sent only to the base URL above.

    Generate unique codes for a discount (prefix, count, uses per code, optional email per code)

    POST/v1/store/discounts/{discountId}/codes

    Or name the store: POST /v1/stores/{storeId}/discounts/{discountId}/codes

    marketing:writerole: marketing:writegenerateDiscountCodes

    Parameters

    • discountIddsc_…pathrequired

    Body

    • prefixstring
    • countintegerrequired
    • lengthinteger
    • usesPerCodeinteger
    • emailsstring[]

    Response GeneratedCodes

    • batchIdCodeBatchIdrequired
    • createdintegerrequired
    • samplestring[]required

    Example

    curl -X POST "https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/codes" \
      -H "Authorization: Bearer $SHOPFAST_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
      "prefix": "",
      "count": 1,
      "length": 8,
      "usesPerCode": 1,
      "emails": []
    }'
    const res = await fetch('https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/codes', {
      method: 'POST',
      headers: {
        Authorization: `Bearer ${process.env.SHOPFAST_API_KEY}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        "prefix": "",
        "count": 1,
        "length": 8,
        "usesPerCode": 1,
        "emails": []
      }),
    });
    if (!res.ok) throw new Error((await res.json()).detail);
    const data = await res.json();
    import os, requests
    
    res = requests.request(
        "POST",
        "https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/codes",
        headers={"Authorization": f"Bearer {os.environ['SHOPFAST_API_KEY']}"},
        json={
          "prefix": "",
          "count": 1,
          "length": 8,
          "usesPerCode": 1,
          "emails": []
        },
    )
    res.raise_for_status()
    data = res.json()
    req, _ := http.NewRequest("POST", "https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/codes", strings.NewReader(`{
      "prefix": "",
      "count": 1,
      "length": 8,
      "usesPerCode": 1,
      "emails": []
    }`))
    req.Header.Set("Authorization", "Bearer "+os.Getenv("SHOPFAST_API_KEY"))
    req.Header.Set("Content-Type", "application/json")
    res, err := http.DefaultClient.Do(req)
    Try it with your key

    Use a test key on a development store. The key stays in this tab (sessionStorage) and is sent only to the base URL above.

    Turn one generated code off or on

    PATCH/v1/store/discounts/{discountId}/codes/{code}

    Or name the store: PATCH /v1/stores/{storeId}/discounts/{discountId}/codes/{code}

    marketing:writerole: marketing:writeupdateDiscountCode

    Parameters

    • discountIddsc_…pathrequired
    • codestringpathrequired

    Body

    • disabledbooleanrequired

    Response DiscountCodeRow

    • codestringrequired
    • usageLimitintegerrequired
    • timesUsedintegerrequired
    • assignedEmailEmail | nullrequired
    • disabledbooleanrequired
    • batchIdCodeBatchId | nullrequired
    • source"batch" | "popup"required
    • createdAtTimestamprequired
    • lastUsedAtTimestamp | nullrequired

    Example

    curl -X PATCH "https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/codes/string" \
      -H "Authorization: Bearer $SHOPFAST_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
      "disabled": false
    }'
    const res = await fetch('https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/codes/string', {
      method: 'PATCH',
      headers: {
        Authorization: `Bearer ${process.env.SHOPFAST_API_KEY}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        "disabled": false
      }),
    });
    if (!res.ok) throw new Error((await res.json()).detail);
    const data = await res.json();
    import os, requests
    
    res = requests.request(
        "PATCH",
        "https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/codes/string",
        headers={"Authorization": f"Bearer {os.environ['SHOPFAST_API_KEY']}"},
        json={
          "disabled": False
        },
    )
    res.raise_for_status()
    data = res.json()
    req, _ := http.NewRequest("PATCH", "https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/codes/string", strings.NewReader(`{
      "disabled": false
    }`))
    req.Header.Set("Authorization", "Bearer "+os.Getenv("SHOPFAST_API_KEY"))
    req.Header.Set("Content-Type", "application/json")
    res, err := http.DefaultClient.Do(req)
    Try it with your key

    Use a test key on a development store. The key stays in this tab (sessionStorage) and is sent only to the base URL above.

    Every generated code as CSV (code, uses, limit, email, status)

    GET/v1/store/discounts/{discountId}/codes/export

    Or name the store: GET /v1/stores/{storeId}/discounts/{discountId}/codes/export

    marketing:readrole: marketing:readexportDiscountCodes

    Parameters

    • discountIddsc_…pathrequired

    Response FileExport

    • filenamestringrequired
    • contentTypestringrequired
    • bodystringrequired
    • rowsintegerrequired

    Example

    curl "https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/codes/export" \
      -H "Authorization: Bearer $SHOPFAST_API_KEY"
    const res = await fetch('https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/codes/export', {
      method: 'GET',
      headers: {
        Authorization: `Bearer ${process.env.SHOPFAST_API_KEY}`,
      },
    });
    if (!res.ok) throw new Error((await res.json()).detail);
    const data = await res.json();
    import os, requests
    
    res = requests.request(
        "GET",
        "https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/codes/export",
        headers={"Authorization": f"Bearer {os.environ['SHOPFAST_API_KEY']}"},
    )
    res.raise_for_status()
    data = res.json()
    req, _ := http.NewRequest("GET", "https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/codes/export", nil)
    req.Header.Set("Authorization", "Bearer "+os.Getenv("SHOPFAST_API_KEY"))
    res, err := http.DefaultClient.Do(req)
    Try it with your key

    Use a test key on a development store. The key stays in this tab (sessionStorage) and is sent only to the base URL above.

    Orders, revenue, conversion from entered to paid, top products and why codes did not apply

    GET/v1/store/discounts/{discountId}/report

    Or name the store: GET /v1/stores/{storeId}/discounts/{discountId}/report

    marketing:readrole: marketing:readgetCouponReport

    Parameters

    • discountIddsc_…pathrequired
    • daysinteger | stringquery

    Response CouponReport

    • discountobjectrequired
      • idDiscountIdrequired
      • kindDiscountKindrequired
      • codestringrequired
      • titlestringrequired
      • statusDiscountStatusrequired
      • bulkCodesbooleanrequired
    • currencyCurrencyCoderequired
    • daysintegerrequired
    • kpisobjectrequired
      • ordersintegerrequired
      • revenueMinorMinorUnitsrequired
      • discountedMinorMinorUnitsrequired
      • averageOrderMinorMinorUnitsrequired
      • buyersintegerrequired
      • enteredintegerrequired
      • rejectedintegerrequired
      • conversionBpsintegerrequired
      • heldintegerrequired
    • codesobject | nullrequired
    • seriesobject[]required
      • dateIsoDaterequired
      • ordersintegerrequired
      • revenueMinorMinorUnitsrequired
      • discountedMinorMinorUnitsrequired
      • enteredintegerrequired
    • topProductsobject[]required
      • productIdstringrequired
      • namestringrequired
      • unitsintegerrequired
      • revenueMinorMinorUnitsrequired
    • reasonsobject[]required
      • detailstringrequired
      • countintegerrequired

    Example

    curl "https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/report" \
      -H "Authorization: Bearer $SHOPFAST_API_KEY"
    const res = await fetch('https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/report', {
      method: 'GET',
      headers: {
        Authorization: `Bearer ${process.env.SHOPFAST_API_KEY}`,
      },
    });
    if (!res.ok) throw new Error((await res.json()).detail);
    const data = await res.json();
    import os, requests
    
    res = requests.request(
        "GET",
        "https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/report",
        headers={"Authorization": f"Bearer {os.environ['SHOPFAST_API_KEY']}"},
    )
    res.raise_for_status()
    data = res.json()
    req, _ := http.NewRequest("GET", "https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/report", nil)
    req.Header.Set("Authorization", "Bearer "+os.Getenv("SHOPFAST_API_KEY"))
    res, err := http.DefaultClient.Do(req)
    Try it with your key

    Use a test key on a development store. The key stays in this tab (sessionStorage) and is sent only to the base URL above.

    The usage log: every time the code was entered, rejected, redeemed or held, newest first (or by `sort`)

    GET/v1/store/discounts/{discountId}/usage

    Or name the store: GET /v1/stores/{storeId}/discounts/{discountId}/usage

    marketing:readrole: marketing:readlistCouponUsage

    Parameters

    • discountIddsc_…pathrequired
    • cursorinteger | string | nullquery
    • event"entered" | "rejected" | "redeemed" | "held" | nullquery
    • sort"at" | "event" | "code" | "email" | "order" | "amount"query
    • dir"asc" | "desc"query

    Response CouponUsagePage

    • itemsCouponUsageEntry[]required
    • nextCursorinteger | nullrequired

    Example

    curl "https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/usage" \
      -H "Authorization: Bearer $SHOPFAST_API_KEY"
    const res = await fetch('https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/usage', {
      method: 'GET',
      headers: {
        Authorization: `Bearer ${process.env.SHOPFAST_API_KEY}`,
      },
    });
    if (!res.ok) throw new Error((await res.json()).detail);
    const data = await res.json();
    import os, requests
    
    res = requests.request(
        "GET",
        "https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/usage",
        headers={"Authorization": f"Bearer {os.environ['SHOPFAST_API_KEY']}"},
    )
    res.raise_for_status()
    data = res.json()
    req, _ := http.NewRequest("GET", "https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/usage", nil)
    req.Header.Set("Authorization", "Bearer "+os.Getenv("SHOPFAST_API_KEY"))
    res, err := http.DefaultClient.Do(req)
    Try it with your key

    Use a test key on a development store. The key stays in this tab (sessionStorage) and is sent only to the base URL above.

    The usage log as CSV (up to 20,000 rows)

    GET/v1/store/discounts/{discountId}/usage/export

    Or name the store: GET /v1/stores/{storeId}/discounts/{discountId}/usage/export

    marketing:readrole: marketing:readexportCouponUsage

    Parameters

    • discountIddsc_…pathrequired

    Response FileExport

    • filenamestringrequired
    • contentTypestringrequired
    • bodystringrequired
    • rowsintegerrequired

    Example

    curl "https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/usage/export" \
      -H "Authorization: Bearer $SHOPFAST_API_KEY"
    const res = await fetch('https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/usage/export', {
      method: 'GET',
      headers: {
        Authorization: `Bearer ${process.env.SHOPFAST_API_KEY}`,
      },
    });
    if (!res.ok) throw new Error((await res.json()).detail);
    const data = await res.json();
    import os, requests
    
    res = requests.request(
        "GET",
        "https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/usage/export",
        headers={"Authorization": f"Bearer {os.environ['SHOPFAST_API_KEY']}"},
    )
    res.raise_for_status()
    data = res.json()
    req, _ := http.NewRequest("GET", "https://api.shopfa.st/v1/store/discounts/dsc_0123456789abcdefghjk/usage/export", nil)
    req.Header.Set("Authorization", "Bearer "+os.Getenv("SHOPFAST_API_KEY"))
    res, err := http.DefaultClient.Do(req)
    Try it with your key

    Use a test key on a development store. The key stays in this tab (sessionStorage) and is sent only to the base URL above.

    Queue deleting discounts for 10 seconds (undo window), then delete like bulkDeleteDiscounts

    POST/v1/store/discounts/bulk-delete-queue

    Or name the store: POST /v1/stores/{storeId}/discounts/bulk-delete-queue

    marketing:writerole: marketing:writequeueDiscountsDelete

    Body

    • idsdsc_…[]required

    Response PendingAction

    • idPendingActionIdrequired
    • kindPendingActionKindrequired
    • labelstringrequired
    • statePendingActionStaterequired
    • commitAtTimestamprequired
    • createdAtTimestamprequired
    • settledAtTimestamp | nullrequired
    • errorstringrequired
    • targetobjectrequired
      • kind"order" | "campaign" | "product" | "products" | "discounts"required
      • idstringrequired
    • actorNamestringrequired
    • minebooleanrequired

    Example

    curl -X POST "https://api.shopfa.st/v1/store/discounts/bulk-delete-queue" \
      -H "Authorization: Bearer $SHOPFAST_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
      "ids": [
        "dsc_0123456789abcdefghjk"
      ]
    }'
    const res = await fetch('https://api.shopfa.st/v1/store/discounts/bulk-delete-queue', {
      method: 'POST',
      headers: {
        Authorization: `Bearer ${process.env.SHOPFAST_API_KEY}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        "ids": [
          "dsc_0123456789abcdefghjk"
        ]
      }),
    });
    if (!res.ok) throw new Error((await res.json()).detail);
    const data = await res.json();
    import os, requests
    
    res = requests.request(
        "POST",
        "https://api.shopfa.st/v1/store/discounts/bulk-delete-queue",
        headers={"Authorization": f"Bearer {os.environ['SHOPFAST_API_KEY']}"},
        json={
          "ids": [
            "dsc_0123456789abcdefghjk"
          ]
        },
    )
    res.raise_for_status()
    data = res.json()
    req, _ := http.NewRequest("POST", "https://api.shopfa.st/v1/store/discounts/bulk-delete-queue", strings.NewReader(`{
      "ids": [
        "dsc_0123456789abcdefghjk"
      ]
    }`))
    req.Header.Set("Authorization", "Bearer "+os.Getenv("SHOPFAST_API_KEY"))
    req.Header.Set("Content-Type", "application/json")
    res, err := http.DefaultClient.Do(req)
    Try it with your key

    Use a test key on a development store. The key stays in this tab (sessionStorage) and is sent only to the base URL above.

    Was this page helpful?