• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1page.title=Server Reference
2@jd:body
3
4<div id="qv-wrapper">
5<div id="qv">
6
7<h2>In this document</h2>
8
9<ol class="toc">
10  <li><a href="#downstream">Downstream Messages</a></li>
11<ol class="toc">
12      <li><a href="#send-downstream">Sending a downstream message</a></li>
13      <li><a href="#interpret-downstream">Interpreting a downstream message response</a></li>
14    </ol>
15  <li><a href="#upstream">Upstream Messages (XMPP)</a>
16    <ol class="toc">
17      <li><a href="#interpret-upstream">Interpreting an upstream XMPP message</a></li>
18      <li><a href="#upstream-response">Sending an upstream XMPP message response</a></li>
19    </ol>
20  </li>
21<li><a href="#ccs">Cloud Connection Server Messages (XMPP)</a></li>
22<li><a href="#error-codes">Downstream message error response codes (HTTP and XMPP)</a></li>
23</ol>
24
25</div>
26</div>
27
28<p>This document provides a reference for the syntax used to pass
29messages back and forth in GCM. These messages fall into
30the following broad categories:</p>
31
32<ul>
33   <li><a href="#downstream">Downstream messages</a></li>
34   <li><a href="#upstream">Upstream messages</a></li>
35   <li><a href="#ccs">Cloud Connection Server messages (XMPP)</a></li>
36   <li><a href="#error-codes">Downstream message error response codes (HTTP and XMPP)</a></li>
37</ul>
38
39<p>The following sections describe the basic requirements for
40sending messages.</p>
41
42<h2 id="downstream">Downstream Messages</h2>
43<p>This is the message that a 3rd-party app server sends to a client app.
44</p>
45<p>A downstream message includes the following components:</p>
46<ul>
47  <li>Target: specifies the recipient of the message.</li>
48  <li>Options: specifies attributes of the message.</li>
49  <li>Payload: specifies additional content to be included in the message. Optional.</li>
50</ul>
51
52<p>The syntax for each of these components is described in the tables below. </p>
53
54<h3 id="send-downstream">Sending a downstream message</h3>
55
56<p>This section gives the syntax for sending a downstream messages. For JSON,
57these messages can be either HTTP or XMPP. For plain text, these messages can only be HTTP.</p>
58
59<h4>Downstream HTTP or XMPP messages (JSON)</h4>
60
61<p>The following table lists the targets, options, and payload for HTTP or XMPP JSON messages.</p>
62<p class="table-caption" id="table1">
63  <strong>Table 1.</strong> Targets, options, and payload for downstream HTTP or XMPP message (JSON).</p>
64<table border="1">
65  <tr>
66    <th>Parameter</th>
67    <th>Protocol</th>
68    <th>Usage</th>
69    <th>Description</th>
70  </tr>
71<tr>
72    <td colspan="4"><strong>Targets</strong></td>
73  </tr>
74  <tr>
75    <td><code>to</code></td>
76    <td>XMPP</td>
77    <td>Required, string</td>
78    <td><p>This parameter specifies the recipient of a message. </p>
79      <p>The value must be a registration ID or notification key.</p>
80    <p>This parameter is used in XMPP in place of {@code registration_ids} or   {@code notification_key} in HTTP.</p></td>
81  </tr>
82  <tr>
83    <td><code>registration_ids</code></td>
84    <td>HTTP</td>
85    <td>Required if {@code notification_key} not present, string array</td>
86    <td><p>This parameter specifies the list of devices (registration IDs)
87receiving the message. It must contain at least 1 and at most 1000 registration IDs.</p>
88      <p>Multicast messages (sending to more than 1 registration IDs) are allowed using HTTP JSON format only.</p>
89    <p>This parameter or {@code notification_key} is used in HTTP in place of {@code to} in XMPP.</p></td>
90  </tr>
91  <tr>
92    <td><code>notification_key</code></td>
93    <td>HTTP</td>
94    <td>Required if {@code registration_ids} not present, string</td>
95    <td><p>This parameter specifies the mapping of a single user to
96multiple registration IDs associated with that user.</p>
97      <p>This allows a 3rd-party app server to send a single message to multiple app instances
98(typically on multiple devices) owned by a single user.</p>
99      <p>A 3rd-party app server can use {@code notification_key} as the target for a
100message instead of an individual registration ID (or array of registration IDs).
101The maximum number of members allowed for a {@code notification_key} is 20.</p>
102      <p>This parameter or {@code registration_ids} is used in HTTP in place of {@code to} in XMPP.</p>
103    <p>See <a href="notifications.html">User Notifications</a> for details.</p></td>
104  </tr>
105<tr>
106    <td colspan="4"><strong>Options</strong></td>
107  </tr>
108  <tr>
109    <td><code>message_id</code></td>
110    <td>XMPP</td>
111    <td>Required, string</td>
112    <td><p>This parameter uniquely identifies a message in an XMPP connection.</p></td>
113  </tr>
114  <tr>
115    <td><code>collapse_key</code></td>
116    <td>HTTP, XMPP</td>
117    <td>Optional, string</td>
118    <td><p>This parameters identifies a group of messages (e.g., with
119{@code collapse_key: "Updates Available"}) that can be collapsed, so that only the
120last message gets sent when delivery can be resumed. This is intended to avoid sending too
121many of the same messages when the device comes back online or becomes active (see {@code delay_while_idle}).</p>
122      <p>Note that there is no guarantee of the order in which messages get sent.</p>
123      <p>Messages with collapse key are also called
124<a href="{@docRoot}google/gcm/server.html#s2s">send-to-sync messages</a> messages.
125</p>
126    <p>Note: A maximum of 4 different collapse keys is allowed at any given time. This means a
127GCM connection server can simultaneously store 4 different send-to-sync messages per client app. If you
128exceed this number, there is no guarantee which 4 collapse keys the GCM connection server will keep. </p></td>
129  </tr>
130  <tr>
131    <td><code>delay_while_idle</code></td>
132    <td>HTTP, XMPP</td>
133    <td>Optional, JSON boolean</td>
134    <td>When this parameter is set to {@code true}, it indicates that the message should not be
135sent until the device becomes active.</p>
136    <p>The default value is {@code false}.</p></td>
137  </tr>
138  <tr>
139    <td><code>time_to_live</code></td>
140    <td>HTTP, XMPP</td>
141    <td>Optional, JSON number</td>
142    <td><p>This parameter specifies how long (in seconds) the message should be kept in GCM storage
143if the device is offline. The maximum time to live supported is 4 weeks.</p>
144    <p>The default value is 4 weeks. </p></td>
145  </tr>
146  <tr>
147    <td><code>delivery_receipt_
148<br>requested</code></td>
149    <td>XMPP</td>
150    <td>Optional, JSON boolean</td>
151    <td><p>This parameter lets 3rd-party app server request confirmation of message delivery.</p>
152      <p>When this parameter is set to {@code true}, CCS sends a delivery receipt
153when the device confirms that it received the message.</p>
154    <p>The default value is {@code false}.</p></td>
155  </tr>
156  <tr>
157    <td><code>restricted_package_
158<br>name</code></td>
159    <td>HTTP</td>
160    <td>Optional, string</td>
161    <td>This parameter specifies the package name of the application where the
162registration IDs must match in order to receive the message.</td>
163  </tr>
164  <tr>
165    <td><code>dry_run</code></td>
166    <td>HTTP</td>
167    <td>Optional, JSON boolean</td>
168    <td><p>This parameter, when set to {@code true}, allows developers to test a
169request without actually sending a message.</p>
170    <p>The default value is {@code false}.</p></td>
171  </tr>
172<tr>
173    <td colspan="4"><strong>Payload</strong></td>
174  </tr>
175  <tr>
176    <td><code>data</code></td>
177    <td>HTTP, XMPP</td>
178    <td>Optional, JSON object</td>
179    <td><p>This parameter specifies the key-value pairs of the message's payload. There is
180no limit on the number of key-value pairs, but there is a total message size limit of 4kb.</p>
181      <p>For instance, in Android, <code>data:{"score":"3x1"}</code> would result in an intent extra
182named {@code score} with the string value {@code 3x1}.</p>
183      <p>The key should not be a reserved word ({@code from} or any word starting with
184{@code google}). It is also not recommended to use words defined in this table
185(such as {@code collapse_key}) because that could yield unpredictable outcomes. </p>
186    <p>Values in string types are recommended. You have to convert values in objects
187or other non-string data types (e.g., integers or booleans) to string.</p></td>
188  </tr>
189</table>
190
191<h3>Downstream HTTP messages (Plain Text)</h3>
192
193<p>The following table lists the syntax for targets, options, and payload in plain
194text downstream HTTP messages.</p>
195
196<p class="table-caption" id="table2">
197  <strong>Table 2.</strong> Targets, options, and payload for downstream plain text HTTP messages.</p>
198
199<table border="1">
200  <tr>
201    <th>Parameter</th>
202    <th>Usage</th>
203    <th>Description</th>
204  </tr>
205<tr>
206    <td colspan="3"><strong>Targets</strong></td>
207  </tr>
208  <tr>
209    <td><code>registration _id</code></td>
210    <td>Required, string</td>
211    <td><p>This parameter specifies the client apps (registration ID) receiving the message.</p>
212    <p>Multicast messaging (sending to more than one registration ID) is allowed using HTTP JSON format only.</p></td>
213  </tr>
214<tr>
215    <td colspan="3"><strong>Options</strong></td>
216  </tr>
217  <tr>
218    <td><code>collapse_key</code></td>
219    <td>Optional, string</td>
220    <td>See <a href="#table1">table 1</a> for details.</td>
221  </tr>
222  <tr>
223    <td><code>delay_while_idle</code></td>
224    <td>Optional, boolean or number</td>
225    <td>See <a href="#table1">table 1</a> for details.</td>
226  </tr>
227  <tr>
228    <td><code>time_to_live</code></td>
229    <td>Optional, number</td>
230    <td>See <a href="#table1">table 1</a> for details.</td>
231  </tr>
232  <tr>
233    <td><code>restricted_package_name</code></td>
234    <td>Optional, string</td>
235    <td>See <a href="#table1">table 1</a> for details.</td>
236  </tr>
237  <tr>
238    <td><code>dry_run </code></td>
239    <td>Optional, boolean</td>
240    <td>See <a href="#table1">table 1</a> for details.</td>
241  </tr>
242<tr>
243    <td colspan="3"><strong>Payload</strong></td>
244  </tr>
245  <tr>
246    <td><code>data.&lt;key&gt;</code></td>
247    <td>Optional, string</td>
248    <td><p>This parameter specifies the key-value pairs of the message's payload.
249There is no limit on the number of key-value parameters,
250but there is a total message size limit of 4kb.</p>
251      <p>For instance, in Android, <code>data:{"score":"3x1"}</code> would result in an intent extra
252named {@code score} with the string value {@code 3x1}.</p>
253    <p>The key should not be a reserved word ({@code from} or any word starting with
254{@code google}). It is also not recommended to use words defined in this table
255(such as {@code collapse_key}) because that could yield unpredictable outcomes.</p></td>
256  </tr>
257</table>
258
259<h3 id="interpret-downstream">Interpreting a Downstream Message Response</h3>
260
261<p>This section describes the syntax of a response to a downstream message. A client
262app or the GCM Connection Server sends the response to 3rd-party app server upon processing
263the message request. </p>
264
265<h4>Interpreting a downstream HTTP message response </h4>
266<p>The 3rd-party app server should look at both the message response header and the body
267to interpret the message response sent from the GCM Connection Server. The following table
268describes the possible responses.</p>
269<p>
270
271<p class="table-caption" id="table3">
272  <strong>Table 3.</strong> Downstream HTTP message response header.</p>
273<table border=1>
274  <tr>
275    <th>Response</th>
276    <th>Description</th>
277  </tr>
278  <tr>
279    <td>200</td>
280    <td>Message was processed successfully. The response body will contain more
281details about the message status, but its format will depend whether the request
282was JSON or plain text. See <a href="#table4">table 4</a>
283for more details.</td>
284  </tr>
285  <tr>
286    <td>400</td>
287    <td>Only applies for JSON requests.
288Indicates that the request could not be parsed as JSON, or it contained invalid
289fields (for instance, passing a string where a number was expected). The exact
290failure reason is described in the response and the problem should be addressed
291before the request can be retried.</td>
292  </tr>
293  <tr>
294    <td>401</td>
295    <td>There was an error authenticating the sender account.
296<a href="server.html#auth_error">Troubleshoot</a></td>
297  </tr>
298  <tr>
299    <td>5xx</td>
300    <td>Errors in the 500-599 range (such as 500 or 503) indicate that there was
301an internal error in the GCM server while trying to process the request, or that
302the server is temporarily unavailable (for example, because of timeouts). Sender
303must retry later, honoring any <code>Retry-After</code> header included in the
304response. Application servers must implement exponential back-off.
305<a href="server.html#internal_error">Troubleshoot</a></td>
306  </tr>
307</table>
308
309<p>The following table lists the fields in a downstream message response body
310(JSON).</p>
311
312
313<p class="table-caption" id="table4">
314  <strong>Table 4.</strong> Downstream HTTP message response body (JSON).</p>
315<table>
316  <tr>
317    <th>Parameter</th>
318    <th>Usage</th>
319    <th>Description</th>
320  </tr>
321  <tr>
322    <td><code>multicast_id</code></td>
323    <td>Required, number</td>
324    <td>Unique ID (number) identifying the multicast message.</td>
325  </tr>
326  <tr>
327    <td><code>success</code></td>
328    <td>Required, number</td>
329    <td>Number of messages that were processed without an error.</td>
330  </tr>
331  <tr>
332    <td><code>failure</code></td>
333    <td>Required, number</td>
334    <td>Number of messages that could not be processed.</td>
335  </tr>
336  <tr>
337    <td><code>canonical_ids</code></td>
338    <td>Required, number</td>
339    <td>Number of results that contain a canonical registration ID. See the
340<a href="{@docRoot}google/gcm/gcm.html#canonical">Overview</a> for more discussion of this topic.</td>
341  </tr>
342  <tr>
343    <td><code>results</code></td>
344    <td>Optional, array object</td>
345    <td>Array of objects representing the status of the messages processed. The
346objects are listed in the same order as the request (i.e., for each registration
347ID in the request, its result is listed in the same index in the response).<br>
348      <ul>
349        <li><code>message_id</code>: String specifying a unique ID for each successfully processed
350          message.</li>
351        <li><code>registration_id</code>: Optional string specifying the canonical registration ID
352          for the client app that the message was processed and sent to. Sender should use this
353          value as the Registration ID for future requests. Otherwise, the messages might
354          be rejected.
355        </li>
356        <li><code>error</code>: String specifying the error that occurred when processing the
357          message for the recipient. The possible values can be found in <a href="#table11">table 11
358        </a>.</li>
359    </ul></td>
360  </tr>
361</table>
362
363
364<p class="table-caption" id="table5">
365  <strong>Table 5.</strong> Success response for downstream HTTP message response body (Plain Text).</p>
366<table border="1">
367  <tr>
368    <th>Parameter</th>
369    <th>Usage</th>
370    <th>Description</th>
371  </tr>
372  <tr>
373    <td><code>id</code></td>
374    <td>Required, string</td>
375    <td>This parameter specifies the unique message ID that GCM server processed successfully.</td>
376  </tr>
377  <tr>
378    <td><code>registration_id</code></td>
379    <td>Optional, string</td>
380    <td>This parameter specifies the canonical registration ID for the client app that the message was
381processed and sent to. Sender should replace the registration ID with this value on future requests,
382otherwise, the messages might be rejected.</td>
383  </tr>
384</table>
385
386<p class="table-caption" id="table6">
387  <strong>Table 6.</strong> Error response for downstream HTTP message response body (Plain Text).</p>
388<table border="1">
389  <tr>
390    <th>Parameter</th>
391    <th>Usage</th>
392    <th>Description</th>
393  </tr>
394  <tr>
395    <td>{@code Error}</td>
396    <td>Required, string</td>
397    <td>This parameter specifies the error value while processing the message for the recipient.
398See <a href="#table11">table 11</a> for details. </td>
399  </tr>
400</table>
401
402<h4>Interpreting a downstream XMPP message response</h4>
403
404<p>The following table lists the fields that appear in a downstream XMPP message response.</p>
405
406<p class="table-caption" id="table7">
407  <strong>Table 7.</strong> Downstream message XMPP message response body.</p>
408<table border="1">
409  <tr>
410    <th>Parameter</th>
411    <th>Usage</th>
412    <th>Description</th>
413  </tr>
414  <tr>
415    <td><code>from</code></td>
416    <td>Required, string</td>
417    <td><p>This parameter specifies who sent this response.</p>
418    <p>The value is the registration ID of the client app.</p></td>
419  </tr>
420  <tr>
421    <td><code>message_id</code></td>
422    <td>Required, string</td>
423    <td>This parameter uniquely identifies a message in an XMPP connection.
424The value is a string that uniquely identifies the associated message.</td>
425  </tr>
426  <tr>
427    <td><code>message_type</code></td>
428    <td>Required, string</td>
429    <td><p>This parameter specifies an 'ack' or 'nack' message from XMPP (CCS)
430to the 3rd-party app server.</p>
431    <p>If the value is set to {@code nack}, the 3rd-party app server should look at
432{@code error} and {@code error_description} to get failure information. </p></td>
433  </tr>
434  <tr>
435    <td><code>error</code></td>
436    <td>Optional, string</td>
437    <td>This parameter specifies an error related to the downstream message. It is set when the
438{@code message_type} is {@code nack}. See <a href="#table11">table 6</a> for details.</td>
439  </tr>
440  <tr>
441    <td><code>error_description</code></td>
442    <td>Optional, string</td>
443    <td>This parameter provides descriptive information for the error. It is set
444when the {@code message_type} is {@code nack}.</td>
445  </tr>
446</table>
447<h2 id="upstream">Upstream Messages (XMPP)</h2>
448
449<p>An upstream message is a message the client app sends to the 3rd-party app server.
450Currently only CCS (XMPP) supports upstream messaging.</p>
451
452<h3 id="interpret-upstream">Interpreting an upstream XMPP message </h3>
453<p>The following table describes the fields that appear in an upstream XMPP message.
454
455<p class="table-caption" id="table8">
456  <strong>Table 8.</strong> Upstream XMPP messages.</p>
457<table border="1">
458  <tr>
459    <th>Parameter</th>
460    <th>Usage</th>
461    <th>Description</th>
462  </tr>
463  <tr>
464    <td><code>from</code></td>
465    <td>Required, string</td>
466    <td><p>This parameter specifies who sent the message.</p>
467    <p>The value is the registration ID of the client app.</p></td>
468  </tr>
469  <tr>
470    <td><code>category</code></td>
471    <td>Required, string</td>
472    <td>This parameter specifies the application package name of the client app that sent the message. </td>
473  </tr>
474  <tr>
475    <td><code>message_id</code></td>
476    <td>Required, string</td>
477    <td>This parameter specifies the unique ID of the message. </td>
478  </tr>
479  <tr>
480    <td><code>data</code></td>
481    <td>Optional, string</td>
482    <td>This parameter specifies the key-value pairs of the message's payload.</td>
483  </tr>
484</table>
485
486<h3 id="upstream-response">Sending an upstream XMPP message response</h3>
487
488<p>The following table describes the response that 3rd-party app server is expected to send to
489<a href="{@docRoot}google/gcm/ccs.html">XMPP (CCS)</a> in response to an
490upstream message it (the app server) received.</p>
491
492<p class="table-caption" id="table9">
493  <strong>Table 9.</strong> Upstream XMPP message response.</p>
494<table border="1">
495  <tr>
496    <th>Parameter</th>
497    <th>Usage</th>
498    <th>Description</th>
499  </tr>
500  <tr>
501    <td><code>to</code></td>
502    <td>Required, string</td>
503    <td><p>This parameter specifies the recipient of a response message. </p>
504    <p>The value must be a registration ID of the client app that sent the upstream message.</p></td>
505  </tr>
506  <tr>
507    <td><code>message_id</code></td>
508    <td>Required, string</td>
509    <td>This parameter specifies which message the response is intended for. The value must be
510the {@code message_id} value from the corresponding upstream message.</td>
511  </tr>
512  <tr>
513    <td><code>message_type</code></td>
514    <td>Required, string</td>
515    <td>This parameter specifies an {@code ack} message from a 3rd-party app server to CCS.</td>
516  </tr>
517</table>
518<h2 id="ccs">Cloud Connection Server Messages (XMPP) </h2>
519<p>This is a message sent from XMPP (CCS) to a 3rd-party app server. Here are the primary types
520of messages that XMPP (CCS) sends to the 3rd-party app server:</p>
521<ul>
522  <li><strong>Delivery Receipt:</strong> If the 3rd-party app server included {@code delivery_receipt_requested}
523in the downstream message, XMPP (CCS) sends a delivery receipt when it receives confirmation
524that the device received the message.</li>
525  <li><strong>Control:</strong> These CCS-generated messages indicate that
526action is required from the 3rd-party app server.</li>
527</ul>
528
529<p>The following table describes the fields included in the messages CCS
530sends to a 3rd-party app server.</p>
531
532<p class="table-caption" id="table10">
533  <strong>Table 10.</strong> GCM Cloud Connection Server messages (XMPP).</p>
534<table border="1">
535  <tr>
536    <th>Parameter</th>
537    <th>Usage</th>
538    <th>Description</th>
539  </tr>
540  <tr>
541    <td colspan="3"><strong>Common Field</strong></td>
542  </tr>
543  <tr>
544    <td><code>message_type</code></td>
545    <td>Required, string</td>
546    <td><p>This parameter specifies the type of the CCS message: either delivery receipt or control.</p>
547      <p>When it is set to {@code receipt}, the message includes {@code from}, {@code message_id},
548        {@code category} and {@code data} fields to provide additional information.</p>
549    <p>When it is set to {@code control}, the message includes {@code control_type} to indicate the
550type of control message.</p></td>
551  </tr>
552  <tr>
553    <td colspan="3"><strong>Delivery receipt-specific</strong></td>
554  </tr>
555  <tr>
556    <td><code>from</code></td>
557    <td>Required, string</td>
558    <td>This parameter is set to {@code gcm.googleapis.com}, indicating that the
559message is sent from CCS.</td>
560  </tr>
561  <tr>
562    <td><code>message_id</code></td>
563    <td>Required, string</td>
564    <td>This parameter specifies the original message ID that the receipt is intended for,
565prefixed with {@code dr2:} to indicate that the message is a delivery receipt. A 3rd-party app
566server must send an {@code ack} message with this message ID to acknowledge that it
567received this delivery receipt. See <a href="#table9">table 9</a> for the 'ack' message format.</td>
568  </tr>
569  <tr>
570    <td><code>category</code></td>
571    <td>Optional, string</td>
572    <td>This parameter specifies the application package name of the client app that
573receives the message that this delivery receipt is reporting. This is available when
574{@code message_type} is {@code receipt}.</td>
575  </tr>
576  <tr>
577    <td><code>data</code></td>
578    <td>Optional, string</td>
579    <td>This parameter specifies the key-value pairs for the delivery receipt message. This is available
580when the {@code message_type} is {@code receipt}.
581      <ul>
582        <li>{@code message_status}: This parameter specifies the status of the receipt message.
583It is set to {@code MESSAGE_SENT_TO_DEVICE} to indicate the device has confirmed its receipt of
584the original message.</li>
585      <li>{@code original_message_id}: This parameter specifies the ID of the original message
586that the 3rd-party app server sent to the client app.</li>
587     <li>{@code device_registration_id}: This parameter specifies the registration ID of the
588client app to which the original message was sent.</li>
589    </ul>
590</td>
591  </tr>
592  <tr>
593    <td colspan="3"><strong>Control-specific</strong></td>
594  </tr>
595  <tr>
596    <td><code>control_type</code></td>
597    <td>Optional, string</td>
598    <td><p>This parameter specifies the type of control message sent from CCS.</p>
599    <p>Currently, only {@code CONNECTION_DRAINING} is supported. XMPP (CCS) sends this control message
600before it closes a connection to perform load balancing. As the connection drains, no more messages
601are allowed to be sent to the connection, but existing messages in the pipeline will
602continue to be processed.</p></td>
603  </tr>
604</table>
605
606<h2 id="error-codes">Downstream message error response codes (HTTP and XMPP)</h2>
607
608<p>The following table lists the error response codes for downstream messages (HTTP and XMPP).</p>
609
610<p class="table-caption" id="table11">
611  <strong>Table 11.</strong> Downstream message error response codes.</p>
612<table border="1">
613  <tr>
614    <th>Error</th>
615    <th>HTTP Code</th>
616    <th>XMPP Code</th>
617    <th>Recommended Action</th>
618  </tr>
619  <tr>
620    <td>Missing Registration ID</td>
621    <td>200 + error:MissingRegistration</td>
622    <td><code>INVALID_JSON</code></td>
623    <td>Check that the request contains a registration ID (either in the
624{@code registration_id} in a plain text message, or in the {@code registration_ids} in JSON).</td>
625  </tr>
626  <tr>
627    <td>Invalid Registration ID</td>
628    <td>200 + error:InvalidRegistration</td>
629    <td><code>BAD_REGISTRATION</code></td>
630    <td>Check the format of the registration ID you pass to the server. Make sure it
631matches the registration ID the client app receives from registering with GCM. Do not
632truncate or add additional characters.</td>
633  </tr>
634  <tr>
635    <td>Unregistered Device</td>
636    <td>200 + error:NotRegistered</td>
637    <td><code>DEVICE_UNREGISTERED</code></td>
638    <td>An existing registration ID may cease to be valid in a number of scenarios, including:<br>
639     <ul>
640      <li>If the client app unregisters with GCM.</li>
641      <li>If the client app is automatically unregistered, which can happen if the user uninstalls the application.</li>
642      <li>If the registration ID expires (for example, Google might decide to refresh registration IDs).</li>
643      <li>If the client app is updated but the new version is not configured to receive messages.</li>
644</ul>
645 For all these cases, remove this registration ID from the 3rd-party app
646server and stop using it to send messages.</td>
647  </tr>
648  <tr>
649    <td>Invalid Package Name</td>
650    <td>200 + error:InvalidPackageName</td>
651    <td></td>
652    <td>Make sure the message was addressed to a registration ID whose package name
653matches the value passed in the request.</td>
654  </tr>
655  <tr>
656    <td>Authentication Error</td>
657    <td>401</td>
658    <td>&nbsp;</td>
659    <td>The sender account used to send a message couldn't be authenticated. Possible causes are:<br>
660<ul>
661      <li>Authorization header missing or with invalid syntax in HTTP request.</li>
662      <li>Invalid project number sent as key.</li>
663      <li>Key valid but with GCM service disabled.</li>
664      <li>Request originated from a server not whitelisted in the Server Key IPs.</li>
665</ul>
666    Check that the token you're sending inside the Authentication header is
667the correct API key associated with your project. See
668<a href="{@docRoot}google/gcm/http.html">GCM HTTP Connection Server</a> for details.</td>
669  </tr>
670  <tr>
671    <td>Mismatched Sender</td>
672    <td>200 + error:MismatchSenderId</td>
673    <td><code>BAD_REGISTRATION</code></td>
674    <td>A registration ID is tied to a certain group of senders. When a client app registers
675for GCM, it must specify which senders are allowed to send messages. You should use one
676of those sender IDs when sending messages to the client app. If you switch to a different
677sender, the existing registration IDs won't work.</td>
678  </tr>
679  <tr>
680    <td>Invalid JSON</td>
681    <td>400</td>
682    <td><code>INVALID_JSON</code></td>
683    <td>Check that the JSON message is properly formatted and contains valid fields
684(for instance, making sure the right data type is passed in).</td>
685  </tr>
686  <tr>
687    <td>Message Too Big</td>
688    <td>200 + error:MessageTooBig</td>
689    <td><code>INVALID_JSON</code></td>
690    <td>Check that the total size of the payload data included in a message does
691not exceed 4096 bytes. This includes both the the keys and the values.</td>
692  </tr>
693  <tr>
694    <td>Invalid Data Key</td>
695    <td>200 + error:
696<br />
697InvalidDataKey</td>
698    <td><code>INVALID_JSON</code></td>
699    <td>Check that the payload data does not contain a key (such as {@code from} or any value
700prefixed by {@code google}) that is used internally by GCM. Note that some words (such as {@code collapse_key})
701are also used by GCM but are allowed in the payload, in which case the payload value
702will be overridden by the GCM value.</td>
703  </tr>
704  <tr>
705    <td>Invalid Time to Live</td>
706    <td>200 + error:InvalidTtl</td>
707    <td><code>INVALID_JSON</code></td>
708    <td>Check that the value used in {@code time_to_live} is an integer representing a
709duration in seconds between 0 and 2,419,200 (4 weeks).</td>
710  </tr>
711  <tr>
712    <td>Bad ACK message</td>
713    <td>N/A</td>
714    <td><code>BAD_ACK</code></td>
715    <td>Check that the 'ack' message is properly formatted before retrying. See
716<a href="#table9">table 9</a> for details.</td>
717  </tr>
718  <tr>
719    <td>Timeout</td>
720    <td>5xx or 200 + error:Unavailable</td>
721    <td><code>SERVICE_UNAVAILABLE</code></td>
722    <td><p>The server couldn't process the request in time. Retry the same request, but you must:<br>
723<ul>
724      <li>For HTTP: Honor the {@code Retry-After} header if it is included in the response from the
725GCM Connection Server.</li>
726      <li>Implement exponential back-off in your retry mechanism. (e.g. if you waited one second
727before the first retry, wait at least two second before the next one, then 4 seconds and so on).
728If you're sending multiple messages, delay each one independently by an additional random amount
729to avoid issuing a new request for all messages at the same time.</li>
730    <li>For CCS: The initial retry delay should be set to 1 second.</li>
731</ul>
732    <p>Senders that cause problems risk being blacklisted.</p></td>
733  </tr>
734  <tr>
735    <td>Internal Server Error</td>
736    <td>500 or 200 + error:InternalServerError</td>
737    <td><code>INTERNAL_SERVER_
738<br />
739ERROR</code></td>
740    <td>The server encountered an error while trying to process the request. You could retry
741the same request following the requirements listed in "Timeout" (see row above). If the error persists, please
742report the problem in the {@code android-gcm group}.</td>
743  </tr>
744  <tr>
745    <td>Device Message Rate Exceeded</td>
746    <td>200 + error:
747<br />DeviceMessageRate
748<br />
749Exceeded</td>
750    <td><code>DEVICE_MESSAGE_RATE<br />
751_EXCEEDED</code></td>
752    <td>The rate of messages to a particular device is too high. Reduce the
753number of messages sent to this device and do not immediately retry sending to this device.</td>
754  </tr>
755  <tr>
756    <td>Connection Draining</td>
757    <td>N/A</td>
758    <td><code>CONNECTION_DRAINING</code></td>
759    <td>The message couldn't be processed because the connection is draining. This happens because
760periodically, XMPP (CCS) needs to close down a connection to perform load balancing. Retry the message over
761another XMPP connection.</td>
762  </tr>
763</table>
764