Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 144 additions & 1 deletion api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2255,6 +2255,57 @@ paths:
- rest_api_key: []
summary: Export CSV of Events
x-accepts: application/json
/notifications/count-unsaved:
post:
description: "Returns the estimated number of recipients for a notification's\
\ targeting, without creating or sending anything.\nThe returned `count` reflects\
\ the same audience-size estimate you would see under \"Choose your target\
\ audience\" when composing a message. It is based on the user targeting method\
\ you've set and the specific platforms the message is targeted to send to.\n\
This endpoint only supports a subset of targeting parameters: `included_segments`\
\ is required (its `\"All\"` shorthand targets every subscriber), and `excluded_segments`,\
\ `filters`, `include_aliases`, and `target_channel` narrow that audience\
\ further. Use `target_channel` to select platforms. `include_subscription_ids`\
\ and the other raw subscription id/token fields, and the individual `isIos`\
\ / `isAndroid` / etc. platform flags, are not supported. All other notification\
\ fields (content, delivery options, and so on) are accepted, but ignored.\n"
operationId: estimate_notification_recipients
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/EstimateNotificationRecipientsRequest'
required: true
responses:
default:
content:
application/json:
schema:
$ref: '#/components/schemas/GenericError'
description: Unexpected error
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/EstimateNotificationRecipientsSuccessResponse'
description: OK
"400":
content:
application/json:
schema:
$ref: '#/components/schemas/GenericError'
description: Bad Request
"429":
content:
application/json:
schema:
$ref: '#/components/schemas/RateLimitError'
description: Rate Limit Exceeded
security:
- rest_api_key: []
summary: Estimate notification recipients
x-content-type: application/json
x-accepts: application/json
/templates:
get:
description: List templates for an app.
Expand Down Expand Up @@ -3728,7 +3779,9 @@ components:
description: "The segment names you want to target. Users in these segments\
\ will receive a notification. This targeting parameter is only compatible\
\ with excluded_segments.\nExample: [\"Active Users\", \"Inactive Users\"\
]\n"
]\n`\"All\"` is a shorthand for every subscribed user: if the array includes\
\ the string `\"All\"` and the app has no segment actually named `All`,\
\ it targets all subscribers instead of a literal segment lookup.\n"
items:
type: string
type: array
Expand Down Expand Up @@ -5046,6 +5099,55 @@ components:
\ be 200 with partial success. Typed SDKs model this loosely so both shapes\
\ deserialize."
type: object
EstimateNotificationRecipientsRequest:
allOf:
- $ref: '#/components/schemas/SegmentNotificationTarget'
- $ref: '#/components/schemas/EstimateNotificationRecipientsRequest_allOf'
- required:
- app_id
description: "The targeting subset of notification fields this endpoint honors.\
\ `included_segments` (or its `\"All\"` shorthand) is required. `excluded_segments`,\
\ `filters`, `include_aliases`, and `target_channel` narrow that segment-based\
\ audience further when present. Use `target_channel` to select which platforms\
\ to count. Other notification targeting fields (`include_subscription_ids`\
\ and the other raw subscription id/token fields, and the individual `isIos`\
\ / `isAndroid` / etc. platform flags) are not read by this endpoint. All\
\ non-targeting notification fields (content, delivery options, and so on)\
\ are accepted, but ignored.\n"
EstimateNotificationRecipientsSuccessResponse:
example:
mobile_suppressed: true
uncapped_count: 6
count: 0
mobile_excluded_count: 1
cap_applied: true
properties:
count:
description: "The estimated audience size based on the user targeting method\
\ you've set on the message, and the specific platforms the message is\
\ targeted to send to."
type: integer
uncapped_count:
description: The estimated audience size before the plan's web push subscriber
cap is applied. Present only when `cap_applied` is `true`; `null` otherwise.
nullable: true
type: integer
cap_applied:
description: Whether `count` was reduced because the app is on a plan that
caps the number of web push subscribers it can send to.
type: boolean
mobile_suppressed:
description: The mobile equivalent of `cap_applied`. Whether mobile push
deliveries will be dropped for this send because the org is over its plan's
mobile push subscriber cap. `false` when the notification doesn't target
any mobile push platforms.
type: boolean
mobile_excluded_count:
description: How many mobile push recipients the `count` excludes due to
the plan's mobile push subscriber cap. `0` when `mobile_suppressed` is
`false`.
type: integer
type: object
GenericSuccessBoolResponse:
example:
success: true
Expand Down Expand Up @@ -9131,6 +9233,47 @@ components:
unsubscribe link in this email.
nullable: true
type: integer
EstimateNotificationRecipientsRequest_allOf:
properties:
app_id:
description: "The OneSignal App ID for your app, which can be found in Keys\
\ & IDs."
type: string
filters:
items:
$ref: '#/components/schemas/FilterExpression'
nullable: true
type: array
include_aliases:
additionalProperties:
items:
type: string
type: array
description: "Target specific users by aliases assigned via API. An alias\
\ can be an external_id, onesignal_id, or a custom alias.\nAccepts an\
\ object where keys are alias labels and values are arrays of alias IDs\
\ to include\nExample usage: { \"external_id\": [\"exId1\", \"extId2\"\
], \"internal_label\": [\"id1\", \"id2\"] }\nKeys must match API spellings\
\ exactly (for example the label for External ID is the string `external_id`;\
\ arbitrary keys such as camelCase variants are not aliases and may yield\
\ no recipients).\nNot compatible with any other targeting parameters.\n\
REQUIRED: REST API Key Authentication\nLimit of 2,000 entries per REST\
\ API call\nNote: If targeting push, email, or sms subscribers with same\
\ ids, use with target_channel to indicate you are sending a push or email\
\ or sms."
nullable: true
type: object
target_channel:
description: "Which platforms to count recipients for. Selects the same\
\ default platforms Create notification would use for the channel. Individual\
\ platform flags (`isIos`, `isAndroid`, etc.) are not supported by this\
\ endpoint."
enum:
- push
- email
- sms
type: string
type: object
CreateUserConflictResponse_errorsItems_meta:
properties:
conflicting_aliases:
Expand Down
2 changes: 1 addition & 1 deletion docs/BasicNotification.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**includedSegments** | **List<String>** | The segment names you want to target. Users in these segments will receive a notification. This targeting parameter is only compatible with excluded_segments. Example: [\"Active Users\", \"Inactive Users\"] | [optional] |
|**includedSegments** | **List<String>** | The segment names you want to target. Users in these segments will receive a notification. This targeting parameter is only compatible with excluded_segments. Example: [\"Active Users\", \"Inactive Users\"] `\"All\"` is a shorthand for every subscribed user: if the array includes the string `\"All\"` and the app has no segment actually named `All`, it targets all subscribers instead of a literal segment lookup. | [optional] |
|**excludedSegments** | **List<String>** | Segment that will be excluded when sending. Users in these segments will not receive a notification, even if they were included in included_segments. This targeting parameter is only compatible with included_segments. Example: [\"Active Users\", \"Inactive Users\"] | [optional] |
|**includeSubscriptionIds** | **List<String>** | Specific subscription ids to send your notification to. _Does not require API Auth Key._ Not compatible with any other targeting parameters. Example: [\"1dd608f2-c6a1-11e3-851d-000c2940e62c\"] Limit of 2,000 entries per REST API call | [optional] |
|**includeEmailTokens** | **List<String>** | Deprecated alias for `email_to`. Target specific email addresses. If an email does not correspond to an existing user, a new user will be created. Example: nick@catfac.ts. Limit of 2,000 entries per REST API call. Prefer `email_to` in new integrations. | [optional] |
Expand Down
74 changes: 74 additions & 0 deletions docs/DefaultApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ All URIs are relative to *https://api.onesignal.com*
| [**deleteSubscription**](DefaultApi.md#deleteSubscription) | **DELETE** /apps/{app_id}/subscriptions/{subscription_id} | |
| [**deleteTemplate**](DefaultApi.md#deleteTemplate) | **DELETE** /templates/{template_id} | Delete template |
| [**deleteUser**](DefaultApi.md#deleteUser) | **DELETE** /apps/{app_id}/users/by/{alias_label}/{alias_id} | |
| [**estimateNotificationRecipients**](DefaultApi.md#estimateNotificationRecipients) | **POST** /notifications/count-unsaved | Estimate notification recipients |
| [**exportEvents**](DefaultApi.md#exportEvents) | **POST** /notifications/{notification_id}/export_events | Export CSV of Events |
| [**exportSubscriptions**](DefaultApi.md#exportSubscriptions) | **POST** /players/csv_export?app_id={app_id} | Export CSV of Subscriptions |
| [**getAliases**](DefaultApi.md#getAliases) | **GET** /apps/{app_id}/users/by/{alias_label}/{alias_id}/identity | |
Expand Down Expand Up @@ -1729,6 +1730,79 @@ null (empty response body)
| **429** | Rate Limit Exceeded | - |
| **0** | Unexpected error | - |

<a name="estimateNotificationRecipients"></a>
# **estimateNotificationRecipients**
> EstimateNotificationRecipientsSuccessResponse estimateNotificationRecipients(estimateNotificationRecipientsRequest)

Estimate notification recipients

Returns the estimated number of recipients for a notification&#39;s targeting, without creating or sending anything. The returned &#x60;count&#x60; reflects the same audience-size estimate you would see under \&quot;Choose your target audience\&quot; when composing a message. It is based on the user targeting method you&#39;ve set and the specific platforms the message is targeted to send to. This endpoint only supports a subset of targeting parameters: &#x60;included_segments&#x60; is required (its &#x60;\&quot;All\&quot;&#x60; shorthand targets every subscriber), and &#x60;excluded_segments&#x60;, &#x60;filters&#x60;, &#x60;include_aliases&#x60;, and &#x60;target_channel&#x60; narrow that audience further. Use &#x60;target_channel&#x60; to select platforms. &#x60;include_subscription_ids&#x60; and the other raw subscription id/token fields, and the individual &#x60;isIos&#x60; / &#x60;isAndroid&#x60; / etc. platform flags, are not supported. All other notification fields (content, delivery options, and so on) are accepted, but ignored.

### Example
```java
// Import classes:
import com.onesignal.client.ApiClient;
import com.onesignal.client.ApiException;
import com.onesignal.client.Configuration;
import com.onesignal.client.auth.*;
import com.onesignal.client.model.*;
import com.onesignal.client.api.DefaultApi;

public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.onesignal.com");

// Configure HTTP bearer authorization: rest_api_key
HttpBearerAuth rest_api_key = (HttpBearerAuth) defaultClient.getAuthentication("rest_api_key");
rest_api_key.setBearerToken("YOUR_REST_API_KEY");

DefaultApi apiInstance = new DefaultApi(defaultClient);
EstimateNotificationRecipientsRequest estimateNotificationRecipientsRequest = new EstimateNotificationRecipientsRequest(); // EstimateNotificationRecipientsRequest |
try {
EstimateNotificationRecipientsSuccessResponse result = apiInstance.estimateNotificationRecipients(estimateNotificationRecipientsRequest);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling DefaultApi#estimateNotificationRecipients");
System.err.println("Status code: " + e.getCode());
// getErrorMessages() flattens any error-envelope shape to a List<String>;
// the raw body remains on getResponseBody().
System.err.println("Error messages: " + e.getErrorMessages());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
```

### Parameters

| Name | Type | Description | Notes |
|------------- | ------------- | ------------- | -------------|
| **estimateNotificationRecipientsRequest** | [**EstimateNotificationRecipientsRequest**](EstimateNotificationRecipientsRequest.md)| | |

### Return type

[**EstimateNotificationRecipientsSuccessResponse**](EstimateNotificationRecipientsSuccessResponse.md)

### Authorization

[rest_api_key](https://github.com/OneSignal/onesignal-java-api#configuration)

### HTTP request headers

- **Content-Type**: application/json
- **Accept**: application/json

### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | OK | - |
| **400** | Bad Request | - |
| **429** | Rate Limit Exceeded | - |
| **0** | Unexpected error | - |

<a name="exportEvents"></a>
# **exportEvents**
> ExportEventsSuccessResponse exportEvents(notificationId, appId)
Expand Down
29 changes: 29 additions & 0 deletions docs/EstimateNotificationRecipientsRequest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@


# EstimateNotificationRecipientsRequest

The targeting subset of notification fields this endpoint honors. `included_segments` (or its `\"All\"` shorthand) is required. `excluded_segments`, `filters`, `include_aliases`, and `target_channel` narrow that segment-based audience further when present. Use `target_channel` to select which platforms to count. Other notification targeting fields (`include_subscription_ids` and the other raw subscription id/token fields, and the individual `isIos` / `isAndroid` / etc. platform flags) are not read by this endpoint. All non-targeting notification fields (content, delivery options, and so on) are accepted, but ignored.

## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**includedSegments** | **List&lt;String&gt;** | The segment names you want to target. Users in these segments will receive a notification. This targeting parameter is only compatible with excluded_segments. Example: [\&quot;Active Users\&quot;, \&quot;Inactive Users\&quot;] &#x60;\&quot;All\&quot;&#x60; is a shorthand for every subscribed user: if the array includes the string &#x60;\&quot;All\&quot;&#x60; and the app has no segment actually named &#x60;All&#x60;, it targets all subscribers instead of a literal segment lookup. | [optional] |
|**excludedSegments** | **List&lt;String&gt;** | Segment that will be excluded when sending. Users in these segments will not receive a notification, even if they were included in included_segments. This targeting parameter is only compatible with included_segments. Example: [\&quot;Active Users\&quot;, \&quot;Inactive Users\&quot;] | [optional] |
|**appId** | **String** | The OneSignal App ID for your app, which can be found in Keys &amp; IDs. | |
|**filters** | [**List&lt;FilterExpression&gt;**](FilterExpression.md) | | [optional] |
|**includeAliases** | **Map&lt;String, List&lt;String&gt;&gt;** | Target specific users by aliases assigned via API. An alias can be an external_id, onesignal_id, or a custom alias. Accepts an object where keys are alias labels and values are arrays of alias IDs to include Example usage: { \&quot;external_id\&quot;: [\&quot;exId1\&quot;, \&quot;extId2\&quot;], \&quot;internal_label\&quot;: [\&quot;id1\&quot;, \&quot;id2\&quot;] } Keys must match API spellings exactly (for example the label for External ID is the string &#x60;external_id&#x60;; arbitrary keys such as camelCase variants are not aliases and may yield no recipients). Not compatible with any other targeting parameters. REQUIRED: REST API Key Authentication Limit of 2,000 entries per REST API call Note: If targeting push, email, or sms subscribers with same ids, use with target_channel to indicate you are sending a push or email or sms. | [optional] |
|**targetChannel** | [**TargetChannelEnum**](#TargetChannelEnum) | Which platforms to count recipients for. Selects the same default platforms Create notification would use for the channel. Individual platform flags (&#x60;isIos&#x60;, &#x60;isAndroid&#x60;, etc.) are not supported by this endpoint. | [optional] |



## Enum: TargetChannelEnum

| Name | Value |
|---- | -----|
| PUSH | &quot;push&quot; |
| EMAIL | &quot;email&quot; |
| SMS | &quot;sms&quot; |



26 changes: 26 additions & 0 deletions docs/EstimateNotificationRecipientsRequestAllOf.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@


# EstimateNotificationRecipientsRequestAllOf


## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**appId** | **String** | The OneSignal App ID for your app, which can be found in Keys &amp; IDs. | [optional] |
|**filters** | [**List&lt;FilterExpression&gt;**](FilterExpression.md) | | [optional] |
|**includeAliases** | **Map&lt;String, List&lt;String&gt;&gt;** | Target specific users by aliases assigned via API. An alias can be an external_id, onesignal_id, or a custom alias. Accepts an object where keys are alias labels and values are arrays of alias IDs to include Example usage: { \&quot;external_id\&quot;: [\&quot;exId1\&quot;, \&quot;extId2\&quot;], \&quot;internal_label\&quot;: [\&quot;id1\&quot;, \&quot;id2\&quot;] } Keys must match API spellings exactly (for example the label for External ID is the string &#x60;external_id&#x60;; arbitrary keys such as camelCase variants are not aliases and may yield no recipients). Not compatible with any other targeting parameters. REQUIRED: REST API Key Authentication Limit of 2,000 entries per REST API call Note: If targeting push, email, or sms subscribers with same ids, use with target_channel to indicate you are sending a push or email or sms. | [optional] |
|**targetChannel** | [**TargetChannelEnum**](#TargetChannelEnum) | Which platforms to count recipients for. Selects the same default platforms Create notification would use for the channel. Individual platform flags (&#x60;isIos&#x60;, &#x60;isAndroid&#x60;, etc.) are not supported by this endpoint. | [optional] |



## Enum: TargetChannelEnum

| Name | Value |
|---- | -----|
| PUSH | &quot;push&quot; |
| EMAIL | &quot;email&quot; |
| SMS | &quot;sms&quot; |



Loading