BackEnd

Our BackEnd API is documented using Postman . You will find in the link below the technical details for each endpoints.

But before heading to that documentation, read below a summary of how our API works, and what each endpoint does.

Introduction

There are two sections in this collection:

  • Front-end endpoints (if you want to reproduce the mobile/web SDK's behaviour without going through it)

  • Back-end endpoints (server to server)

Front-end endpoints workflow

Only two endpoints work without a userToken: partner/getprog and user/clientcheckcredentials. In order to call any of the other front-end endpoints, you will need to retrieve the userToken sent in user/clientcheckcredentials (data.user.userToken) which connects the user. See the JWT token section to understand where to place the userToken in your requests.

path

description

partner/getprog

Get all the information about the app's miles program for a non-connected user

partner/initialcheckstore

Same than getprog + information specific to that user

user/clientcheckcredentials

Connects/creates the user (creates them if they don't exist)

user/historyburns

List of all the gifts they bought

user/historyearns

List of all the actions they completed

user/logout

Disconnects the user (on all devices)

user/delete

Deletes the user and all of their history from app's miles' server

generosity/store

Equivalent to the SDK's triggerAction, validates(+stores) an action

gift/list

List of available gifts for the user

gift/checkavailability

Buys a gift if user has enough points

ad/bonus

List of bonus ads

ad/specials

List of special ads

ad/news

List of news ads

Back-end endpoints workflow

You must first get a token via auth/token before calling the other endpoints. See the JWT token section to understand where to place the token in your requests.

path

description

auth/token

Returns the token needed for the other endpoints

buffer/store

Back-end equivalent to generosity/store, validates(+stores) an action

generosity/multistore

Validates(+stores) an action for multiple users

user/incrementalinfos

List of users with their info, completed actions and purchased gifts

user/infos

List of users with their info

user/info

Returns a single user's information

user/ranking

List of n users below and above the given user

user/multidelete

Deletes one or multiple users

Creating a JWT token

https://www.iana.org/assignments/jwt/jwt.xhtml

$timestamp = time();
$partnerID = {{to_fill}};
$partnerSecret = {{to_fill}};
$token = {{to_fill}}; // userToken (frontend) or token (backend), empty for auth/token
$requestHeaders = {{to_fill}};
$requestBody = {{to_fill}};
$header = [
“alg” =>HS256,
“typ” =>JWT
];
$payload = [
“iss” => $partnerID, // The "iss" (issuer) claim identifies the principal that issued the JWT.
“sub” => $token, // The "sub" (subject) claim identifies the principal that is the subject of the JWT
“iat” => $timestamp, // The "iat" (issued at) claim identifies the time at which the JWT was issued. UTC.
“data_header” => json_encode($requestHeaders),
“data_body” => json_encode($requestBody)
];
$signature = HMACSHA256(
base64UrlEncode($header) . "." .
base64UrlEncode($payload),
$partnerSecret
);
$jwtToken = base64UrlEncode($header) . "." . base64UrlEncode($payload) . "." . $signature;