Skip to main content
POST
/
v1
/
discounts
Get Discounts
curl --request POST \
  --url https://vanilla-dev02-loyalty.fabric.zone/api/v1/discounts \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "profileId": "67460e74-02e3-11e8-b443-00163e990bdb",
  "entityReference": "Company_Club",
  "transactionTimestamp": "2020-02-08 09:30:26",
  "taxAmount": 1,
  "grossAmount": 6,
  "netAmount": 5,
  "transactionItems": [
    {
      "grossAmount": 6,
      "netAmount": 5,
      "categories": [
        "Proteins",
        "Adults"
      ],
      "itemPrice": 5,
      "itemQuantity": 1,
      "SKU": "123456",
      "taxAmount": 1,
      "itemName": "Whey"
    }
  ]
}
'
import requests

url = "https://vanilla-dev02-loyalty.fabric.zone/api/v1/discounts"

payload = {
"profileId": "67460e74-02e3-11e8-b443-00163e990bdb",
"entityReference": "Company_Club",
"transactionTimestamp": "2020-02-08 09:30:26",
"taxAmount": 1,
"grossAmount": 6,
"netAmount": 5,
"transactionItems": [
{
"grossAmount": 6,
"netAmount": 5,
"categories": ["Proteins", "Adults"],
"itemPrice": 5,
"itemQuantity": 1,
"SKU": "123456",
"taxAmount": 1,
"itemName": "Whey"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
profileId: '67460e74-02e3-11e8-b443-00163e990bdb',
entityReference: 'Company_Club',
transactionTimestamp: '2020-02-08 09:30:26',
taxAmount: 1,
grossAmount: 6,
netAmount: 5,
transactionItems: [
{
grossAmount: 6,
netAmount: 5,
categories: ['Proteins', 'Adults'],
itemPrice: 5,
itemQuantity: 1,
SKU: '123456',
taxAmount: 1,
itemName: 'Whey'
}
]
})
};

fetch('https://vanilla-dev02-loyalty.fabric.zone/api/v1/discounts', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://vanilla-dev02-loyalty.fabric.zone/api/v1/discounts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'profileId' => '67460e74-02e3-11e8-b443-00163e990bdb',
'entityReference' => 'Company_Club',
'transactionTimestamp' => '2020-02-08 09:30:26',
'taxAmount' => 1,
'grossAmount' => 6,
'netAmount' => 5,
'transactionItems' => [
[
'grossAmount' => 6,
'netAmount' => 5,
'categories' => [
'Proteins',
'Adults'
],
'itemPrice' => 5,
'itemQuantity' => 1,
'SKU' => '123456',
'taxAmount' => 1,
'itemName' => 'Whey'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://vanilla-dev02-loyalty.fabric.zone/api/v1/discounts"

payload := strings.NewReader("{\n \"profileId\": \"67460e74-02e3-11e8-b443-00163e990bdb\",\n \"entityReference\": \"Company_Club\",\n \"transactionTimestamp\": \"2020-02-08 09:30:26\",\n \"taxAmount\": 1,\n \"grossAmount\": 6,\n \"netAmount\": 5,\n \"transactionItems\": [\n {\n \"grossAmount\": 6,\n \"netAmount\": 5,\n \"categories\": [\n \"Proteins\",\n \"Adults\"\n ],\n \"itemPrice\": 5,\n \"itemQuantity\": 1,\n \"SKU\": \"123456\",\n \"taxAmount\": 1,\n \"itemName\": \"Whey\"\n }\n ]\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://vanilla-dev02-loyalty.fabric.zone/api/v1/discounts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"profileId\": \"67460e74-02e3-11e8-b443-00163e990bdb\",\n \"entityReference\": \"Company_Club\",\n \"transactionTimestamp\": \"2020-02-08 09:30:26\",\n \"taxAmount\": 1,\n \"grossAmount\": 6,\n \"netAmount\": 5,\n \"transactionItems\": [\n {\n \"grossAmount\": 6,\n \"netAmount\": 5,\n \"categories\": [\n \"Proteins\",\n \"Adults\"\n ],\n \"itemPrice\": 5,\n \"itemQuantity\": 1,\n \"SKU\": \"123456\",\n \"taxAmount\": 1,\n \"itemName\": \"Whey\"\n }\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://vanilla-dev02-loyalty.fabric.zone/api/v1/discounts")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"profileId\": \"67460e74-02e3-11e8-b443-00163e990bdb\",\n \"entityReference\": \"Company_Club\",\n \"transactionTimestamp\": \"2020-02-08 09:30:26\",\n \"taxAmount\": 1,\n \"grossAmount\": 6,\n \"netAmount\": 5,\n \"transactionItems\": [\n {\n \"grossAmount\": 6,\n \"netAmount\": 5,\n \"categories\": [\n \"Proteins\",\n \"Adults\"\n ],\n \"itemPrice\": 5,\n \"itemQuantity\": 1,\n \"SKU\": \"123456\",\n \"taxAmount\": 1,\n \"itemName\": \"Whey\"\n }\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "status": 200,
  "message": "Created",
  "errors": {},
  "data": [
    {
      "grossAmount": 6,
      "taxAmount": 1,
      "netAmount": 4,
      "discounts": [
        {
          "value": 1,
          "type": "tier",
          "description": "20.0% discount from tier rule.",
          "id": 23,
          "ruleName": "tier-discount-rule",
          "discountPercentage": 20,
          "discountAmount": 1
        }
      ],
      "transactionItems": [
        {
          "SKU": "123456",
          "discounts": []
        }
      ],
      "miscellaneous": []
    }
  ]
}
{
"message": "Error message string",
"errors": {
"ExceptionString": [
"Invalid Field"
]
},
"data": null,
"status": 400
}
{
"detail": "Authentication Failed"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
profileId
string<uuid>
required

Profile ID of member

Example:

"67460e74-02e3-11e8-b443-00163e990bdb"

entityReference
string
required

External reference of the store where the transaction occurred

Minimum string length: 1
Example:

"Company_Club"

transactionTimestamp
string<date-time>
required

Transaction timestamp (UTC format)

Example:

"2020-02-08 09:30:26"

taxAmount
number<float>
required

Tax amount

Example:

1

grossAmount
number<float>
required

Gross amount of the transaction (before discount)

Example:

6

netAmount
number<float>
required

Net amount of the transaction (after discount).

Example:

5

transactionItems
object[]

Response

Ok

Response of the Discounts API

status
integer<int32>

Status of the call

Example:

200

message
string
default:Exception message

Message corresponding to the call

Example:

"Created"

errors
Errors · object

Error details, if applicable

Example:
{}
data
Data · object[]