Save Push Notification Template
Saves push notification template for title
Error codes
This operation may return the following PlayFab errors:
| Error | Code |
|---|---|
| InvalidLocalizedPushNotificationLanguage | 1409 |
| MissingLocalizedPushNotificationMessage | 1410 |
| PushNotificationTemplateAndroidPayloadMissingNotificationBody | 1416 |
| PushNotificationTemplateContainsInvalidAndroidPayload | 1414 |
| PushNotificationTemplateContainsInvalidIosPayload | 1413 |
| PushNotificationTemplateInvalidPayload | 1408 |
| PushNotificationTemplateInvalidSyntax | 1419 |
| PushNotificationTemplateIosPayloadMissingNotificationBody | 1415 |
| PushNotificationTemplateMissingDefaultVersion | 1418 |
| PushNotificationTemplateMissingName | 1442 |
| PushNotificationTemplateMissingPlatformPayload | 1411 |
| PushNotificationTemplateNoCustomPayloadForV1 | 1420 |
| PushNotificationTemplatePayloadContainsInvalidJson | 1412 |
| TitleDefaultLanguageNotSet | 1393 |
curl --request POST \
--url https://{titleId}.playfabapi.com/Server/SavePushNotificationTemplate \
--header 'Content-Type: application/json' \
--header 'X-SecretKey: <api-key>' \
--data '
{
"Id": "6bc7dbf0-075a-46e9-8e84-35737a22c6a4",
"Name": "F8763A987E",
"AndroidPayload": "{ notification: { body: \"Some Message\", title: \"Subject\", body_loc_key: \"someLocKey\" } }",
"IOSPayload": "{ aps: { alert: { body: \"Some Message\", title: \"Subject\", \"loc-key\": \"someLocKey\" } } }",
"LocalizedPushNotificationTemplates": {
"en": {
"Subject": "Recent Attack",
"Message": "You have been attacked! Go defend your base!"
},
"fr": {
"Subject": "Attaque récente",
"Message": "Vous avez été attaqué! Va défendre ta base!"
}
}
}
'import requests
url = "https://{titleId}.playfabapi.com/Server/SavePushNotificationTemplate"
payload = {
"Id": "6bc7dbf0-075a-46e9-8e84-35737a22c6a4",
"Name": "F8763A987E",
"AndroidPayload": "{ notification: { body: \"Some Message\", title: \"Subject\", body_loc_key: \"someLocKey\" } }",
"IOSPayload": "{ aps: { alert: { body: \"Some Message\", title: \"Subject\", \"loc-key\": \"someLocKey\" } } }",
"LocalizedPushNotificationTemplates": {
"en": {
"Subject": "Recent Attack",
"Message": "You have been attacked! Go defend your base!"
},
"fr": {
"Subject": "Attaque récente",
"Message": "Vous avez été attaqué! Va défendre ta base!"
}
}
}
headers = {
"X-SecretKey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-SecretKey': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
Id: '6bc7dbf0-075a-46e9-8e84-35737a22c6a4',
Name: 'F8763A987E',
AndroidPayload: '{ notification: { body: "Some Message", title: "Subject", body_loc_key: "someLocKey" } }',
IOSPayload: '{ aps: { alert: { body: "Some Message", title: "Subject", "loc-key": "someLocKey" } } }',
LocalizedPushNotificationTemplates: {
en: {
Subject: 'Recent Attack',
Message: 'You have been attacked! Go defend your base!'
},
fr: {
Subject: 'Attaque récente',
Message: 'Vous avez été attaqué! Va défendre ta base!'
}
}
})
};
fetch('https://{titleId}.playfabapi.com/Server/SavePushNotificationTemplate', 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://{titleId}.playfabapi.com/Server/SavePushNotificationTemplate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'Id' => '6bc7dbf0-075a-46e9-8e84-35737a22c6a4',
'Name' => 'F8763A987E',
'AndroidPayload' => '{ notification: { body: "Some Message", title: "Subject", body_loc_key: "someLocKey" } }',
'IOSPayload' => '{ aps: { alert: { body: "Some Message", title: "Subject", "loc-key": "someLocKey" } } }',
'LocalizedPushNotificationTemplates' => [
'en' => [
'Subject' => 'Recent Attack',
'Message' => 'You have been attacked! Go defend your base!'
],
'fr' => [
'Subject' => 'Attaque récente',
'Message' => 'Vous avez été attaqué! Va défendre ta base!'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-SecretKey: <api-key>"
],
]);
$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://{titleId}.playfabapi.com/Server/SavePushNotificationTemplate"
payload := strings.NewReader("{\n \"Id\": \"6bc7dbf0-075a-46e9-8e84-35737a22c6a4\",\n \"Name\": \"F8763A987E\",\n \"AndroidPayload\": \"{ notification: { body: \\\"Some Message\\\", title: \\\"Subject\\\", body_loc_key: \\\"someLocKey\\\" } }\",\n \"IOSPayload\": \"{ aps: { alert: { body: \\\"Some Message\\\", title: \\\"Subject\\\", \\\"loc-key\\\": \\\"someLocKey\\\" } } }\",\n \"LocalizedPushNotificationTemplates\": {\n \"en\": {\n \"Subject\": \"Recent Attack\",\n \"Message\": \"You have been attacked! Go defend your base!\"\n },\n \"fr\": {\n \"Subject\": \"Attaque récente\",\n \"Message\": \"Vous avez été attaqué! Va défendre ta base!\"\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-SecretKey", "<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.post("https://{titleId}.playfabapi.com/Server/SavePushNotificationTemplate")
.header("X-SecretKey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"Id\": \"6bc7dbf0-075a-46e9-8e84-35737a22c6a4\",\n \"Name\": \"F8763A987E\",\n \"AndroidPayload\": \"{ notification: { body: \\\"Some Message\\\", title: \\\"Subject\\\", body_loc_key: \\\"someLocKey\\\" } }\",\n \"IOSPayload\": \"{ aps: { alert: { body: \\\"Some Message\\\", title: \\\"Subject\\\", \\\"loc-key\\\": \\\"someLocKey\\\" } } }\",\n \"LocalizedPushNotificationTemplates\": {\n \"en\": {\n \"Subject\": \"Recent Attack\",\n \"Message\": \"You have been attacked! Go defend your base!\"\n },\n \"fr\": {\n \"Subject\": \"Attaque récente\",\n \"Message\": \"Vous avez été attaqué! Va défendre ta base!\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{titleId}.playfabapi.com/Server/SavePushNotificationTemplate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-SecretKey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"Id\": \"6bc7dbf0-075a-46e9-8e84-35737a22c6a4\",\n \"Name\": \"F8763A987E\",\n \"AndroidPayload\": \"{ notification: { body: \\\"Some Message\\\", title: \\\"Subject\\\", body_loc_key: \\\"someLocKey\\\" } }\",\n \"IOSPayload\": \"{ aps: { alert: { body: \\\"Some Message\\\", title: \\\"Subject\\\", \\\"loc-key\\\": \\\"someLocKey\\\" } } }\",\n \"LocalizedPushNotificationTemplates\": {\n \"en\": {\n \"Subject\": \"Recent Attack\",\n \"Message\": \"You have been attacked! Go defend your base!\"\n },\n \"fr\": {\n \"Subject\": \"Attaque récente\",\n \"Message\": \"Vous avez été attaqué! Va défendre ta base!\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"code": 200,
"status": "OK",
"data": {
"PushNotificationTemplateId": "6bc7dbf0-075a-46e9-8e84-35737a22c6a4"
}
}{
"code": 123,
"errorCode": 123,
"status": "<string>",
"error": "<string>",
"errorMessage": "<string>",
"errorDetails": {}
}Authorizations
This API requires a title secret key, available to title admins, from PlayFab Game Manager.
Body
Represents the save push notification template request.
Represents the save push notification template request.
Name of the push notification template.
Android JSON for the notification template.
Id of the push notification template.
IOS JSON for the notification template.
Dictionary of localized push notification templates with the language as the key.
Show child attributes
Show child attributes
Response
Represents the save push notification template result.
The Http status code. If X-ReportErrorAsSuccess header is set to true, this will report the actual http error code.
The Http status code as a string.
Represents the save push notification template result.
Show child attributes
Show child attributes
{
"PushNotificationTemplateId": "6bc7dbf0-075a-46e9-8e84-35737a22c6a4"
}
Was this page helpful?
curl --request POST \
--url https://{titleId}.playfabapi.com/Server/SavePushNotificationTemplate \
--header 'Content-Type: application/json' \
--header 'X-SecretKey: <api-key>' \
--data '
{
"Id": "6bc7dbf0-075a-46e9-8e84-35737a22c6a4",
"Name": "F8763A987E",
"AndroidPayload": "{ notification: { body: \"Some Message\", title: \"Subject\", body_loc_key: \"someLocKey\" } }",
"IOSPayload": "{ aps: { alert: { body: \"Some Message\", title: \"Subject\", \"loc-key\": \"someLocKey\" } } }",
"LocalizedPushNotificationTemplates": {
"en": {
"Subject": "Recent Attack",
"Message": "You have been attacked! Go defend your base!"
},
"fr": {
"Subject": "Attaque récente",
"Message": "Vous avez été attaqué! Va défendre ta base!"
}
}
}
'import requests
url = "https://{titleId}.playfabapi.com/Server/SavePushNotificationTemplate"
payload = {
"Id": "6bc7dbf0-075a-46e9-8e84-35737a22c6a4",
"Name": "F8763A987E",
"AndroidPayload": "{ notification: { body: \"Some Message\", title: \"Subject\", body_loc_key: \"someLocKey\" } }",
"IOSPayload": "{ aps: { alert: { body: \"Some Message\", title: \"Subject\", \"loc-key\": \"someLocKey\" } } }",
"LocalizedPushNotificationTemplates": {
"en": {
"Subject": "Recent Attack",
"Message": "You have been attacked! Go defend your base!"
},
"fr": {
"Subject": "Attaque récente",
"Message": "Vous avez été attaqué! Va défendre ta base!"
}
}
}
headers = {
"X-SecretKey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-SecretKey': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
Id: '6bc7dbf0-075a-46e9-8e84-35737a22c6a4',
Name: 'F8763A987E',
AndroidPayload: '{ notification: { body: "Some Message", title: "Subject", body_loc_key: "someLocKey" } }',
IOSPayload: '{ aps: { alert: { body: "Some Message", title: "Subject", "loc-key": "someLocKey" } } }',
LocalizedPushNotificationTemplates: {
en: {
Subject: 'Recent Attack',
Message: 'You have been attacked! Go defend your base!'
},
fr: {
Subject: 'Attaque récente',
Message: 'Vous avez été attaqué! Va défendre ta base!'
}
}
})
};
fetch('https://{titleId}.playfabapi.com/Server/SavePushNotificationTemplate', 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://{titleId}.playfabapi.com/Server/SavePushNotificationTemplate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'Id' => '6bc7dbf0-075a-46e9-8e84-35737a22c6a4',
'Name' => 'F8763A987E',
'AndroidPayload' => '{ notification: { body: "Some Message", title: "Subject", body_loc_key: "someLocKey" } }',
'IOSPayload' => '{ aps: { alert: { body: "Some Message", title: "Subject", "loc-key": "someLocKey" } } }',
'LocalizedPushNotificationTemplates' => [
'en' => [
'Subject' => 'Recent Attack',
'Message' => 'You have been attacked! Go defend your base!'
],
'fr' => [
'Subject' => 'Attaque récente',
'Message' => 'Vous avez été attaqué! Va défendre ta base!'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-SecretKey: <api-key>"
],
]);
$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://{titleId}.playfabapi.com/Server/SavePushNotificationTemplate"
payload := strings.NewReader("{\n \"Id\": \"6bc7dbf0-075a-46e9-8e84-35737a22c6a4\",\n \"Name\": \"F8763A987E\",\n \"AndroidPayload\": \"{ notification: { body: \\\"Some Message\\\", title: \\\"Subject\\\", body_loc_key: \\\"someLocKey\\\" } }\",\n \"IOSPayload\": \"{ aps: { alert: { body: \\\"Some Message\\\", title: \\\"Subject\\\", \\\"loc-key\\\": \\\"someLocKey\\\" } } }\",\n \"LocalizedPushNotificationTemplates\": {\n \"en\": {\n \"Subject\": \"Recent Attack\",\n \"Message\": \"You have been attacked! Go defend your base!\"\n },\n \"fr\": {\n \"Subject\": \"Attaque récente\",\n \"Message\": \"Vous avez été attaqué! Va défendre ta base!\"\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-SecretKey", "<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.post("https://{titleId}.playfabapi.com/Server/SavePushNotificationTemplate")
.header("X-SecretKey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"Id\": \"6bc7dbf0-075a-46e9-8e84-35737a22c6a4\",\n \"Name\": \"F8763A987E\",\n \"AndroidPayload\": \"{ notification: { body: \\\"Some Message\\\", title: \\\"Subject\\\", body_loc_key: \\\"someLocKey\\\" } }\",\n \"IOSPayload\": \"{ aps: { alert: { body: \\\"Some Message\\\", title: \\\"Subject\\\", \\\"loc-key\\\": \\\"someLocKey\\\" } } }\",\n \"LocalizedPushNotificationTemplates\": {\n \"en\": {\n \"Subject\": \"Recent Attack\",\n \"Message\": \"You have been attacked! Go defend your base!\"\n },\n \"fr\": {\n \"Subject\": \"Attaque récente\",\n \"Message\": \"Vous avez été attaqué! Va défendre ta base!\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{titleId}.playfabapi.com/Server/SavePushNotificationTemplate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-SecretKey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"Id\": \"6bc7dbf0-075a-46e9-8e84-35737a22c6a4\",\n \"Name\": \"F8763A987E\",\n \"AndroidPayload\": \"{ notification: { body: \\\"Some Message\\\", title: \\\"Subject\\\", body_loc_key: \\\"someLocKey\\\" } }\",\n \"IOSPayload\": \"{ aps: { alert: { body: \\\"Some Message\\\", title: \\\"Subject\\\", \\\"loc-key\\\": \\\"someLocKey\\\" } } }\",\n \"LocalizedPushNotificationTemplates\": {\n \"en\": {\n \"Subject\": \"Recent Attack\",\n \"Message\": \"You have been attacked! Go defend your base!\"\n },\n \"fr\": {\n \"Subject\": \"Attaque récente\",\n \"Message\": \"Vous avez été attaqué! Va défendre ta base!\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"code": 200,
"status": "OK",
"data": {
"PushNotificationTemplateId": "6bc7dbf0-075a-46e9-8e84-35737a22c6a4"
}
}{
"code": 123,
"errorCode": 123,
"status": "<string>",
"error": "<string>",
"errorMessage": "<string>",
"errorDetails": {}
}