Loyalty

List loyalty cards

Retrieve a list of all loyalty cards.

GET https://api.coupontools.com/v4/loyalty/loyalty-cards

Authentication:

API Keys

Example

const https = require("https");
const clientId = "XXX"; // Your API client ID (required)
const clientSecret = "YYY"; // Your API client secret (required)
const options = {
	"hostname": "api.coupontools.com",
	"port": 443,
	"path": "/v4/loyalty/loyalty-cards",
	"method": "GET",
	"headers": {
		"x-api-key": clientId,
		"x-api-secret": clientSecret,
		"Content-Type": "application/json"
	}
};
const request = https.request(options, (response) => {
	console.log(`statusCode: ${response.statusCode}`);
	response.on("data", (d) => {
		process.stdout.write(d);
	});
});
request.end();

Response

[
	{
		"id": 123456,
		"code": "ndoh57",
		"name": "My membership card",
		"domain": "loyalty.coupontools.com",
		"type": "membership"
	},
	{
		"id": 234567,
		"code": "sk878e",
		"name": "My stamp card",
		"domain": "save2wallet.link",
		"type": "stamp"
	}
]

Copy loyalty card

Make a copy of a loyalty card.

POST https://api.coupontools.com/v4/loyalty/loyalty-cards/{id}/copy

Authentication:

API Keys

Parameters

Optional name String
New card name. Max. 50 characters

Example

const https = require("https");
const clientId = "XXX"; // Your API client ID (required)
const clientSecret = "YYY"; // Your API client secret (required)
const data = JSON.stringify({
	"name": "New card name"
});
const options = {
	"hostname": "api.coupontools.com",
	"port": 443,
	"path": "/v4/loyalty/loyalty-cards/1/copy",
	"method": "POST",
	"headers": {
		"x-api-key": clientId,
		"x-api-secret": clientSecret,
		"Content-Type": "application/json",
		"Content-Length": data.length
	}
};
const request = https.request(options, (response) => {
	console.log(`statusCode: ${response.statusCode}`);
	response.on("data", (d) => {
		process.stdout.write(d);
	});
});
request.write(data);
request.end();

Response

{
	"id": 123456,
	"code": "ndoh57",
	"name": "New name",
	"domain": "save2wallet.link",
	"type": "membership"
}

Loyalty users

Get user

Retrieve a list of all users connected to a loyalty card.

GET https://api.coupontools.com/v4/loyalty/loyalty-cards/{loyaltyCardId}/stats

Authentication:

API Keys

Parameters

Optional filter Object
Contains settings to filter the users.
Optional pagination Object
Contains settings to paginate the users.
Optional include_voided true | false
Toggle to include voided users

Example

const https = require("https");
const clientId = "XXX"; // Your API client ID (required)
const clientSecret = "YYY"; // Your API client secret (required)
const data = JSON.stringify({
	"filter": {
		"strict": false,
		"keyword": "Doe"
	},
	"include_voided": true
});
const options = {
	"hostname": "api.coupontools.com",
	"port": 443,
	"path": "/v4/loyalty/loyalty-cards/2/stats",
	"method": "GET",
	"headers": {
		"x-api-key": clientId,
		"x-api-secret": clientSecret,
		"Content-Type": "application/json",
		"Content-Length": data.length
	}
};
const request = https.request(options, (response) => {
	console.log(`statusCode: ${response.statusCode}`);
	response.on("data", (d) => {
		process.stdout.write(d);
	});
});
request.write(data);
request.end();

Response

[
	{
		"id": 2,
		"code": "5e8ztlbqexobkoerjpqls",
		"first_name": "John",
		"last_name": "Doe",
		"address": "Amina Course 956",
		"zip": "123456",
		"city": "Central City",
		"phone": "+0123456789",
		"email": "John@Doe.com",
		"download_url": "https://loyalty.coupontools.com/snvczh/5e8ztlbqexobkoerjpqls",
		"created_at": "2023-12-05 14:15:29",
		"voided_at": null
	},
	{
		"id": 3,
		"code": "q3hvk7ppli4b8iq9ryufz",
		"first_name": "Jane",
		"last_name": "Doe",
		"address": "Amina Course 957",
		"zip": "123456",
		"city": "Central City",
		"phone": "+0987654321",
		"email": "Jane@Doe.com",
		"download_url": "https://loyalty.coupontools.com/snvczh/q3hvk7ppli4b8iq9ryufz",
		"created_at": "2023-12-06 09:23:34",
		"voided_at": null,
		"expired_at": "2023-12-12 22:59:59"
	}
]

