Best practices for using the API, or why you should log the Push ID

If you are an avid user of our server APIs to manage your push messaging, you're familiar with our HTTP server responses. Tracking this information is important to you in the event you need to contact us for any support issues.

Please Log your API requests and our responses

First, we recommend that you always log the HTTP response code that you get from each request. This will allow you to look back and find out if there was a problem with a particular request, or to trigger automatic retries.

Retry on API errors

If you receive a 5xx response from our API, you should retry your request with a progressive back off method. Errors happen on the internet from time to time, and our best practices recommend that if you first do not succeed, please try, try again. When retrying your API call, please insert a progressive delay, so your first retry may occur in 5 seconds, your second in 30, and progressive calls back off further until success. You may want to handle exceptions for persistent failures. Log files after persistent failures will be essential for us to diagnose the issue with you.

Authentication issues

If you received a 4xx response, there was some problem with your authentication or the structure of your request.

Examples of successful pushes

When we receive a successful push request, we return valuable information back to you about your request. A typical push response looks something like this:

{
    "ok" : true,
    "operation_id" : "df6a6b50-9843-0304-d5a5-743f246a4946",
    "push_ids": [
        "9d78a53b-b16a-c58f-b78d-181d5e242078",
    ]
}

 And a rich message like this:

{
    "ok" : true,
    "operation_id" : "df6a6b50-9843-0304-d5a5-743f246a4946",
    "push_ids": [
        "9d78a53b-b16a-c58f-b78d-181d5e242078",
    ]
    "message_ids":[
         "lXiQ4roCcCDkmxlwDnER4x"
    ]
}

The key pieces that you want to keep are the push_ids for a standard push request and the message_ids for a rich push request. The 202 OK response means that we were successful in receiving your request for processing. The operation_id is currently saved for future functionality. Along with these responses, you should also track the full payload including it's exact date and time of request.

Why should you keep this information? We can use the push_ids and message_ids to look up your push in our systems. Saving these items can help us address problems you might have had with your push request. It also saves us valuable time when trying to determine other causes for problems with your push. If you're having trouble with push and receiving something other than an OK from us, please refer to our HTTP troubleshooting guide.

You can find the general docs about pushing via our API here.

 

Related Content