Last modified April 1, 2020 by Shelly Wolfe

Push via API

Trigger push notifications campaigns in Swrve using an external, third-party system event and send notifications to a single user or a group of users with the Swrve Push API.

Swrve’s streamlined campaign workflow now supports creating push notification campaigns that are triggered via API. Use the newly redesigned message builder to include predefined content or include custom content when sending the API call from your external system. For information about configuring your request to the Push API, see the Swrve push API guide.

The new campaign workflow for push is currently available as part of our Early Access program. To have this feature enabled for your app, contact your CSM at support@swrve.com.

Creating a push API campaign

The first steps for creating a push via API campaign are similar to creating a standard push campaign.

To set up your campaign

  1. To create a new campaign from your Campaigns center, select Create campaign.
  2. On the Choose your marketing channel screen, select the Push campaign channel.
  3. Under Choose Notification type, select Push via API as the push type.
  4. Under Choose platform, Any is selected by default. If your app supports multiple platforms, the campaign will be sent to qualifying users regardless of their platform. If you need to create a platform-specific campaign, select the individual platform.
  5. To continue to the Campaign overview screen, select Continue.
  6. Enter the Campaign name and Description, then select Save to go to the campaign builder.

The blocks on the campaign screen guide you through building your campaign, but you can complete them in any order.

Campaign builder page for a push API campaign

There are two main differences between the blocks available for a standard push campaign and push via API. Since push via API campaigns are triggered externally, there is no need to specify the Audience or Schedule. Push via API campaigns have an additional API block where you can test the content you want to send via API call.

For general information about each section, see the following:


Default campaign content

If you want to include default content for your push API campaign, on the Content block, select edit . Adding content is optional—if the API call includes custom parameters, it overwrites the default content. For more information about custom parameters, see the Push API guide.

The options available for adding your notification content are the same as standard push, except you cannot personalize, localize, or test multiple variants of a push API campaign. For information on adding notification content, see Adding your notification content.


Testing the campaign

To preview your message on a physical device, first ensure your device is set up on the QA Devices screen.

  1. On the Content screen or API block, select Test.
  2. In the Send test message window, select your device from the list.
  3. The window displays sample cURL and HTTP POST commands with the campaign-specific API key and your user ID.
    Send test message window with push API campaign cURL and HTTP POST commands
    Select Copy to clipboard and edit the test message as required.
  4. To send the test message to the device, run the cURL command in the terminal or copy the HTTP POST command to a REST client service like Insomnia or Postman (remembering to use POST, not GET).

Starting the campaign

If you’re happy with your test message and are ready to make the campaign active, on the Campaign builder, select Activate campaign.

Once the campaign is active, use the campaign-specific Push API Key and URL displayed on the API block to trigger push notifications to individual users, either via webhooks from a third-party system or using your own custom code.

API block with push API key and test button

For more information on the API call method, URL parameter, expected responses, and possible error codes, see the Swrve push API guide.


Next steps