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

# Unsubscribe from the newsletter

> Destroys the newsletter subscription, firing the `newsletter_subscriber.deleted`
lifecycle event. Two authorization paths are accepted:

- **Unsubscribe token** in the `?token=` query param — bearer delivered to the
  subscriber by email (the link in an unsubscribe message). The token is
  cryptographically signed and is cross-checked against the `:id` in the URL —
  tampering with either is rejected. To request such an email be sent, call the
  collection action `POST /newsletter_subscribers/request_unsubscribe` with the
  subscriber's email in the body.
- **JWT bearer** for the logged-in customer who owns the subscription. No `token`
  query param is needed in this path.

All failure modes return a generic `invalid_token` 422.




## OpenAPI

````yaml /api-reference/store.yaml delete /api/v3/store/newsletter_subscribers/{id}
openapi: 3.0.3
info:
  title: Store API
  contact:
    name: Spree Commerce
    url: https://spreecommerce.org
    email: hello@spreecommerce.org
  description: >
    Spree Store API v3 - Customer-facing storefront API for building headless
    commerce experiences.


    ## Authentication


    The Store API uses two authentication methods:


    ### API Key (Required)

    All requests must include a publishable API key in the `x-spree-api-key`
    header.


    ### JWT Bearer Token (For authenticated customers)

    After login, include the JWT token in the `Authorization: Bearer <token>`
    header.


    ### Order Token (For guest checkout)

    When creating an order, a `token` is returned. Include this in the
    `x-spree-token` header

    for guest access to that specific order.


    ## Response Format


    All responses are JSON. List endpoints return paginated responses with
    `data` and `meta` keys.


    ## Error Handling


    Errors return a consistent format:

    ```json

    {
      "error": {
        "code": "record_not_found",
        "message": "Product not found"
      }
    }

    ```
  version: v3
servers:
  - url: http://{defaultHost}
    variables:
      defaultHost:
        default: localhost:3000
security: []
tags:
  - name: Authentication
    description: Customer authentication (login, logout, token refresh)
  - name: Product Catalog
    description: Products and categories
  - name: Carts
    description: Shopping cart management
  - name: Orders
    description: Order lookup
  - name: Customers
    description: Customer account, addresses, saved payment methods, and order history
  - name: Markets
    description: Markets, countries, currencies, and locales
  - name: Wishlists
    description: Customer wishlists
  - name: Newsletter Subscribers
    description: Guest and customer newsletter subscriptions (double opt-in)
  - name: Policies
    description: Store policies (return policy, privacy policy, terms of service)
  - name: Digitals
    description: Digital product downloads
paths:
  /api/v3/store/newsletter_subscribers/{id}:
    parameters:
      - name: id
        in: path
        description: Newsletter subscriber prefix id (sub_*)
        required: true
        schema:
          type: string
    delete:
      tags:
        - Newsletter Subscribers
      summary: Unsubscribe from the newsletter
      description: >
        Destroys the newsletter subscription, firing the
        `newsletter_subscriber.deleted`

        lifecycle event. Two authorization paths are accepted:


        - **Unsubscribe token** in the `?token=` query param — bearer delivered
        to the
          subscriber by email (the link in an unsubscribe message). The token is
          cryptographically signed and is cross-checked against the `:id` in the URL —
          tampering with either is rejected. To request such an email be sent, call the
          collection action `POST /newsletter_subscribers/request_unsubscribe` with the
          subscriber's email in the body.
        - **JWT bearer** for the logged-in customer who owns the subscription.
        No `token`
          query param is needed in this path.

        All failure modes return a generic `invalid_token` 422.
      parameters:
        - name: x-spree-api-key
          in: header
          required: true
          schema:
            type: string
        - name: Authorization
          in: header
          required: false
          description: Optional Bearer JWT — alternative to the `token` query param
          schema:
            type: string
        - name: token
          in: query
          required: false
          description: >-
            Unsubscribe token delivered to the subscriber by email (e.g. the
            link in an unsubscribe message).
          schema:
            type: string
      responses:
        '204':
          description: unsubscribed via JWT (owner)
        '422':
          description: JWT-authenticated, subscriber on a different store
          content:
            application/json:
              example:
                error:
                  code: invalid_token
                  message: Newsletter unsubscribe token is invalid or has expired.
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - api_key: []
components:
  schemas:
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: record_not_found
            message:
              type: string
              example: Record not found
            details:
              type: object
              description: Field-specific validation errors
              nullable: true
              example:
                name:
                  - is too short
                  - is required
                email:
                  - is invalid
          required:
            - code
            - message
      required:
        - error
      example:
        error:
          code: validation_error
          message: Validation failed
          details:
            name:
              - is too short
            email:
              - is invalid
  securitySchemes:
    api_key:
      type: apiKey
      name: x-spree-api-key
      in: header
      description: Publishable API key for store access

````