Skip to main content

Notifications API

Send notifications to players from your game server: a turn in an asynchronous battle, an attack on the player's base, the end of an auction, a reply from support.

Methods are called with an API key, as admin requests:

# Access Key
X-API-Secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# Project ID
X-Project-ID: 12345
MethodDescriptionCost
SendNotificationSend a notification to players, now or later1 request per call + 2 requests per delivered push
CancelNotificationCancel a pending notification of a player by tag1 request

The limits of your plan, the daily limit per player and platform limits apply to notifications sent through the API. Quiet hours and skip rules also apply: skipped and failed pushes are not charged.

SendNotification​

Send a notification to one or more players. You can use a template from the control panel or pass the title and text directly.

mutation ($input: SendNotificationInput!) {
result: SendNotification(input: $input) {
__typename
... on SendNotificationResult {
queued
inbox
rejectedPlayerIds
}
... on Problem {
message
}
}
}

Variables with a template:

{
"input": {
"projectId": 12345,
"playerIds": [579134513, 579134514],
"template": "BASE_ATTACKED",
"variables": { "attacker": "Dark Knight" },
"payload": "screen=base",
"delivery": "PUSH_AND_INBOX",
"inboxTags": ["battle"],
"idempotencyKey": "attack-98231"
}
}

Variables without a template, delayed sending:

{
"input": {
"projectId": 12345,
"playerIds": [579134513],
"title": { "en": "Auction", "ru": "Аукцион" },
"text": { "en": "Your lot has been sold!", "ru": "Ваш лот продан!" },
"sendAt": "2026-12-01T12:00:00Z",
"tag": "AUCTION_123"
}
}

Input Parameters​

ParameterTypeDescription
projectIdInt!Project ID
playerIds[Int!]!IDs of players, from 1 to 1000 per call
templateStringTemplate tag or ID. If not passed, title and text are required
titleTranslationsInputTitle with translations, if there is no template
textTranslationsInputText with translations, if there is no template
variablesAnyTemplate variables. More
payloadStringPayload for the game: when the player opens the notification and in the inbox message (message.payload). More
sendAtStringDelayed sending time in RFC 3339 format with a time zone, for example 2026-12-01T12:00:00Z, up to 30 days ahead. If not passed, the notification is sent immediately
tagStringNotification tag. Sending again with the same tag overwrites the pending notification of the player
deliveryNotificationDeliveryPUSH (default), INBOX, PUSH_AND_INBOX or INBOX_FALLBACK. More
inboxTags[String!]Tags of the inbox message
claimableBooleanThe player can claim the inbox message. false by default
idempotencyKeyStringIdempotency key. Duplicates are removed per player: a repeated call with the same key does not send the notification again to the same player. Use it for retries

Result​

FieldTypeDescription
queuedInt!How many notifications are queued for sending. For all deliveries except INBOX, including PUSH_AND_INBOX
inboxInt!How many messages are put into the inbox. Counted only for the INBOX delivery
rejectedPlayerIds[Int!]!IDs of players for whom the notification could not be queued: the player is not found, removed or belongs to another project

Errors​

On an error result is a Problem with the error code in message:

ErrorWhat it means
notifications_disabledNotifications are disabled in the project settings
notification_template_not_foundThe template is not found
bad_inputNeither a template nor a title and text are passed, or playerIds is empty or has more than 1000 IDs. The message has details after the code
notification_bad_delaysendAt is more than 30 days ahead
sendAt must be ISO 8601sendAt is not in RFC 3339 format, for example the time zone is missing

CancelNotification​

Cancel a pending notification of a player by tag. For example, the player has returned to the game before the auction ended.

mutation ($input: CancelNotificationInput!) {
result: CancelNotification(input: $input) {
__typename
... on Success {
success
}
... on Problem {
message
}
}
}
{
"input": {
"projectId": 12345,
"playerId": 579134513,
"tag": "AUCTION_123"
}
}
ParameterTypeDescription
projectIdInt!Project ID
playerIdInt!Player ID
tagString!Notification tag

The tag is shared with notifications scheduled by the game client with gp.notifications.schedule(). So the server can cancel a notification scheduled by the game, and vice versa.

Example in JS​

const SEND_NOTIFICATION = `mutation ($input: SendNotificationInput!) {
result: SendNotification(input: $input) {
__typename
... on SendNotificationResult {
queued
inbox
rejectedPlayerIds
}
... on Problem {
message
}
}
}`;

const result = await fetch('https://api.gamepush.com/gs/api/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Secret': 'mykey', // Only on the server, keep it secure
'X-Project-ID': '12345',
},
body: JSON.stringify({
query: SEND_NOTIFICATION,
variables: {
input: {
projectId: 12345,
playerIds: [579134513],
template: 'YOUR_TURN',
variables: { opponent: 'Alex' },
payload: JSON.stringify({ screen: 'battle', battleId: 777 }),
delivery: 'INBOX_FALLBACK',
idempotencyKey: 'battle-777-turn-12',
},
},
}),
})
.then((r) => r.json())
.then((r) => r.data.result);

if (result.__typename === 'Problem') {
throw result.message;
}

console.log('Queued:', result.queued, 'Inbox:', result.inbox);

Stay in Touch​

Other documents of this chapter available Here. To get started, welcome to the Tutorials chapter.

GamePush Community Telegram: @gs_community.

For your suggestions e-mail: official@gamepush.com

We Wish you Success!