Apply coupon - Fabric

Documentation Index

Fetch the complete documentation index at: /llms.txt

Use this file to discover all available pages before exploring further.

Apply coupon

cURL

curl --request POST \
  --url https://api.fabric.inc/v3/orchestrator/carts/{cartId}/coupons/{couponCode} \
  --header 'Authorization: Bearer <token>' \
  --header 'x-fabric-channel-id: <x-fabric-channel-id>' \
  --header 'x-fabric-tenant-id: <x-fabric-tenant-id>'
import requests

url = "https://api.fabric.inc/v3/orchestrator/carts/{cartId}/coupons/{couponCode}"

headers = {
    "x-fabric-tenant-id": "<x-fabric-tenant-id>",
    "x-fabric-channel-id": "<x-fabric-channel-id>",
    "Authorization": "Bearer <token>"
}

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

print(response.text)
const options = {
  method: 'POST',
  headers: {
    'x-fabric-tenant-id': '<x-fabric-tenant-id>',
    'x-fabric-channel-id': '<x-fabric-channel-id>',
    Authorization: 'Bearer <token>'
  }
};

fetch('https://api.fabric.inc/v3/orchestrator/carts/{cartId}/coupons/{couponCode}', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.fabric.inc/v3/orchestrator/carts/{cartId}/coupons/{couponCode}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "x-fabric-channel-id: <x-fabric-channel-id>",
    "x-fabric-tenant-id: <x-fabric-tenant-id>"
  ],
]);

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

curl_close($curl);

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

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

func main() {

url := "https://api.fabric.inc/v3/orchestrator/carts/{cartId}/coupons/{couponCode}"

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

req.Header.Add("x-fabric-tenant-id", "<x-fabric-tenant-id>")
    req.Header.Add("x-fabric-channel-id", "<x-fabric-channel-id>")
    req.Header.Add("Authorization", "Bearer <token>")

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.fabric.inc/v3/orchestrator/carts/{cartId}/coupons/{couponCode}")
  .header("x-fabric-tenant-id", "<x-fabric-tenant-id>")
  .header("x-fabric-channel-id", "<x-fabric-channel-id>")
  .header("Authorization", "Bearer <token>")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.fabric.inc/v3/orchestrator/carts/{cartId}/coupons/{couponCode}")

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

request = Net::HTTP::Post.new(url)
request["x-fabric-tenant-id"] = '<x-fabric-tenant-id>'
request["x-fabric-channel-id"] = '<x-fabric-channel-id>'
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body

Response Codes

Response Structure

{
  "id": "0e49199c-5849-4211-abe6-a97a3c4dcc56",
  "attributes": {},
  "configuration": {
    "order": {
      "validate": {}
    },
    "product": {
      "cacheExpiry": 7776000,
      "behaviors": {
        "add": "REJECT",
        "update": "WARN",
        "get": "WARN",
        "cacheExpiry": "WARN"
      },
      "maxQuantity": {
        "limit": 100,
        "behaviors": {
          "add": "REJECT",
          "update": "WARN",
          "get": "WARN"
        }
      }
    },
    "inventory": {
      "cacheExpiry": 7776000,
      "behaviors": {
        "add": "REJECT",
        "update": "WARN",
        "get": "WARN",
        "cacheExpiry": "WARN"
      },
      "check": "SKU"
    },
    "tax": {
      "cacheExpiry": 7776000,
      "behaviors": {
        "cacheExpiry": "WARN"
      }
    },
    "promotions": {
      "cacheExpiry": 86400,
      "behaviors": {}
    }
  },
  "customerContext": {
    "id": "109840938",
    "segments": [{
      "name": "membership",
      "value": ["gold", "silver"]
    }],
    "attributes": {
      "email": "test@gmail.com"
    },
    "sessionId": "3a5fd2d3-5c96-4e57-b069-7ff2a88c1119"
  },
  "status": "ACTIVE",
  "state": [{
    "resource": "CART",
    "resourceId": "c86f777b-1885-4ddf-961d-542ba80a69b8",
    "key": "MISSING_PAYMENT_DETAILS",
    "description": "No payment details have been added to this Cart"
  }],
  "price": {
    "total": 1570,
    "subtotal": 1530,
    "tax": 0,
    "fulfillments": 40,
    "discounts": 0,
    "fees": 0,
    "adjustments": 0
  },
  "promotions": {
    "total": 0,
    "collection": [{
      "id": "6626c179627d450008a5b202",
      "title": "Cart Promotion Fixed Price",
      "type": "QUANTITY",
      "value": 10,
      "attributes": {
        "promotionStack": "HIGHEST"
      }
    }]
  },
  "fees": {
    "id": "a8577d7f-0d4d-4b22-8e85-7b4a2e90dc93",
    "name": "Eco Fee",
    "price": {
      "amount": 12.99
    },
    "taxable": true,
    "attributes": {
      "source": "eco"
    },
    "tax": {
      "total": 3,
      "collection": [{
        "amount": 3,
        "attributes": {
          "rate": "5.0",
          "type": "COUNTY"
        }
      }]
    },
    "updatedAt": "2024-06-13T16:50:00.682Z",
    "createdAt": "2024-06-13T16:50:00.682Z",
    "taxDetails": {
      "destinationAddress": "c86f777b-1885-4ddf-961d-542ba80a69b8",
      "originAddress": "c86f777b-1885-4ddf-961d-542ba80a69b8"
    }
  },
  "adjustments": {
    "total": 2,
    "collection": [{
      "id": "a8577d7f-0d4d-4b22-8e85-7b4a2e90dc93",
      "price": {
        "amount": 12.99
      },
      "reason": "Price adjustment from customer representative.",
      "attributes": {
        "source": "CSR"
      },
      "updatedAt": "2024-06-13T16:50:00.682Z",
      "createdAt": "2024-06-13T16:50:00.682Z"
    }]
  }
  // Additional properties can be added as necessary
}