> ## Documentation Index
> Fetch the complete documentation index at: https://docs.salesive.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create/update subscription

> Create or update a push subscription.

## Request

```http theme={null}
POST /push-subscriptions
Authorization: Bearer {{token}}
x-shop-id: {{shopId}}
Content-Type: application/json

{
  "subscription": {
    "endpoint": "https://fcm.googleapis.com/fcm/send/abc123",
    "expirationTime": null,
    "keys": {
      "p256dh": "BNPx...example...key",
      "auth": "abc123auth"
    }
  },
  "label": "Chrome Desktop"
}
```

## Headers

| Header          | Type   | Description                                   |
| --------------- | ------ | --------------------------------------------- |
| `Authorization` | string | Provide the customer token as `Bearer <jwt>`. |
| `x-shop-id`     | string | Identify the shop.                            |
| `Content-Type`  | string | Always set to `application/json`.             |

## Body parameters

| Field                         | Type         | Required | Description                            |
| ----------------------------- | ------------ | -------- | -------------------------------------- |
| `subscription`                | object       | Yes      | Push subscription object from browser. |
| `subscription.endpoint`       | string       | Yes      | Push service endpoint URL.             |
| `subscription.expirationTime` | integer/null | No       | Subscription expiration time.          |
| `subscription.keys`           | object       | Yes      | Encryption keys object.                |
| `subscription.keys.p256dh`    | string       | Yes      | P-256 public key.                      |
| `subscription.keys.auth`      | string       | Yes      | Authentication secret.                 |
| `label`                       | string       | No       | Device label (e.g., "Chrome Desktop"). |

## Successful response

```json theme={null}
{
    "status": 201,
    "success": true,
    "message": "Subscription created successfully",
    "data": {
        "_id": "678bd8f2e37452d19efcb4ea",
        "user": "69360693a7a8f7dc8ae32d6d",
        "shop": "68b8f52575da81b332af29f1",
        "endpoint": "https://fcm.googleapis.com/fcm/send/abc123",
        "keys": {
            "p256dh": "BNPx...example...key",
            "auth": "abc123auth"
        },
        "label": "Chrome Desktop",
        "createdAt": "2025-01-18T12:35:00.000Z"
    }
}
```

## Error response

```json theme={null}
{
    "status": 400,
    "success": false,
    "message": "Subscription object is required",
    "data": {}
}
```


## OpenAPI

````yaml POST /push-subscriptions
openapi: 3.1.0
info:
  title: Salesive Store API
  description: >-
    REST interface for querying products, categories, and merchandising banners
    exposed by Salesive storefronts.
  version: 1.0.0
servers:
  - description: Production
    url: https://store.salesive.com/api/v1
security:
  - BearerAuth: []
    ShopIdHeader: []
paths:
  /push-subscriptions:
    post:
      summary: Create/update subscription
      description: Create or update a push subscription.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                endpoint:
                  type: string
                keys:
                  type: object
      responses:
        '201':
          description: Subscription created
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: JWT issued by the Salesive Store API for authenticated shoppers.
    ShopIdHeader:
      type: apiKey
      in: header
      name: x-shop-id
      description: >-
        Optional storefront identifier sent as a header to scope responses to a
        specific shop. Try It requests remember this value once provided.

````