API Info
Introduction
API for working with core Luna Loyalty Cards objects.
Default API methods address: https://app.lunaloyaltycards.com/api/v1/[method]
Any request can return an error code in the error variable. Common errors for all requests:
1
Invalid token specified
2
Card with the given serial number is not found
3
Card found but not owned by your company
4
Not all required request parameters are filled in
Many queries take or return a card type parameter. List of card types:
0
Cumulative card (stamps)
1
Cashback card
2
Subscription (stamps)
3
Coupon
4
Discount card
5
Certificate
6
Membership card
Reference
List of card templates for your company
The request has no formal input Return values for each pattern:
id
Template ID
name
Name
type
Card type
POST: https://app.lunaloyaltycards.com/api/v1/getTemplates
Headers
Content-Type:application/json
x-access-token:ghgghhhyee358fjhdhd0
Body
Response
200
Headers
Content-Type:application/json
Body
Client creation
Creates a client for a card type. The request takes the following parameters:
sName
string, required
surname
fName
string, required
name
phone
integer
phone number. Required if no email
string, required
client email. Mandatory if not phone
idTemplate
integer, required
card template ID
Possible errors typical for the request
5
A user with this phone number or email is already created for this card type. If this error is present, the request also returns the user ID.
Request to create a client: POST: https://app.lunaloyaltycards.com/api/v1/createClient
Headers
Content-Type:application/json
x-access-token:ghgghhhyee358fjhdhd0
Body
Response
200
Headers
Content-Type:application/json
Body
Search for the client in the card template
Search for a client by phone or email in a given card template
| Parameter | Type | Description | | phone | integer | phone number. Obligatory if no email is specified | | E-mail | string | Client's Email. Mandatory if not phone | | idTemplate | integer, required | card template ID
POST: https://app.lunaloyaltycards.com/api/v1/searchClient
Headers
Content-Type:application/json
x-access-token:ghgghhhyee358fjhdhd0
Body
Response
200
Headers
Content-Type:application/json
Body
Change the client
Changes the client parameters for the card type. The request takes the following parameters as a parameter:
userID
integer, required
customer ID
sName
string, required
surname
fName
string, required
name
phone
integer
phone number. Required if no email
string, required
client email. Mandatory if not phone
idTemplate
integer, required
card template ID
Possible errors typical for the request
5
A user with this phone number or email is already created for this card type. If this error is present, the request also returns the user ID.
POST: https://app.lunaloyaltycards.com/api/v1/updateClient
Headers
Content-Type:application/json
x-access-token:ghgghhhyee358fjhdhd0
Body
Response
200
Headers
Content-Type:application/json
Body
Creating a card
Creates a card of a given template for a specific client. The request takes the following parameters:
idTemplate
integer, required
card template ID
userID
integer, required
customer ID
The client ID can be obtained by creating the client in the createClient method
POST: https://app.lunaloyaltycards.com/api/v1/createPass
Headers
Content-Type:application/json
x-access-token:ghgghhhyee358fjhdhd0
Body
Response
200
Headers
Content-Type:application/json
Body
Card information
The request takes the passSerialNumber parameter and returns card details.
passSerialNumber
string, required
Serial number of the card
The returned values depend on the type of card. The card type is returned in the type attribute
Depending on the type of card, the structure and values of returned data differ.
status
installed, deleted, not installed
Card status
serialNumber
123-4445-223444
Serial number of the card
Card type 0.
maxStamps
10
The maximum number of stamps on stamps image
activeStamps
3
Current number of stamps
totalStamps
13
The total number of stamps accrued for the entire duration of the card
unusedRewards
1
Number of unused awards
image
URL
Path to the image with stamps reflecting the current number of stamps
rewards
Data array
An array of data with the attributes name, stamps, autoUse. name - the name of the award, stamps - the number of stamps, separated by commas, upon completion of which the award will be credited, autoUse - the automatic writing off of the award at the next visit
Card type 1.
amountMoneySpentTotal
10000
The total amount of funds recorded on the card
currentPersentBonus
4
Current cashback percentage, according to which points are awarded
amountMoneyBonus
400
Current number of points
Card type 2.
maxStamps
10
The maximum number of stamps on stamps image
activeStamps
3
Current number of stamps
numberScores
9
The client can receive a certain number of bonus points for each visit, this field shows the current number of points
image
URL
Path to the stamps image reflecting current number of stamps
Card type 4.
amountMoneySpentTotal
10000
The total amount of funds recorded on the card
currentPersentBonus
4
Current discount percentage
POST: https://app.lunaloyaltycards.com/api/v1/getPassInfo
Headers
Content-Type:application/json
x-access-token:ghgghhhyee358fjhdhd0
Body
Response
200
Headers
Content-Type:application/json
Body
Check the existence of the card using the phone number
The query takes the parameters phone and idTemplate and returns 0 (does not exist) or 1 (exists) in the result parameter
idTemplate
integer, required
ID of the card template
phone
integer, required
phone number
POST: https://app.lunaloyaltycards.com/api/v1/checkPassExistsByPhone
Headers
Content-Type:application/json
x-access-token:ghgghhhyee358fjhdhd0
Body
Response
200
Headers
Content-Type:application/json
Body
Card information using the cardholder's phone number
The query takes parameters phone and idTemplate and returns card data in the same format as the getPassInfo method
idTemplate
integer, required
card template ID
phone
integer, required
phone number
POST: https://app.lunaloyaltycards.com/api/v1/getPassInfoByPhone
Headers
Content-Type:application/json
x-access-token:ghgghhhyee358fjhdhd0
Body
Response
200
Headers
Content-Type:application/json
Body
Customer card information using phone number
Retrieves all cards within all templates available to your company by phone number and returns information on them.
phone
integer, required
phone number
POST: https://app.lunaloyaltycards.com/api/v1/getClientPassesByPhone
Headers
Content-Type:application/json
x-access-token:ghgghhhyee358fjhdhd0
Body
Response
200
Headers
Content-Type:application/json
Body
Customer card information via email
The email retrieves all cards within all templates available to your company and returns information on them.
string, required
customer email
POST: https://app.lunaloyaltycards.com/api/v1/getClientPassesByEmail
Headers
Content-Type:application/json
x-access-token:ghgghhhyee358fjhdhd0
Body
Response
200
Headers
Content-Type:application/json
Body
Sending informational push notifications to clients who installed the cards
Sending a push notification to one client
pushSegment
string, required
the value of this parameter must be oneClient
passSerialNumber
string, required
serial number of the client card
messageText
string, required
push notification text
Sending push notifications to all clients who installed cards of a certain template
pushSegment
string, required
the value of this parameter must be allClients
idTemplate
string, required
ID of the template of the card
messageText
string, required
push notification text
page
page
integer, required
When sending push notifications to all clients it is necessary to use the page attribute, because sending takes some time and has to be done in parts. Up to 10 messages are sent with each call. After successful sending, the method returns the numberOfRowsSelected parameter. If it is 10, you must increase page by 1 and call the method again until the value of the numberOfRowsSelected parameter is less than 10.
The messageText attribute may contain variables that will be replaced by corresponding values. All variables in the message text are distinguished by special characters in double curly braces {{variable name}}. For example {{clientFName}}
A list of supported variables:
clientFName
clientName
clientSName
clientSurname
clientDateOfBirth
date of birth
clientPhone
clientPhone
clientEmail
clientEmail
passCurrentStamps
current number of stamps on the client card (card type 0 and 2)
passTotalStamps
total number of stamps accumulated over time (card type 0)
passUnusedRewards
current number of unused rewards (card type 0)
passPoints
current bonus points (card type 1)
passPersent
current cashback percentage or current discount percentage (card type 1 and 4)
Request to send a push notification to one client POST: https://app.lunaloyaltycards.com/api/v1/sendInfoPush
Body
Headers
Content-Type:application/json
200
Response
Body
Headers
Content-Type:application/json
x-access-token:ghgghhhyee358fjhdhd0
Request to send push notifications to all clients POST: https://app.lunaloyaltycards.com/api/v1/sendInfoPush
Headers
Content-Type:application/json
x-access-token:ghgghhhyee358fjhdhd0
Body
Response
200
Headers
Content-Type:application/json
Body
Get the history of information push notifications by card
passSerialNumber
string, required
customer card serial number
page
number
page number. Since the query returns no more than 10 messages, it is used to select the following ones.
Request for history of informational push notifications POST: https://app.lunaloyaltycards.com/api/v1/getInfoPushList
Headers
Content-Type:application/json
x-access-token:ghgghhhyee358fjhdhd0
Body
Response
200
Headers
Content-Type:application/json
Body
Template card status information
By template ID and retrieves information about the clients and their card statuses according to the type of selection.
idTemplate
integer, required
template ID
selectionMode
string, required
Selection type. PassNotCreated - returns all clients with unissued cards. PassInstalled - all clients with cards installed and currently valid. passNotInstalled - all clients with issued, but not installed cards. passDeleted - all clients with issued but deleted cards.
page
number
page number. Since the query returns no more than 100 clients, it serves to select the following ones.
POST: https://app.lunaloyaltycards.com/api/v1/getTemplateClientPasses Headers
Content-Type:application/json
x-access-token:ghgghhhyee358fjhdhd0
Body
Response
200
Headers
Content-Type:application/json
Body
Information on card operations
The request takes the following parameters: passSerialNumber and page (optional). Returns the last 50 card transactions.
passSerialNumber
string, required
Serial number of the card
page
number
Page number. Because the request returns no more than 50 last operations, it serves to select the next page.
Request to receive data
POST: https://app.lunaloyaltycards.com/api/v1/getPassOperations
Headers
Content-Type:application/json
x-access-token:ghgghhhyee358fjhdhd0
Body
Response
200
Headers
Content-Type:application/json
Body
Information about the client who installed the card
The request takes the passSerialNumber parameter.
passSerialNumber
string, required
Serial number of the card
Returned parameters
sName
Client surname
fName
Client name
dateOfBirth
Date of birth
phone
Phone number
Field0-5
Values of additional fields, if they were in the card issue form and the client filled them in
Request to receive data POST: https://app.lunaloyaltycards.com/api/v1/getClientInfo
Headers
Content-Type:application/json
x-access-token:ghgghhhyee358fjhdhd0
Body
Response
200
Headers
Content-Type:application/json
Body
Get client list by card template
The query takes idTemplate and page (optional) parameters. It returns 10 clients registered in the given card template.
idTemplate
integer, required
card template ID
page
number
page number. Since the query returns no more than 10 clients, it is used to select the following ones.
Returned parameters
id
customer ID
sName
client's last name
fName
customer name
dateOfBirth
date of birth
phone
phone number
Field0-5
values of additional fields, if they were in the card release form and the client filled them in
Request to get data POST: https://app.lunaloyaltycards.com/api/v1/getClientsList
Headers
Content-Type:application/json
x-access-token:ghgghhhyee358fjhdhd0
Body
Response
200
Headers
Content-Type:application/json
Body
Card information update
This request depends on the type of card and includes general and special parameters. The request always takes the passSerialNumber parameter.
passSerialNumber
string, required
Serial number of the card
Parameters for card type 0.
numberStumps
integer, required
Number of credited stamps
Parameters for card type 1.
action
string, required
Action type
sum
integer, required
Scope of action
Possible values of action
spendPoints
Writing off points
accruePoints
Earning points
increaseTotalSpentSum
Increase in the total amount of funds spent
reduceTotalSpentSum
Reducing the total amount of funds spent
Parameters for card type 2.
When writing off points:
action
string, required
spendPoints
Action type: writing off points
sum
integer, required
For example: 12
The amount of points written off
When writing off visits:
action
string, required
takeStamps
Action type: write off visits
numberStumps
integer, required
For example: 1
The amount of visits written off
When calculating visits:
action
string, required
addStamps
Action type: accrual of visits
numberStumps
integer, required
For example: 1
Accrual of visits
Parameters for card type 4.
action
string, required
Action type
sum
integer, required
Scope of action
Possible values for action
increaseTotalSpentSum
Increase in the total amount of funds spent
reduceTotalSpentSum
Reducing the total amount of funds spent
Parameters for card type 5.
action
string, required
action type
sum
integer, required
action type
Possible values of action
spendPoints
decrease balance
accruePoints
increase balance
For all types of cards with an active card expiration date setting in the template.
action
string, required
action type
expiryDate
integer, required
expiration date of the card (UNIX timestamp)
Possible values of action
setExpirationDate
set card expiration date
Request to update the card POST: https://app.lunaloyaltycards.com/api/v1/usePass
Headers
Content-Type:application/json
Body
Response
200
Headers
Content-Type:application/json
Body
Write off rewards on type 0 cards
With the card serial number it writes off all available rewards.
passSerialNumber
string, required
card serial number
numberRewards
integer, required
number of rewards to write off
Card update request POST: https://app.lunaloyaltycards.com/api/v1/useReward
Headers
Content-Type:application/json
Body
Response
200
Headers
Content-Type:application/json
Body
Last updated