Launch Single Web Pushes
  • 14 Feb 2024
  • 2 Minutes to read

    Launch Single Web Pushes


      Article Summary

      Overview

      Insider's web push API allows you to launch single web push notifications from your own back-end without using Insider's InOne panel.

      Endpoint and Headers

      POST https://web-push.api.useinsider.com/v1/single/campaign_id

      Headers

      HeaderSample ValueDescription
      AuthorizationBearer 1a2b3c4d5e6fThis key is required to authorize your request. Refer to API Authentication Tokens to generate your token.
      Content-Typeapplication/jsonThis header specifies the media type of the resource.

      Body Parameters

      Each request body requires a partner ID and a title. 

      ParameterDescriptionData TypeRequired
      partner_idThis is your partner identification number, available from InOne Settings > Account Preferences.StringYes
      titleEvery request creates a push notification campaign on InOne with the push type Single Push. This is the title of the push content. Itcannot be more than 100 characters.StringYes
      descriptionThis is the body of your push notification. It cannot be more than 255 characters. If it is a rich push that has a banner, it is limited to 30 characters.StringYes
      imageThis is the push notification icon. Only HTTPS protocols are accepted. If not provided, the default icon is used instead.StringYes
      bannerThis is the rich push notification image. Only HTTPS protocols are accepted.StringNo
      linkThe link of the Web push message.StringYes
      include_unengagedEnables you to decide whether the bulk push should target unengaged tokens. When not sent in the payload, unengaged users are automatically excluded.Boolean (true/false)No
      ttlShort for time to live: This is the maximum time the system will try to send a push notification to an offline or temporarily unavailable user. TTL is limited to 240 hours.StringYes
      targetTargeting options for the campaign (segmenting).ObjectYes if is_all: false
           attributeThe attribute used for targeting, e.g. "d_wp_browser".StringYes if target is used.
           valuesAn array of values to target, e.g. ["Edg"]ArrayYes if target is used.
      Your title goes here
      If you want to use default attributes, you need to use “d_Default_attribute_name” format. However, if you want to use custom attributes, you need to add “c_Custom_attribute_name” format. You can refer here for further information.

      Sample Example

      Before sending the request, make sure:

      • To replace the authorization value with your own API key.
      • To add your partner ID in partner_id.
      • To add your campaign name in title.
      Your title goes here
      When you send the request to create it, you will get your campaign_id as a response.

      Sample Request

      Below you can see a sample request without segments; is_all: true.

      curl --location --request POST 'https://web-push.api.useinsider.com/v1/single/campaign_id' \
      --header 'Content-Type: application/json' \
      --header 'Authorization: Bearer 1a2b3c4d5e6f' \
      --data-raw '{
        "partner_id": "100000001",
        "title": "title of push",
        "description": "description of push",
        "image": "https://image.useinsider.com/mywebsite/webPushDefaultImage/JpVu9aBXgTXmcrBkiZLB1512577074.jpeg",
        "banner": "https://image.useinsider.com/mywebsite/webPushDefaultImage/JpVu9aBXgTXmcrBkiZLB1512577074.jpeg",
        "link": "https://image.useinsider.com",
        "include_unengage": true,
        "ttl": "1000"
      }'

      Below you can see a sample request with segments; is_all: false.

      curl --location --request POST 'https://web-push.api.useinsider.com/v1/single/campaign_id' \
      --header 'Content-Type: application/json' \
      --header 'Authorization: Bearer 1a2b3c4d5e6f' \
      --data-raw '{
        "partner_id": "10000001",
        "title": "title of push",
        "description": "description of push",
        "image": "https://image.useinsider.com/mywebsite/webPushDefaultImage/JpVu9aBXgTXmcrBkiZLB1512577074.jpeg",
        "banner": "https://image.useinsider.com/mywebsite/webPushDefaultImage/JpVu9aBXgTXmcrBkiZLB1512577074.jpeg",
        "link": "https://image.useinsider.com",
        "include_unengage": true,
        "ttl": "1000",
        "language": "en_US",
        "target": {
          "attribute": "d_wp_browser",
          "values": ["Edg"]
        }
      }'

      Sample Responses

      200 OK

      You can see this kind of response when you successfully launched your campaign.

      {
        "success": true,
        "campaign_id": 1697300275
      }

      401 Unauthorized

      {
      "message": "Unauthorized"
      }

      424 Failed Dependency

      {
        "message": "SERVICE:-"
      }

      Error Codes

      • 400: Bad request
      • 401: Unauthorized request
      • 424 Failed Dependency
      • 429 Request limit exceeded

      Limitations

      • All functions must be executed with an HTTPS POST request.
      • The API key should be provided as the authorization key on the request header. If the key is incorrect, the operation will not be executed and an authorization error will return in the response.
      • The rate limit is 30 requests per minute second.

      Was this article helpful?

      ESC

      Eddy, a super-smart generative AI, opening up ways to have tailored queries and responses