beehiiv subpackage_newsletterListSubscriptions API

The subpackage_newsletterListSubscriptions API from beehiiv — 3 operation(s) for subpackage_newsletterlistsubscriptions.

OpenAPI Specification

beehiiv-subpackage-newsletterlistsubscriptions-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: API Reference subpackage_advertisement_opportunities subpackage_newsletterListSubscriptions API
  version: 1.0.0
servers:
- url: https://api.beehiiv.com/v2
tags:
- name: subpackage_newsletterListSubscriptions
paths:
  /publications/{publicationId}/newsletter_lists/{newsletterListId}/subscriptions:
    post:
      operationId: create
      summary: 'Create newsletter list subscription <Badge intent="warning" minimal outlined>Beta</Badge> <Badge intent="info" minimal outlined>OAuth Scope: newsletter_lists:write</Badge>'
      description: "<Note title=\"Currently in beta\" icon=\"b\">\n  Newsletter Lists is currently in beta, the API is subject to change.\n</Note>\nSubscribe a subscription to a newsletter list. Accepts either a subscription_id or email to identify the subscription."
      tags:
      - subpackage_newsletterListSubscriptions
      parameters:
      - name: publicationId
        in: path
        description: The prefixed ID of the publication object
        required: true
        schema:
          $ref: '#/components/schemas/type_ids:PublicationId'
      - name: newsletterListId
        in: path
        description: The prefixed ID of the newsletter list object
        required: true
        schema:
          $ref: '#/components/schemas/type_ids:NewsletterListId'
      - name: Authorization
        in: header
        description: Bearer authentication
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_newsletterListSubscriptions:NewsletterListSubscriptionResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_:Error'
        '404':
          description: Resource Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_:Error'
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_:Error'
        '429':
          description: Rate Limit Exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_:Error'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_:Error'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                subscription_id:
                  $ref: '#/components/schemas/type_ids:SubscriptionId'
                  description: The prefixed ID of the subscription to subscribe. Either subscription_id or email must be provided.
                email:
                  type: string
                  description: The email address of the subscription to subscribe. Either subscription_id or email must be provided.
    get:
      operationId: index
      summary: 'List newsletter list subscriptions <Badge intent="warning" minimal outlined>Beta</Badge> <Badge intent="info" minimal outlined>OAuth Scope: newsletter_lists:read</Badge>'
      description: "<Note title=\"Currently in beta\" icon=\"b\">\n  Newsletter Lists is currently in beta, the API is subject to change.\n</Note>\nList all subscriptions for a newsletter list."
      tags:
      - subpackage_newsletterListSubscriptions
      parameters:
      - name: publicationId
        in: path
        description: The prefixed ID of the publication object
        required: true
        schema:
          $ref: '#/components/schemas/type_ids:PublicationId'
      - name: newsletterListId
        in: path
        description: The prefixed ID of the newsletter list object
        required: true
        schema:
          $ref: '#/components/schemas/type_ids:NewsletterListId'
      - name: limit
        in: query
        description: A limit on the number of objects to be returned. The limit can range between 1 and 100, and the default is 10.
        required: false
        schema:
          type: integer
      - name: cursor
        in: query
        description: '**Cursor-based pagination (recommended)**: Use this opaque cursor token to fetch the next page of results. When provided, pagination will use cursor-based method which is more efficient and consistent than offset-based pagination.'
        required: false
        schema:
          type: string
      - name: page
        in: query
        description: '**Offset-based pagination (deprecated)**: Page number for offset-based pagination. Please migrate to cursor-based pagination using the `cursor` parameter. If not specified, results 1-10 from page 1 will be returned.'
        required: false
        schema:
          type: integer
      - name: direction
        in: query
        description: The direction that the results are sorted in. Defaults to asc<br> `asc` - Ascending, sorts from smallest to largest.<br> `desc` - Descending, sorts from largest to smallest.
        required: false
        schema:
          $ref: '#/components/schemas/type_:RequestDirection'
      - name: Authorization
        in: header
        description: Bearer authentication
        required: true
        schema:
          type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_newsletterListSubscriptions:NewsletterListSubscriptionIndexResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_:Error'
        '404':
          description: Resource Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_:Error'
        '429':
          description: Rate Limit Exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_:Error'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_:Error'
  /publications/{publicationId}/newsletter_lists/{newsletterListId}/subscriptions/{newsletterListSubscriptionId}:
    get:
      operationId: show
      summary: 'Get newsletter list subscription <Badge intent="warning" minimal outlined>Beta</Badge> <Badge intent="info" minimal outlined>OAuth Scope: newsletter_lists:read</Badge>'
      description: "<Note title=\"Currently in beta\" icon=\"b\">\n  Newsletter Lists is currently in beta, the API is subject to change.\n</Note>\nRetrieve a single newsletter list subscription."
      tags:
      - subpackage_newsletterListSubscriptions
      parameters:
      - name: publicationId
        in: path
        description: The prefixed ID of the publication object
        required: true
        schema:
          $ref: '#/components/schemas/type_ids:PublicationId'
      - name: newsletterListId
        in: path
        description: The prefixed ID of the newsletter list object
        required: true
        schema:
          $ref: '#/components/schemas/type_ids:NewsletterListId'
      - name: newsletterListSubscriptionId
        in: path
        description: The prefixed ID of the newsletter list subscription object
        required: true
        schema:
          $ref: '#/components/schemas/type_ids:NewsletterListSubscriptionId'
      - name: Authorization
        in: header
        description: Bearer authentication
        required: true
        schema:
          type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_newsletterListSubscriptions:NewsletterListSubscriptionResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_:Error'
        '404':
          description: Resource Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_:Error'
        '429':
          description: Rate Limit Exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_:Error'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_:Error'
    patch:
      operationId: update
      summary: 'Update newsletter list subscription <Badge intent="warning" minimal outlined>Beta</Badge> <Badge intent="info" minimal outlined>OAuth Scope: newsletter_lists:write</Badge>'
      description: "<Note title=\"Currently in beta\" icon=\"b\">\n  Newsletter Lists is currently in beta, the API is subject to change.\n</Note>\nUpdate a newsletter list subscription. Currently supports unsubscribing a subscription from a newsletter list."
      tags:
      - subpackage_newsletterListSubscriptions
      parameters:
      - name: publicationId
        in: path
        description: The prefixed ID of the publication object
        required: true
        schema:
          $ref: '#/components/schemas/type_ids:PublicationId'
      - name: newsletterListId
        in: path
        description: The prefixed ID of the newsletter list object
        required: true
        schema:
          $ref: '#/components/schemas/type_ids:NewsletterListId'
      - name: newsletterListSubscriptionId
        in: path
        description: The prefixed ID of the newsletter list subscription object
        required: true
        schema:
          $ref: '#/components/schemas/type_ids:NewsletterListSubscriptionId'
      - name: Authorization
        in: header
        description: Bearer authentication
        required: true
        schema:
          type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_newsletterListSubscriptions:NewsletterListSubscriptionResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_:Error'
        '404':
          description: Resource Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_:Error'
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_:Error'
        '429':
          description: Rate Limit Exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_:Error'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_:Error'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                unsubscribe:
                  type: boolean
                  description: Set to true to unsubscribe the subscription from this newsletter list.
  /publications/{publicationId}/newsletter_lists/{newsletterListId}/subscriptions/by_subscription_id/{subscriptionId}:
    patch:
      operationId: update-by-subscription-id
      summary: 'Update newsletter list subscription by subscription ID <Badge intent="warning" minimal outlined>Beta</Badge> <Badge intent="info" minimal outlined>OAuth Scope: newsletter_lists:write</Badge>'
      description: "<Note title=\"Currently in beta\" icon=\"b\">\n  Newsletter Lists is currently in beta, the API is subject to change.\n</Note>\nUpdate a newsletter list subscription by subscription ID. An alternative to the update endpoint when you don't have the newsletter list subscription ID. Accepts either a subscription_id or email to identify the subscription. Currently supports unsubscribing a subscription from a newsletter list."
      tags:
      - subpackage_newsletterListSubscriptions
      parameters:
      - name: publicationId
        in: path
        description: The prefixed ID of the publication object
        required: true
        schema:
          $ref: '#/components/schemas/type_ids:PublicationId'
      - name: newsletterListId
        in: path
        description: The prefixed ID of the newsletter list object
        required: true
        schema:
          $ref: '#/components/schemas/type_ids:NewsletterListId'
      - name: subscriptionId
        in: path
        description: The prefixed ID of the subscription
        required: true
        schema:
          $ref: '#/components/schemas/type_ids:SubscriptionId'
      - name: Authorization
        in: header
        description: Bearer authentication
        required: true
        schema:
          type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_newsletterListSubscriptions:NewsletterListSubscriptionResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_:Error'
        '404':
          description: Resource Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_:Error'
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_:Error'
        '429':
          description: Rate Limit Exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_:Error'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_:Error'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                unsubscribe:
                  type: boolean
                  description: Set to true to unsubscribe the subscription from this newsletter list.