Get user

Retrieve all data from a single user.

GET https://api.coupontools.com/v4/loyalty/loyalty-cards/{loyaltyCardId}/stats/{userId}

Authentication:

API Keys

Example

const https = require("https");
const clientId = "XXX"; // Your API client ID (required)
const clientSecret = "YYY"; // Your API client secret (required)
const options = {
	"hostname": "api.coupontools.com",
	"port": 443,
	"path": "/v4/loyalty/loyalty-cards/1/stats/2",
	"method": "GET",
	"headers": {
		"x-api-key": clientId,
		"x-api-secret": clientSecret,
		"Content-Type": "application/json"
	}
};
const request = https.request(options, (response) => {
	console.log(`statusCode: ${response.statusCode}`);
	response.on("data", (d) => {
		process.stdout.write(d);
	});
});
request.end();

Response

{
	"id": 2,
	"code": "wvjeykseaswlquco6uta8",
	"first_name": "John",
	"last_name": "Doe",
	"address": "Amina Course 956",
	"zip": "15242",
	"city": "Central City",
	"phone": "+0123456789",
	"email": "John@Doe.com",
	"custom_1": "custom value 1",
	"custom_5": "custom value 5",
	"custom_8": "custom value 8",
	"download_url": "https://loyalty.coupontools.com/6epyy9/wvjeykseaswlquco6uta8",
	"created_at": "2024-02-12 12:31:06",
	"voided_at": null
}

Create user

Create a single user with or without additional user data.

POST https://api.coupontools.com/v4/loyalty/loyalty-cards/{id}/stats

Authentication:

API Keys

Parameters

Optional first_name First name
 
Optional last_name Last name
 
Optional address Address
 
Optional zip Zip
 
Optional city City
 
Optional phone Phone
 
Optional email Email address
 
Optional custom_1 - custom_8 String
Custom value 1 through 8

Example

const https = require("https");
const clientId = "XXX"; // Your API client ID (required)
const clientSecret = "YYY"; // Your API client secret (required)
const data = JSON.stringify({
	"first_name": "John",
	"last_name": "Doe",
	"address": "Amina Course 956",
	"zip": "123456",
	"city": "Central City",
	"phone": "+0123456789",
	"email": "John@Doe.com",
	"custom_1": "custom value 1"
});
const options = {
	"hostname": "api.coupontools.com",
	"port": 443,
	"path": "/v4/loyalty/loyalty-cards/1/stats",
	"method": "POST",
	"headers": {
		"x-api-key": clientId,
		"x-api-secret": clientSecret,
		"Content-Type": "application/json",
		"Content-Length": data.length
	}
};
const request = https.request(options, (response) => {
	console.log(`statusCode: ${response.statusCode}`);
	response.on("data", (d) => {
		process.stdout.write(d);
	});
});
request.write(data);
request.end();

Response

{
	"id": 123456,
	"code": "wvjeykseaswlquco6uta8",
	"first_name": "John",
	"last_name": "Doe",
	"address": "Amina Course 956",
	"zip": "123456",
	"city": "Central City",
	"phone": "+0123456789",
	"email": "John@Doe.com",
	"custom_1": "custom value 1",
	"custom_2": "custom value 2",
	"custom_3": "custom value 3",
	"custom_4": "custom value 4",
	"custom_5": "custom value 5",
	"custom_6": "custom value 6",
	"custom_7": "custom value 7",
	"custom_8": "custom value 8",
	"download_url": "https://loyalty.coupontools.com/6epyy9/wvjeykseaswlquco6uta8"
}

Create users

Create a batch of users. Each user can contain additional user data.

POST https://api.coupontools.com/v4/loyalty/loyalty-cards/{id}/stats/bulk

Authentication:

API Keys

Parameters

Optional first_name First name
 
Optional last_name Last name
 
Optional address Address
 
Optional zip Zip
 
Optional city City
 
Optional phone Phone
 
Optional email Email address
 
Optional custom_1 - custom_8 String
Custom value 1 through 8

