Available SDKs
| Language | Package | Repository |
|---|---|---|
| Node.js | @onesignal/node-onesignal | GitHub |
| Python | onesignal-python-api | GitHub |
| Java | onesignal-java-client | GitHub |
| Go | onesignal-go-api | GitHub |
| PHP | onesignal/onesignal-php-api | GitHub |
| Ruby | onesignal | GitHub |
| C# (.NET) | OneSignalApi | GitHub |
| Rust | onesignal-rust-api | GitHub |
Before you begin
Gather these values from your OneSignal dashboard before installing an SDK. See Keys & IDs for where to find each one.- App ID — the unique identifier for your OneSignal app.
- REST API Key — required for most endpoints (sending notifications, managing users).
- Organization API Key (optional) — only required for organization-level endpoints like creating or listing apps.
Installation
Version numbers below are examples. Check the package registry for each SDK to install the latest version.
- Node.js
- Python
- Java
- Go
- PHP
- Ruby
- C# (.NET)
- Rust
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.
- Node.js
- Python
- Java
- Go
- PHP
- Ruby
- C# (.NET)
- Rust
Send a push notification
Send push notifications to web and mobile Subscriptions by targeting a segment. Each example wraps the send call in try/catch (or the language equivalent) so failures surface instead of silently swallowing errors..NET: Normalize newline characters manually
.NET: Normalize newline characters manually
The .NET SDK does not normalize newline characters automatically. If your content contains
\r\n, normalize it before passing to Contents:Send an email
Send emails to Subscriptions with theemail channel.
Send an SMS
Send SMS text messages to Subscriptions with thesms channel.
Common send patterns
Target specific users, target specific devices, or schedule delivery. The JSON field names shown below map identically across every SDK — call the equivalent setter on yourNotification object (setIncludeAliases / include_aliases, setSendAfter / send_after, etc.).
Send by external ID
Send by external ID
Send to specific users by their
external_id alias. You must set target_channel when using aliases so OneSignal knows which channel to route the message on.Keys under
include_aliases must match API alias labels exactly (for example, external_id, not externalId).Send by subscription ID
Send by subscription ID
Send to specific subscriptions by their OneSignal-generated subscription ID. Use this when you already know the exact devices or channels you want to reach.
Schedule a send
Schedule a send
Set
send_after to a future timestamp to schedule delivery. Optionally set delayed_option to timezone or last-active to deliver per-subscription at a local time.Verify your setup
After callingcreateNotification, check the response for a non-empty id to confirm the notification was accepted:
Successful response
Response with no matching recipients
id, common causes are:
- Segment name is misspelled or has the wrong case (segment names are case-sensitive).
- The
external_idor subscription ID does not exist in your app. - All targeted subscriptions are unsubscribed.
Common errors
| Status | Meaning | Action |
|---|---|---|
| 400 | Malformed request or invalid field | Check field names and payload shape against the REST API reference. |
| 401 | Missing or invalid API key | Verify the key value and that it matches the app you’re targeting. |
| 403 | Wrong key scope (e.g. app REST key for an org endpoint) | Use the Organization API Key for org-level endpoints. |
| 404 | App, notification, user, or subscription not found | Verify the ID or alias in the dashboard. |
| 409 | Conflict — duplicate resource | For idempotent sends, this typically means the idempotency_key was replayed. |
| 429 | Rate limit exceeded | Wait for the Retry-After header before retrying; use exponential backoff. |
| 5xx | Server error | Retry with exponential backoff. |
Full API reference
Each server SDK supports the same set of endpoints — Notifications, Users, Subscriptions, Segments, Templates, Live Activities, Custom Events, API Keys, and Apps. TheDefaultApi docs list every method; the models docs describe request and response shapes. Each SDK also ships an AGENTS.md with an integration guide tailored to LLM-assisted coding.
| SDK | API methods | Models | LLM/agent guide |
|---|---|---|---|
| Node.js | DefaultApi.md | models/ | AGENTS.md |
| Python | DefaultApi.md | docs/ | AGENTS.md |
| Java | DefaultApi.md | docs/ | AGENTS.md |
| Go | DefaultApi.md | docs/ | AGENTS.md |
| PHP | DefaultApi.md | docs/Model/ | AGENTS.md |
| Ruby | DefaultApi.md | docs/ | AGENTS.md |
| C# (.NET) | DefaultApi.md | docs/ | AGENTS.md |
| Rust | default_api docs | docs/ | AGENTS.md |
FAQ
Which server SDK should I choose?
Use the SDK that matches your backend language. All server SDKs are generated from the same OpenAPI specification and support the same endpoints, so functionality is identical across languages.What is the difference between the REST API Key and Organization API Key?
The REST API Key is scoped to a single app and is required for most operations like sending notifications and managing users. The Organization API Key is scoped to your organization and is only needed for creating or listing apps. Most integrations only need the REST API Key.Can I use the REST API directly instead of an SDK?
Yes. The server SDKs are convenience wrappers around the OneSignal REST API. You can call the API directly using any HTTP client with thekey authentication scheme (Authorization: key YOUR_REST_API_KEY).
Are these SDKs auto-generated?
Yes. All server SDKs are generated from the OneSignal OpenAPI specification using OpenAPI Generator. This ensures consistent API coverage across all languages.Related pages
REST API overview
Endpoints, authentication, rate limits, and request/response formats.
Keys & IDs
Find your App ID, REST API key, and Organization API key.
Transactional messages
Send OTPs, receipts, and time-sensitive alerts via API with personalized data.
Identity verification
Secure your integration with server-generated JWTs to prevent User impersonation.