subscriptions_create
Import existing push subscriptions from another service into Pushpad by providing the endpoint and optional user ID, auth, p256dh key, and tags.
Instructions
To create a new subscription,
send a POST request to /projects/PROJECT_ID/subscriptions
setting the required attributes.
A subscription will be created using the provided information.
The response body will contain a JSON object with the attributes of your new subscription.
This operation is mainly intended to import subscriptions from another service into Pushpad.
This is not the standard way to collect subscriptions: usually you collect them using the JavaScript SDK.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| uid | No | A user identifier associated with the subscription. You can use it to find the push subscription of a user and then send notifications to that specific user. You can choose any ID that makes sense for your application, like the ID of the user in your database. | |
| auth | No | The auth property of the push subscription object, as described in the W3C Push API. It is an authentication secret that an application server uses in authentication of its messages. | |
| tags | No | Tags associated with the subscription. You can use them to filter the push subscriptions and send notifications to a segment of your audience. You can add all tags that make sense for your application. | |
| p256dh | No | The p256dh property of the push subscription object, as described in the W3C Push API. It is an elliptic curve Diffie-Hellman (ECDH) public key associated with the push subscription. | |
| endpoint | Yes | The push endpoint of a browser, as described in the W3C Push API. It is a URL where the application can deliver the push notifications that should be sent to the browser. An endpoint uniquely identifies the subscription. | |
| project_id__path | Yes | The ID of a project. (Path parameter) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | A unique identifier for each subscription. This is automatically generated upon subscription creation. | |
| uid | No | A user identifier associated with the subscription. You can use it to find the push subscription of a user and then send notifications to that specific user. You can choose any ID that makes sense for your application, like the ID of the user in your database. | |
| auth | No | The auth property of the push subscription object, as described in the W3C Push API. It is an authentication secret that an application server uses in authentication of its messages. | |
| tags | No | Tags associated with the subscription. You can use them to filter the push subscriptions and send notifications to a segment of your audience. You can add all tags that make sense for your application. | |
| p256dh | No | The p256dh property of the push subscription object, as described in the W3C Push API. It is an elliptic curve Diffie-Hellman (ECDH) public key associated with the push subscription. | |
| endpoint | No | The push endpoint of a browser, as described in the W3C Push API. It is a URL where the application can deliver the push notifications that should be sent to the browser. An endpoint uniquely identifies the subscription. | |
| created_at | No | A time value given in ISO 8601 format. It represents when the subscription was created. | |
| project_id | No | The ID of the project the subscription belongs to. | |
| last_click_at | No | A time value given in ISO 8601 format. It represents the last time that a notification sent to this subscription was clicked by the user. If there aren't any clicks on notifications yet, null is returned. |