How to hit the OneSignal API

OneSignal's API at https://api.onesignal.com sends push notifications, email, and SMS to your app's users.

Authentication

Copy your app's REST API key from Settings → Keys & IDs in OneSignal and send it as Authorization: Key <key>. In the examples it's written {{ONESIGNAL_API_KEY}}, and {{ONESIGNAL_APP_ID}} is your app id.

Full reference: https://documentation.onesignal.com/reference/rest-api-overview

Send a push notification

included_segments targets a segment; use one targeting method per message.

curl -X POST https://api.onesignal.com/notifications \
  -H "Authorization: Key {{ONESIGNAL_API_KEY}}" \
  -H "Content-Type: application/json" \
  -d '{"app_id": "{{ONESIGNAL_APP_ID}}", "included_segments": ["Total Subscriptions"], "contents": {"en": "Hello from PostTaco"}}'
Run in PostTaco