Skip to content

Repository files navigation

Rust API client for onesignal-rust-api

Building with an AI agent or LLM? See AGENTS.md for an agent-oriented integration guide — authentication, calling conventions, idempotent retries, and the full API reference.

A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com

For more information, please visit https://onesignal.com

  • API version: 5.14.0
  • Package version: 5.14.0

Installation

Add to Cargo.toml under [dependencies]:

onesignal-rust-api = "5.14.0"

Configuration

Every SDK requires authentication via API keys. Two key types are available:

  • REST API Key — required for most endpoints (sending notifications, managing users, etc.). Found in your app's Settings > Keys & IDs.
  • Organization API Key — only required for organization-level endpoints like creating or listing apps. Found in Organization Settings.

Warning: Store your API keys in environment variables or a secrets manager. Never commit them to source control.

use onesignal_rust_api::apis::configuration::Configuration;fncreate_configuration() -> Configuration{letmut config = Configuration::new();
config.rest_api_key_token = Some("YOUR_REST_API_KEY".to_string());
config.organization_api_key_token = Some("YOUR_ORGANIZATION_API_KEY".to_string());
config
}

Send a push notification

use onesignal_rust_api::apis::default_api;use onesignal_rust_api::models::{Notification,LanguageStringMap};use onesignal_rust_api::models::notification::TargetChannelType;letmut contents = LanguageStringMap::new();
contents.en = Some("Hello from OneSignal!".to_string());letmut headings = LanguageStringMap::new();
headings.en = Some("Push Notification".to_string());letmut notification = Notification::new("YOUR_APP_ID".to_string());
notification.contents = Some(Box::new(contents));
notification.headings = Some(Box::new(headings));
notification.included_segments = Some(vec!["Subscribed Users".to_string()]);let config = create_configuration();let response = default_api::create_notification(&config, notification).await;

Send an email

letmut notification = Notification::new("YOUR_APP_ID".to_string());
notification.email_subject = Some("Important Update".to_string());
notification.email_body = Some("<h1>Hello!</h1><p>This is an HTML email.</p>".to_string());
notification.included_segments = Some(vec!["Subscribed Users".to_string()]);
notification.target_channel = Some(TargetChannelType::Email);let response = default_api::create_notification(&config, notification).await;

Send an SMS

letmut contents = LanguageStringMap::new();
contents.en = Some("Your SMS message content here".to_string());letmut notification = Notification::new("YOUR_APP_ID".to_string());
notification.contents = Some(Box::new(contents));
notification.included_segments = Some(vec!["Subscribed Users".to_string()]);
notification.target_channel = Some(TargetChannelType::Sms);
notification.sms_from = Some("+15551234567".to_string());let response = default_api::create_notification(&config, notification).await;

Full API reference

The complete list of API endpoints and their parameters is available in the DefaultApi documentation.

For the underlying REST API, see the OneSignal API reference.

About

OneSignal Rust API Client SDK library

Topics

Resources

Stars

12 stars

Watchers

27 watching

Forks

Releases

Packages

Used by

Contributors

Languages