Example

const https = require("https");
const clientId = "XXX"; // Your API client ID (required)
const clientSecret = "YYY"; // Your API client secret (required)
const data = JSON.stringify([
	{
		"first_name": "John",
		"last_name": "Doe",
		"address": "Amina Course 956",
		"zip": "123456",
		"city": "Central City",
		"phone": "+0123456789",
		"email": "John@Doe.com",
		"custom_1": "custom value 1"
	},
	{
		"first_name": "Jane",
		"last_name": "Doe",
		"address": "Amina Course 957",
		"zip": "123456",
		"city": "Central City",
		"phone": "+0987654321",
		"email": "Jane@Doe.com"
	}
]);
const options = {
	"hostname": "api.coupontools.com",
	"port": 443,
	"path": "/v4/loyalty/loyalty-cards/1/stats/bulk",
	"method": "POST",
	"headers": {
		"x-api-key": clientId,
		"x-api-secret": clientSecret,
		"Content-Type": "application/json",
		"Content-Length": data.length
	}
};
const request = https.request(options, (response) => {
	console.log(`statusCode: ${response.statusCode}`);
	response.on("data", (d) => {
		process.stdout.write(d);
	});
});
request.write(data);
request.end();

Response

[
	{
		"id": 123,
		"code": "so4tvmli5ihq0ic3dqj2p",
		"first_name": "John",
		"last_name": "Doe",
		"address": "Amina Course 956",
		"zip": "123456",
		"city": "Central City",
		"phone": "+0123456789",
		"email": "John@Doe.com",
		"custom_1": "custom value 1",
		"custom_2": "custom value 2",
		"custom_3": "custom value 3",
		"custom_4": "custom value 4",
		"custom_5": "custom value 5",
		"custom_6": "custom value 6",
		"custom_7": "custom value 7",
		"custom_8": "custom value 8",
		"download_url": "https://loyalty.coupontools.com/rbm9dg/so4tvmli5ihq0ic3dqj2p"
	},
	{
		"id": 124,
		"code": "0jjneqb5f1lijnwhiqrji",
		"first_name": "Jane",
		"last_name": "Doe",
		"address": "Amina Course 957",
		"zip": "123456",
		"city": "Central City",
		"phone": "+0987654321",
		"email": "Jane@Doe.com",
		"download_url": "https://loyalty.coupontools.com/rbm9dg/0jjneqb5f1lijnwhiqrji"
	}
]

Update User

Update the data of a user.

POST https://api.coupontools.com/v4/loyalty/loyalty-cards/{loyaltyCardId}/stats/{userId}

Authentication:

API Keys

Parameters

Optional first_name First name
 
Optional last_name Last name
 
Optional address Address
 
Optional zip Zip
 
Optional city City
 
Optional phone Phone number
 
Optional email Email address
 
Optional custom_1 - custom_8 String
Custom value 1 through 8

Example

const https = require("https");
const clientId = "XXX"; // Your API client ID (required)
const clientSecret = "YYY"; // Your API client secret (required)
const data = JSON.stringify({
	"first_name": "John",
	"last_name": "Doe",
	"address": "Amina Course 956",
	"zip": "123456",
	"city": "Central City",
	"phone": "+0123456789",
	"email": "John@Doe.com",
	"custom_1": "custom value 1"
});
const options = {
	"hostname": "api.coupontools.com",
	"port": 443,
	"path": "/v4/loyalty/loyalty-cards/1/stats/123456",
	"method": "POST",
	"headers": {
		"x-api-key": clientId,
		"x-api-secret": clientSecret,
		"Content-Type": "application/json",
		"Content-Length": data.length
	}
};
const request = https.request(options, (response) => {
	console.log(`statusCode: ${response.statusCode}`);
	response.on("data", (d) => {
		process.stdout.write(d);
	});
});
request.write(data);
request.end();

Response

{
	"id": 123456,
	"code": "wvjeykseaswlquco6uta8",
	"first_name": "John",
	"last_name": "Doe",
	"address": "Amina Course 956",
	"zip": "123456",
	"city": "Central City",
	"phone": "+1234567890",
	"email": "John@Doe.com",
	"custom_1": "custom value 1",
	"custom_2": "custom value 2",
	"custom_3": "custom value 3",
	"custom_4": "custom value 4",
	"custom_5": "custom value 5",
	"custom_6": "custom value 6",
	"custom_7": "custom value 7",
	"custom_8": "custom value 8",
	"download_url": "https://loyalty.coupontools.com/6epyy9/wvjeykseaswlquco6uta8",
	"created_at": "2024-02-12 12:31:06",
	"voided_at": null,
	"expired_at": "2024-02-19 22:59:59"
}

