Skip to main content
POST
/
carts
/
{cartId}
/
points
Redeem Reward Points
curl --request POST \
  --url https://api.marzipan.co/v1/carts/{cartId}/points \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "points": 500
}'
import requests

url = "https://api.marzipan.co/v1/carts/{cartId}/points"

payload = { "points": 500 }
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({points: 500})
};

fetch('https://api.marzipan.co/v1/carts/{cartId}/points', 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://api.marzipan.co/v1/carts/{cartId}/points",
  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([
    'points' => 500
  ]),
  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://api.marzipan.co/v1/carts/{cartId}/points"

	payload := strings.NewReader("{\n  \"points\": 500\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://api.marzipan.co/v1/carts/{cartId}/points")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"points\": 500\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.marzipan.co/v1/carts/{cartId}/points")

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  \"points\": 500\n}"

response = http.request(request)
puts response.read_body
{
  "data": {
    "id": "893ff86d-4453-4134-9f62-5c9b7a70d74e",
    "cartCount": 2,
    "customerId": "4b1d2c3a-9f8e-4a7b-8c6d-1e2f3a4b5c6d",
    "email": "customer@example.com",
    "subTotal": 4500,
    "discount": 0,
    "pointsToRedeem": 500,
    "pointsDiscountValue": 500,
    "shipping": 0,
    "tax": 0,
    "grandTotal": 4000,
    "currency": {
      "code": "GBP",
      "symbol": "£"
    }
  },
  "pointsApplied": 500,
  "pointsDiscount": 500
}
{
  "message": "Customer not found."
}
{
  "message": "The points field is required.",
  "errors": {
    "points": [
      "The points field is required."
    ]
  }
}

Authorizations

Authorization
string
header
required

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

Path Parameters

cartId
string<uuid>
required

The unique identifier for the cart

Body

application/json
points
integer
required

The number of reward points to redeem against the cart.

Required range: x >= 1

Response

Points applied. Returns the recalculated cart along with the number of points redeemed and the resulting discount value.

data
object

A storefront shopping cart with its items, totals and applied discounts. Monetary amounts are expressed in the cart currency's minor units (e.g. pence/cents).

pointsApplied
integer

The number of points actually redeemed.

pointsDiscount
number

The monetary discount value granted by the redeemed points.