components:
  schemas:
    type_:RequestDirection:
      type: string
      enum:
      - asc
      - desc
      default: asc
      description: The direction of the request. Defaults to `asc`.
      title: RequestDirection
    type_ids:NewsletterListSubscriptionId:
      type: string
      description: The prefixed ID of the newsletter list subscription.
      title: NewsletterListSubscriptionId
    type_ids:PublicationId:
      type: string
      description: The prefixed ID of the publication.
      title: PublicationId
    type_:Error:
      type: object
      properties:
        status:
          type: integer
        statusText:
          type: string
        errors:
          type: array
          items:
            $ref: '#/components/schemas/type_:ErrorDetail'
      required:
      - status
      - statusText
      - errors
      description: The top level error response.
      title: Error
    type_newsletterListSubscriptions:NewsletterListSubscriptionInfo:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/type_ids:NewsletterListSubscriptionId'
          description: The prefixed ID of the newsletter list subscription.
        newsletter_list_id:
          $ref: '#/components/schemas/type_ids:NewsletterListId'
          description: The prefixed ID of the newsletter list.
        subscription_id:
          $ref: '#/components/schemas/type_ids:SubscriptionId'
          description: The prefixed ID of the subscription.
        status:
          $ref: '#/components/schemas/type_newsletterListSubscriptions:NewsletterListSubscriptionStatus'
          description: The status of the newsletter list subscription.
        subscribed_at:
          type: integer
          description: The time the subscription was activated. Measured in seconds since the Unix epoch.
        unsubscribed_at:
          type: integer
          description: The time the subscription was deactivated. Measured in seconds since the Unix epoch.
        created_at:
          type: integer
          description: The time the newsletter list subscription was created. Measured in seconds since the Unix epoch.
      required:
      - id
      - newsletter_list_id
      - subscription_id
      - status
      - created_at
      title: NewsletterListSubscriptionInfo
    type_ids:NewsletterListId:
      type: string
      description: The prefixed ID of the newsletter list.
      title: NewsletterListId
    type_:ErrorDetail:
      type: object
      properties:
        message:
          type: string
        code:
          type: string
      required:
      - message
      - code
      title: ErrorDetail
    type_newsletterListSubscriptions:NewsletterListSubscriptionStatus:
      type: string
      enum:
      - pending
      - active
      - inactive
      - paused
      description: The status of the newsletter list subscription.
      title: NewsletterListSubscriptionStatus
    type_newsletterListSubscriptions:NewsletterListSubscriptionResponse:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/type_newsletterListSubscriptions:NewsletterListSubscriptionInfo'
      required:
      - data
      title: NewsletterListSubscriptionResponse
    type_ids:SubscriptionId:
      type: string
      description: The prefixed ID of the subscription.
      title: SubscriptionId
    type_newsletterListSubscriptions:NewsletterListSubscriptionIndexResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/type_newsletterListSubscriptions:NewsletterListSubscriptionInfo'
        limit:
          type: integer
          description: The limit placed on the results. If no limit was specified in the request, this defaults to 10.
        has_more:
          type: boolean
          description: '**Cursor pagination only**: Indicates whether there are more results available after the current page. Only present when using cursor-based pagination.'
        next_cursor:
          type: string
          description: '**Cursor pagination only**: The cursor token to use for fetching the next page of results. This will be null if has_more is false. Only present when using cursor-based pagination.'
        total_results:
          type: integer
          description: The total number of results from all pages.
      required:
      - data
      title: NewsletterListSubscriptionIndexResponse
  securitySchemes:
    BearerAuthScheme:
      type: http
      scheme: bearer