# Keep a browser's push subscription under your own id for the person

`POST /notify/push/subscriptions` · Rivier · campaigns

Keep a browser's push subscription under your own id for the person. Only the browsers' push services are accepted as endpoints.

- Scope: campaigns:write
- Mcp: rivier_notify_push_subscribe
- Graphql: Mutation.campaignsNotifyPushSubscribe
- Sdk: campaigns.notifyPush.subscribe
- Cli: campaigns notify push subscribe

## Request body

`application/json`

```json
{
  "type": "object",
  "properties": {
    "userRef": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200,
      "description": "Your own id for the person; Rivier keeps it as given and never shows it to anyone else"
    },
    "subscription": {
      "type": "object",
      "properties": {
        "endpoint": {
          "type": "string",
          "format": "uri",
          "maxLength": 1000
        },
        "keys": {
          "type": "object",
          "properties": {
            "p256dh": {
              "type": "string",
              "minLength": 80,
              "maxLength": 120
            },
            "auth": {
              "type": "string",
              "minLength": 16,
              "maxLength": 40
            }
          },
          "required": [
            "p256dh",
            "auth"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "endpoint",
        "keys"
      ],
      "additionalProperties": false,
      "description": "The PushSubscription a page got from pushManager.subscribe, as its toJSON() gives it"
    },
    "userAgent": {
      "type": "string",
      "maxLength": 300
    }
  },
  "required": [
    "userRef",
    "subscription"
  ],
  "additionalProperties": false
}
```

## Responses

- `201`: Success
- `400`: The request was malformed
- `401`: No valid credential
- `403`: The credential lacks the scope, origin or address
- `429`: Over the key's rate limit; see Retry-After

## Example

```sh
curl -X POST 'https://api.rivier.ai/notify/push/subscriptions' \
  -H 'Authorization: Bearer $KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "userRef": "string",
  "subscription": {
    "endpoint": "https://example.com",
    "keys": {
      "p256dh": "string",
      "auth": "string"
    }
  }
}'
```
