curl --request POST \
--url https://api.fabric.inc/v3/coupons/{couponId}/redemptions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-fabric-tenant-id: <x-fabric-tenant-id>' \
--data '
{
"couponCode": "BESTSUMMER",
"orderId": "1590-2016-12345-7897",
"userId": "614b58924e92f61234567890",
"email": "guest@example.com"
}
'import requests
url = "https://api.fabric.inc/v3/coupons/{couponId}/redemptions"
payload = {
"couponCode": "BESTSUMMER",
"orderId": "1590-2016-12345-7897",
"userId": "614b58924e92f61234567890",
"email": "guest@example.com"
}
headers = {
"x-fabric-tenant-id": "<x-fabric-tenant-id>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-fabric-tenant-id': '<x-fabric-tenant-id>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
couponCode: 'BESTSUMMER',
orderId: '1590-2016-12345-7897',
userId: '614b58924e92f61234567890',
email: 'guest@example.com'
})
};
fetch('https://api.fabric.inc/v3/coupons/{couponId}/redemptions', 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.fabric.inc/v3/coupons/{couponId}/redemptions",
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([
'couponCode' => 'BESTSUMMER',
'orderId' => '1590-2016-12345-7897',
'userId' => '614b58924e92f61234567890',
'email' => 'guest@example.com'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"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"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.fabric.inc/v3/coupons/{couponId}/redemptions"
payload := strings.NewReader("{\n \"couponCode\": \"BESTSUMMER\",\n \"orderId\": \"1590-2016-12345-7897\",\n \"userId\": \"614b58924e92f61234567890\",\n \"email\": \"guest@example.com\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-fabric-tenant-id", "<x-fabric-tenant-id>")
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.fabric.inc/v3/coupons/{couponId}/redemptions")
.header("x-fabric-tenant-id", "<x-fabric-tenant-id>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"couponCode\": \"BESTSUMMER\",\n \"orderId\": \"1590-2016-12345-7897\",\n \"userId\": \"614b58924e92f61234567890\",\n \"email\": \"guest@example.com\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fabric.inc/v3/coupons/{couponId}/redemptions")
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["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"couponCode\": \"BESTSUMMER\",\n \"orderId\": \"1590-2016-12345-7897\",\n \"userId\": \"614b58924e92f61234567890\",\n \"email\": \"guest@example.com\"\n}"
response = http.request(request)
puts response.read_body{
"id": "614b58924e92f6861ac9d43b",
"couponId": "614b58924e92f6861ac91234",
"couponCode": "BESTSUMMER",
"orderId": "1590-2016-12345",
"userId": "614b58924e92f61234567890",
"email": "guest@example.com",
"createdAt": "2020-12-14T12:15:43.646Z",
"updatedAt": "2021-12-14T12:15:43.646Z"
}{
"type": "COUPON_ID_NOT_VALID",
"message": "Coupon ID isn't valid, it must be a valid Object ID"
}{
"type": "UNAUTHORIZED",
"message": "Invalid credentials"
}{
"type": "INTERNAL_SERVER_ERROR",
"message": "Internal server error"
}Create redemption
Creates a redemption for a specific coupon using the corresponding couponId value.
curl --request POST \
--url https://api.fabric.inc/v3/coupons/{couponId}/redemptions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-fabric-tenant-id: <x-fabric-tenant-id>' \
--data '
{
"couponCode": "BESTSUMMER",
"orderId": "1590-2016-12345-7897",
"userId": "614b58924e92f61234567890",
"email": "guest@example.com"
}
'import requests
url = "https://api.fabric.inc/v3/coupons/{couponId}/redemptions"
payload = {
"couponCode": "BESTSUMMER",
"orderId": "1590-2016-12345-7897",
"userId": "614b58924e92f61234567890",
"email": "guest@example.com"
}
headers = {
"x-fabric-tenant-id": "<x-fabric-tenant-id>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-fabric-tenant-id': '<x-fabric-tenant-id>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
couponCode: 'BESTSUMMER',
orderId: '1590-2016-12345-7897',
userId: '614b58924e92f61234567890',
email: 'guest@example.com'
})
};
fetch('https://api.fabric.inc/v3/coupons/{couponId}/redemptions', 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.fabric.inc/v3/coupons/{couponId}/redemptions",
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([
'couponCode' => 'BESTSUMMER',
'orderId' => '1590-2016-12345-7897',
'userId' => '614b58924e92f61234567890',
'email' => 'guest@example.com'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"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"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.fabric.inc/v3/coupons/{couponId}/redemptions"
payload := strings.NewReader("{\n \"couponCode\": \"BESTSUMMER\",\n \"orderId\": \"1590-2016-12345-7897\",\n \"userId\": \"614b58924e92f61234567890\",\n \"email\": \"guest@example.com\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-fabric-tenant-id", "<x-fabric-tenant-id>")
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.fabric.inc/v3/coupons/{couponId}/redemptions")
.header("x-fabric-tenant-id", "<x-fabric-tenant-id>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"couponCode\": \"BESTSUMMER\",\n \"orderId\": \"1590-2016-12345-7897\",\n \"userId\": \"614b58924e92f61234567890\",\n \"email\": \"guest@example.com\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fabric.inc/v3/coupons/{couponId}/redemptions")
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["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"couponCode\": \"BESTSUMMER\",\n \"orderId\": \"1590-2016-12345-7897\",\n \"userId\": \"614b58924e92f61234567890\",\n \"email\": \"guest@example.com\"\n}"
response = http.request(request)
puts response.read_body{
"id": "614b58924e92f6861ac9d43b",
"couponId": "614b58924e92f6861ac91234",
"couponCode": "BESTSUMMER",
"orderId": "1590-2016-12345",
"userId": "614b58924e92f61234567890",
"email": "guest@example.com",
"createdAt": "2020-12-14T12:15:43.646Z",
"updatedAt": "2021-12-14T12:15:43.646Z"
}{
"type": "COUPON_ID_NOT_VALID",
"message": "Coupon ID isn't valid, it must be a valid Object ID"
}{
"type": "UNAUTHORIZED",
"message": "Invalid credentials"
}{
"type": "INTERNAL_SERVER_ERROR",
"message": "Internal server error"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Headers
A header used by fabric to identify the tenant making the request. You must include tenant id in the authentication header for an API request to access any of fabric’s endpoints. You can retrieve the tenant id , which is also called account id, from Copilot. This header is required.
24x-fabric-channel-id identifies the sales channel where the API request is being made; primarily for multichannel use cases. The channel ids are 12 corresponding to US and 13 corresponding to Canada. The default channel id is 12. This field is required.
"12"
A unique request ID.
"263e731c-45c8-11ed-b878-0242ac120002"
Path Parameters
A 24-character system-generated coupon ID generated using the create coupon endpoint.
"614b58924e92f6861ac9d43b"
Body
Coupon redemption details
Coupon code to be redeemed
"BESTSUMMER"
Purchase order ID associated with the coupon redemption
"1590-2016-12345-7897"
ID of the user who redeems the coupon
"614b58924e92f61234567890"
Email address of the user who redeems the coupon
"guest@example.com"
Response
Created
Coupon's redemption details
A 24-character system-generated redemption ID.
"614b58924e92f6861ac9d43b"
A 24-character system-generated coupon ID generated using the create coupon endpoint.
"614b58924e92f6861ac91234"
Coupon code to redeem
"BESTSUMMER"
Purchase order ID associated with the coupon redemption
"1590-2016-12345"
ID of the user who redeems the coupon
"614b58924e92f61234567890"
Email address of the user who redeems the coupon
"guest@example.com"
The timestamp in UTC format of when the coupon redemption was created.
"2020-12-14T12:15:43.646Z"
The timestamp in UTC format of when the coupon redemption was last updated.
"2021-12-14T12:15:43.646Z"
Was this page helpful?