Add stamps

Add stamps to a user's card.

POST https://api.coupontools.com/v4/loyalty/loyalty-cards/{loyaltyCardId}/stats/{userId}/stamps

Authentication:

API Keys

Parameters

Required amount Number
The amount of stamps that gets added to the user's card. Min. 1

Example

const https = require("https");
const clientId = "XXX"; // Your API client ID (required)
const clientSecret = "YYY"; // Your API client secret (required)
const data = JSON.stringify({
	"amount": 1
});
const options = {
	"hostname": "api.coupontools.com",
	"port": 443,
	"path": "/v4/loyalty/loyalty-cards/1/stats/123456",
	"method": "POST",
	"headers": {
		"x-api-key": clientId,
		"x-api-secret": clientSecret,
		"Content-Type": "application/json",
		"Content-Length": data.length
	}
};
const request = https.request(options, (response) => {
	console.log(`statusCode: ${response.statusCode}`);
	response.on("data", (d) => {
		process.stdout.write(d);
	});
});
request.write(data);
request.end();

Response

{
	"id": 123456,
	"code": "wvjeykseaswlquco6uta8",
	"first_name": "John",
	"last_name": "Doe",
	"address": "Amina Course 956",
	"zip": "123456",
	"city": "Central City",
	"phone": "+1234567890",
	"email": "John@Doe.com",
	"custom_1": "custom value 1",
	"custom_2": "custom value 2",
	"custom_3": "custom value 3",
	"stamps": 6,
	"download_url": "https://loyalty.coupontools.com/6epyy9/wvjeykseaswlquco6uta8",
	"created_at": "2024-02-12 12:31:06",
	"voided_at": "2024-03-07 08:41:06",
	"rewards": [
		{
			"id": 7,
			"name": "rewardA",
			"added_at": "2024-02-14 12:20:00",
			"expired_at": "2024-02-21 23:59:59"
		},
		{
			"id": 12,
			"name": "rewardB",
			"added_at": "2024-02-14 12:20:00",
			"used_at": "2024-03-06 14:45:08"
		}
	]
}

Use rewards

Use non-expired rewards of a user.

PUT https://api.coupontools.com/v4/loyalty/loyalty-cards/{loyaltyCardId}/stats/{userId}/rewards

Authentication:

API Keys

Parameters

Required reward_ids List of reward ids
 

Example

const https = require("https");
const clientId = "XXX"; // Your API client ID (required)
const clientSecret = "YYY"; // Your API client secret (required)
const data = JSON.stringify({
	"reward_ids": [
		1,
		2,
		3
	]
});
const options = {
	"hostname": "api.coupontools.com",
	"port": 443,
	"path": "/v4/loyalty/loyalty-cards/1/stats/2/rewards",
	"method": "PUT",
	"headers": {
		"x-api-key": clientId,
		"x-api-secret": clientSecret,
		"Content-Type": "application/json",
		"Content-Length": data.length
	}
};
const request = https.request(options, (response) => {
	console.log(`statusCode: ${response.statusCode}`);
	response.on("data", (d) => {
		process.stdout.write(d);
	});
});
request.write(data);
request.end();

Response

{
	"id": 2,
	"code": "wvjeykseaswlquco6uta8",
	"first_name": "John",
	"last_name": "Doe",
	"address": "Amina Course 956",
	"zip": "123456",
	"city": "Central City",
	"phone": "+0123456789",
	"email": "John@Doe.com",
	"custom_1": "custom value 1",
	"custom_2": "custom value 2",
	"custom_3": "custom value 3",
	"custom_4": "custom value 4",
	"custom_5": "custom value 5",
	"custom_6": "custom value 6",
	"custom_7": "custom value 7",
	"custom_8": "custom value 8",
	"stamps": 4,
	"download_url": "https://loyalty.coupontools.com/6epyy9/wvjeykseaswlquco6uta8",
	"created_at": "2024-02-12 12:31:06",
	"voided_at": null,
	"rewards": [
		{
			"id": 1,
			"name": "rewardA",
			"added_at": "2024-02-14 12:20:00",
			"used_at": "2024-03-06 14:45:08"
		},
		{
			"id": 2,
			"name": "rewardB",
			"added_at": "2024-02-14 12:20:00",
			"expired_at": "2024-02-21 23:59:59"
		},
		{
			"id": 3,
			"name": "rewardA",
			"added_at": "2024-02-14 12:20:00",
			"used_at": "2024-03-07 15:28:18"
		},
		{
			"id": 4,
			"name": "rewardB",
			"added_at": "2024-02-14 12:20:00"
		}
	]
}

