Add
Create or schedule an invitation.
POST /1.0/invitations.json
Query parameters
They should be passed as query parameters to the URL. (ex.: ?id=1&code=abc
)
id
int (required)
The unique webshop ID.
code
string (required)
Your personal API code.
Body parameters
email
string (required)
The full e-mail address of the customer to send the invitation to.
order
string
Order number.
language
string
Language in ISO-639-1 format.
delay
int
The delay in days (use 0 to send the invitation ASAP).
customer_name
string
The customer's name.
phone_numbers
array
Array of customers phone numbers.
order_total
decimal
Total order amount as a decimal number, formatted with a dot.
order_data
JSON
Additional data about the order, such as Product data - Product data requires at least id
, name
and url
.
client
string
The name of the software/system the request is originating from.
platform_version
string
The version of the software/system the request is originating from.
plugin_version
string
The version of the code/plugin the request is originating from.
Example response
Response statuses
status | message | Explanation |
---|---|---|
success | Invitation successfully added to queue! | The invitation has successfully been added to the queue. |
success | Invitation already sent for this order. | The combination email and order has already been used for a previous invitation. |
error | Not all obligated variables are set. | One or more of the required variables (id , code and/or email ) has/have not been set. |
error | Incorrect authentication credentials. | The combination id and code is invalid. |
error | Unexpected error while processing. Please contact Trustprofile. | An unexpected error has occurred. This will probably only be solvable by the Trustprofile team. |
Example code
<?php
$id = 1;
$code = '123456789abc123456789';
$post = [
'email' => 'johndoe@gmail.com',
'order' => 'order123',
'language' => 'en',
'delay' => 0,
'customer_name' => 'John Doe',
'phone_numbers' => ['+31612345678'],
'order_total' => 1500.99,
'order_data' => json_encode([
'products' => [
[
'id' => '1234',
'name' => 'Product 1',
'url' => 'https://example.com/products/1',
'image_url' => 'https://example.com/products/images/1',
'sku' => 'PROD1234',
'gtin' => '12345678s',
],
],
]),
];
$curl = curl_init(
sprintf(
'https://dashboard.trustprofile.com/api/1.0/invitations.json?id=%s&code=%s',
$id,
$code,
),
);
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query($post),
]);
$response = curl_exec($curl);
if ($response !== false) {
$data = json_decode($response, true);
/*
$data will look similar to the format below:
$data = [
"status" => "success",
"message" => "Invitation successfully added to queue!"
];
*/
} else {
// An error occurred
}