Mock Data
Update Mock Data
Update the mock data for a template. Sets the input payload, recipient, tenant, actor, and batching configuration used for previews and testing.
PATCH
/
v2
/
{workspace}
/
template
/
{template_slug}
/
mock_data
/
Update Mock Data
curl -X PATCH "https://management-api.suprsend.com/v2/{workspace}/template/{template_slug}/mock_data/" \
--header 'Authorization: ServiceToken <token>' \
--header 'Content-Type: application/json' \
--data '{
"data": {
"payload": {"order_id": "ORD-1234", "amount": "$99.99"},
"tenant_id": "default",
"is_batch": false,
"recipient_sub_type": "user",
"recipient_distinct_id": "user-123"
}
}'import requests
url = "https://management-api.suprsend.com/v2/{workspace}/template/{template_slug}/mock_data/"
payload = { "data": {
"payload": {},
"tenant_id": "default",
"is_batch": False,
"batch_count": 2,
"recipient_sub_type": "user",
"recipient_distinct_id": "user-123",
"recipient_object": {
"object_type": "<string>",
"id": "<string>"
},
"actor_distinct_id": "<string>",
"actor_object": {
"object_type": "<string>",
"id": "<string>"
}
} }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data: {
payload: {},
tenant_id: 'default',
is_batch: false,
batch_count: 2,
recipient_sub_type: 'user',
recipient_distinct_id: 'user-123',
recipient_object: {object_type: '<string>', id: '<string>'},
actor_distinct_id: '<string>',
actor_object: {object_type: '<string>', id: '<string>'}
}
})
};
fetch('https://management-api.suprsend.com/v2/{workspace}/template/{template_slug}/mock_data/', 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://management-api.suprsend.com/v2/{workspace}/template/{template_slug}/mock_data/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'data' => [
'payload' => [
],
'tenant_id' => 'default',
'is_batch' => false,
'batch_count' => 2,
'recipient_sub_type' => 'user',
'recipient_distinct_id' => 'user-123',
'recipient_object' => [
'object_type' => '<string>',
'id' => '<string>'
],
'actor_distinct_id' => '<string>',
'actor_object' => [
'object_type' => '<string>',
'id' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$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://management-api.suprsend.com/v2/{workspace}/template/{template_slug}/mock_data/"
payload := strings.NewReader("{\n \"data\": {\n \"payload\": {},\n \"tenant_id\": \"default\",\n \"is_batch\": false,\n \"batch_count\": 2,\n \"recipient_sub_type\": \"user\",\n \"recipient_distinct_id\": \"user-123\",\n \"recipient_object\": {\n \"object_type\": \"<string>\",\n \"id\": \"<string>\"\n },\n \"actor_distinct_id\": \"<string>\",\n \"actor_object\": {\n \"object_type\": \"<string>\",\n \"id\": \"<string>\"\n }\n }\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "<api-key>")
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.patch("https://management-api.suprsend.com/v2/{workspace}/template/{template_slug}/mock_data/")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"payload\": {},\n \"tenant_id\": \"default\",\n \"is_batch\": false,\n \"batch_count\": 2,\n \"recipient_sub_type\": \"user\",\n \"recipient_distinct_id\": \"user-123\",\n \"recipient_object\": {\n \"object_type\": \"<string>\",\n \"id\": \"<string>\"\n },\n \"actor_distinct_id\": \"<string>\",\n \"actor_object\": {\n \"object_type\": \"<string>\",\n \"id\": \"<string>\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://management-api.suprsend.com/v2/{workspace}/template/{template_slug}/mock_data/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": {\n \"payload\": {},\n \"tenant_id\": \"default\",\n \"is_batch\": false,\n \"batch_count\": 2,\n \"recipient_sub_type\": \"user\",\n \"recipient_distinct_id\": \"user-123\",\n \"recipient_object\": {\n \"object_type\": \"<string>\",\n \"id\": \"<string>\"\n },\n \"actor_distinct_id\": \"<string>\",\n \"actor_object\": {\n \"object_type\": \"<string>\",\n \"id\": \"<string>\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"payload": {
"user": {
"name": "Pat Morgan"
},
"event": {
"status": "shipped"
}
},
"tenant_id": "default",
"is_batch": false,
"batch_count": 2,
"recipient_sub_type": "user",
"recipient_object": null,
"recipient_distinct_id": "user_12345",
"actor_sub_type": "user",
"actor_object": null,
"actor_distinct_id": "actor_67890"
},
"transformed_data": {
"user": {
"name": "Pat Morgan"
},
"event": {
"status": "shipped"
},
"$tenant": {
"id": "default",
"name": "My Company",
"logo": "https://cdn.example.com/logo.png",
"primary_color": "#2E70E8",
"secondary_color": "#63A3F7",
"tertiary_color": "#FFFFFF",
"embedded_preference_url": "https://preferences.example.com/embed",
"hosted_preference_domain": "preferences.example.com",
"blocked_channels": null,
"social_links": {
"website": "https://www.example.com",
"linkedin": "https://linkedin.com/company/example"
},
"properties": {},
"timezone": null
},
"$user": {
"name": "Jamie Rivera",
"email": "jamie.rivera@example.com",
"distinct_id": "user_12345"
},
"$recipient": {
"name": "Jamie Rivera",
"email": "jamie.rivera@example.com",
"distinct_id": "user_12345"
},
"$actor": {
"name": "Taylor Chen",
"email": "taylor.chen@example.com",
"distinct_id": "actor_67890"
},
"$embedded_preference_url": "https://preferences.example.com/embed",
"$hosted_preference_url": "https://preferences.example.com/preference?key=xxxxxxxxxxxxxxx"
}
}{
"code": 401,
"error_code": "authentication_failed",
"type": "AuthenticationFailed",
"message": "Invalid service token.",
"detail": "Invalid service token."
}{
"code": 404,
"error_code": "not_found",
"type": "NotFound",
"message": "workspace 'demo' not found",
"detail": "workspace 'demo' not found"
}Authorizations
Pass as Authorization: ServiceToken <token>. You can get Service Token from SuprSend dashboard -> Account Settings -> Service Tokens section.
Body
application/json
Mock data configuration. Keys you pass replace the stored keys; keys you leave out are kept. If data is omitted or empty, the stored mock data is not changed.
Show child attributes
Show child attributes
Response
Mock data updated successfully. Returns the same structure as Get Mock Data - both data (raw config) and transformed_data (resolved values).
The response is of type object.
Was this page helpful?
⌘I
Update Mock Data
curl -X PATCH "https://management-api.suprsend.com/v2/{workspace}/template/{template_slug}/mock_data/" \
--header 'Authorization: ServiceToken <token>' \
--header 'Content-Type: application/json' \
--data '{
"data": {
"payload": {"order_id": "ORD-1234", "amount": "$99.99"},
"tenant_id": "default",
"is_batch": false,
"recipient_sub_type": "user",
"recipient_distinct_id": "user-123"
}
}'import requests
url = "https://management-api.suprsend.com/v2/{workspace}/template/{template_slug}/mock_data/"
payload = { "data": {
"payload": {},
"tenant_id": "default",
"is_batch": False,
"batch_count": 2,
"recipient_sub_type": "user",
"recipient_distinct_id": "user-123",
"recipient_object": {
"object_type": "<string>",
"id": "<string>"
},
"actor_distinct_id": "<string>",
"actor_object": {
"object_type": "<string>",
"id": "<string>"
}
} }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data: {
payload: {},
tenant_id: 'default',
is_batch: false,
batch_count: 2,
recipient_sub_type: 'user',
recipient_distinct_id: 'user-123',
recipient_object: {object_type: '<string>', id: '<string>'},
actor_distinct_id: '<string>',
actor_object: {object_type: '<string>', id: '<string>'}
}
})
};
fetch('https://management-api.suprsend.com/v2/{workspace}/template/{template_slug}/mock_data/', 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://management-api.suprsend.com/v2/{workspace}/template/{template_slug}/mock_data/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'data' => [
'payload' => [
],
'tenant_id' => 'default',
'is_batch' => false,
'batch_count' => 2,
'recipient_sub_type' => 'user',
'recipient_distinct_id' => 'user-123',
'recipient_object' => [
'object_type' => '<string>',
'id' => '<string>'
],
'actor_distinct_id' => '<string>',
'actor_object' => [
'object_type' => '<string>',
'id' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$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://management-api.suprsend.com/v2/{workspace}/template/{template_slug}/mock_data/"
payload := strings.NewReader("{\n \"data\": {\n \"payload\": {},\n \"tenant_id\": \"default\",\n \"is_batch\": false,\n \"batch_count\": 2,\n \"recipient_sub_type\": \"user\",\n \"recipient_distinct_id\": \"user-123\",\n \"recipient_object\": {\n \"object_type\": \"<string>\",\n \"id\": \"<string>\"\n },\n \"actor_distinct_id\": \"<string>\",\n \"actor_object\": {\n \"object_type\": \"<string>\",\n \"id\": \"<string>\"\n }\n }\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "<api-key>")
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.patch("https://management-api.suprsend.com/v2/{workspace}/template/{template_slug}/mock_data/")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"payload\": {},\n \"tenant_id\": \"default\",\n \"is_batch\": false,\n \"batch_count\": 2,\n \"recipient_sub_type\": \"user\",\n \"recipient_distinct_id\": \"user-123\",\n \"recipient_object\": {\n \"object_type\": \"<string>\",\n \"id\": \"<string>\"\n },\n \"actor_distinct_id\": \"<string>\",\n \"actor_object\": {\n \"object_type\": \"<string>\",\n \"id\": \"<string>\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://management-api.suprsend.com/v2/{workspace}/template/{template_slug}/mock_data/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": {\n \"payload\": {},\n \"tenant_id\": \"default\",\n \"is_batch\": false,\n \"batch_count\": 2,\n \"recipient_sub_type\": \"user\",\n \"recipient_distinct_id\": \"user-123\",\n \"recipient_object\": {\n \"object_type\": \"<string>\",\n \"id\": \"<string>\"\n },\n \"actor_distinct_id\": \"<string>\",\n \"actor_object\": {\n \"object_type\": \"<string>\",\n \"id\": \"<string>\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"payload": {
"user": {
"name": "Pat Morgan"
},
"event": {
"status": "shipped"
}
},
"tenant_id": "default",
"is_batch": false,
"batch_count": 2,
"recipient_sub_type": "user",
"recipient_object": null,
"recipient_distinct_id": "user_12345",
"actor_sub_type": "user",
"actor_object": null,
"actor_distinct_id": "actor_67890"
},
"transformed_data": {
"user": {
"name": "Pat Morgan"
},
"event": {
"status": "shipped"
},
"$tenant": {
"id": "default",
"name": "My Company",
"logo": "https://cdn.example.com/logo.png",
"primary_color": "#2E70E8",
"secondary_color": "#63A3F7",
"tertiary_color": "#FFFFFF",
"embedded_preference_url": "https://preferences.example.com/embed",
"hosted_preference_domain": "preferences.example.com",
"blocked_channels": null,
"social_links": {
"website": "https://www.example.com",
"linkedin": "https://linkedin.com/company/example"
},
"properties": {},
"timezone": null
},
"$user": {
"name": "Jamie Rivera",
"email": "jamie.rivera@example.com",
"distinct_id": "user_12345"
},
"$recipient": {
"name": "Jamie Rivera",
"email": "jamie.rivera@example.com",
"distinct_id": "user_12345"
},
"$actor": {
"name": "Taylor Chen",
"email": "taylor.chen@example.com",
"distinct_id": "actor_67890"
},
"$embedded_preference_url": "https://preferences.example.com/embed",
"$hosted_preference_url": "https://preferences.example.com/preference?key=xxxxxxxxxxxxxxx"
}
}{
"code": 401,
"error_code": "authentication_failed",
"type": "AuthenticationFailed",
"message": "Invalid service token.",
"detail": "Invalid service token."
}{
"code": 404,
"error_code": "not_found",
"type": "NotFound",
"message": "workspace 'demo' not found",
"detail": "workspace 'demo' not found"
}