Void user

Void a user's card.

PUT https://api.coupontools.com/v4/loyalty/loyalty-cards/{loyaltyCardId}/stats/{userId}/void

Authentication:

API Keys

Example

const https = require("https");
const clientId = "XXX"; // Your API client ID (required)
const clientSecret = "YYY"; // Your API client secret (required)
const options = {
	"hostname": "api.coupontools.com",
	"port": 443,
	"path": "/v4/loyalty/loyalty-cards/1/stats/2/void",
	"method": "PUT",
	"headers": {
		"x-api-key": clientId,
		"x-api-secret": clientSecret,
		"Content-Type": "application/json"
	}
};
const request = https.request(options, (response) => {
	console.log(`statusCode: ${response.statusCode}`);
	response.on("data", (d) => {
		process.stdout.write(d);
	});
});
request.end();

Response

{
	"id": 2,
	"code": "wvjeykseaswlquco6uta8",
	"first_name": "John",
	"last_name": "Doe",
	"address": "Amina Course 956",
	"zip": "15242",
	"city": "Central City",
	"phone": "+0123456789",
	"email": "John@Doe.com",
	"custom_1": "custom value 1",
	"custom_2": "custom value 2",
	"custom_3": "custom value 3",
	"download_url": "https://loyalty.coupontools.com/6epyy9/wvjeykseaswlquco6uta8",
	"created_at": "2024-02-12 12:31:06",
	"voided_at": "2024-03-07 08:41:06"
}

Delete user

Delete a user.

DELETE https://api.coupontools.com/v4/loyalty/loyalty-cards/{loyaltyCardId}/stats/{userId}

Authentication:

API Keys

Example

const https = require("https");
const clientId = "XXX"; // Your API client ID (required)
const clientSecret = "YYY"; // Your API client secret (required)
const options = {
	"hostname": "api.coupontools.com",
	"port": 443,
	"path": "/v4/loyalty/loyalty-cards/1/stats/2",
	"method": "DELETE",
	"headers": {
		"x-api-key": clientId,
		"x-api-secret": clientSecret,
		"Content-Type": "application/json"
	}
};
const request = https.request(options, (response) => {
	console.log(`statusCode: ${response.statusCode}`);
	response.on("data", (d) => {
		process.stdout.write(d);
	});
});
request.end();

Notification

Send push notification

Send push notifications to (select) users.

POST https://api.coupontools.com/v4/loyalty/loyalty-cards/{id}/push-notifications

Authentication:

API Keys

Parameters

Required message String
Push notification message shown to the user.
Optional recipient_stat_ids List of user ids
List of user ids to send the push notification to. If not provided, the message will be send to all users.

Example

const https = require("https");
const clientId = "XXX"; // Your API client ID (required)
const clientSecret = "YYY"; // Your API client secret (required)
const data = JSON.stringify({
	"message": "Target message",
	"recipient_stat_ids": [
		1,
		2,
		3
	]
});
const options = {
	"hostname": "api.coupontools.com",
	"port": 443,
	"path": "/v4/loyalty/loyalty-cards/1/push-notifications",
	"method": "POST",
	"headers": {
		"x-api-key": clientId,
		"x-api-secret": clientSecret,
		"Content-Type": "application/json",
		"Content-Length": data.length
	}
};
const request = https.request(options, (response) => {
	console.log(`statusCode: ${response.statusCode}`);
	response.on("data", (d) => {
		process.stdout.write(d);
	});
});
request.write(data);
request.end();

Response

{
	"message": "Targeted push notification",
	"total_recipients": 1
}