openapi: 3.2.0 info: title: Reference Newsletter List Subscriptions API version: 1.0.0 servers: - url: https://api.beehiiv.com/v2 description: Default tags: - name: Newsletter List Subscriptions paths: /publications/{publicationId}/newsletter_lists/{newsletterListId}/subscriptions: post: operationId: create summary: 'Create newsletter list subscription OAuth Scope: newsletter_lists:write' description: 'Subscribe a subscription to a newsletter list. Accepts either a subscription_id or email to identify the subscription. This endpoint only enrolls **existing** subscriptions. To create a new subscription **and** enroll it in one or more newsletter lists in a single call, use the [Create subscription](/api-reference/subscriptions/create) endpoint and pass the `newsletter_list_ids` parameter. ' tags: - Newsletter List Subscriptions 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' '401': description: Unauthorized. The API key or OAuth access token is missing, invalid, or expired. 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 OAuth Scope: newsletter_lists:read' description: List all subscriptions for a newsletter list. tags: - Newsletter List Subscriptions 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
`asc` - Ascending, sorts from smallest to largest.
`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' '401': description: Unauthorized. The API key or OAuth access token is missing, invalid, or expired. 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 OAuth Scope: newsletter_lists:read' description: Retrieve a single newsletter list subscription. tags: - Newsletter List Subscriptions 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' '401': description: Unauthorized. The API key or OAuth access token is missing, invalid, or expired. 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 OAuth Scope: newsletter_lists:write' description: Update a newsletter list subscription. Currently supports unsubscribing a subscription from a newsletter list. tags: - Newsletter List Subscriptions 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' '401': description: Unauthorized. The API key or OAuth access token is missing, invalid, or expired. 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 OAuth Scope: newsletter_lists:write' description: Update 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: - Newsletter List Subscriptions 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' '401': description: Unauthorized. The API key or OAuth access token is missing, invalid, or expired. 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_newsletterListSubscriptions_NewsletterListSubscriptionResponse: type: object properties: data: $ref: '#/components/schemas/type_newsletterListSubscriptions_NewsletterListSubscriptionInfo' required: - data title: NewsletterListSubscriptionResponse 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 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__RequestDirection: type: string enum: - asc - desc default: asc description: The direction of the request. Defaults to `asc`. title: RequestDirection type_ids_NewsletterListId: type: string description: The prefixed ID of the newsletter list. title: NewsletterListId type_ids_NewsletterListSubscriptionId: type: string description: The prefixed ID of the newsletter list subscription. title: NewsletterListSubscriptionId type_ids_SubscriptionId: type: string description: The prefixed ID of the subscription. title: SubscriptionId type__ErrorDetail: type: object properties: message: type: string code: type: string required: - message - code title: ErrorDetail 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_newsletterListSubscriptions_NewsletterListSubscriptionStatus: type: string enum: - pending - active - inactive - paused description: The status of the newsletter list subscription. title: NewsletterListSubscriptionStatus securitySchemes: BearerAuthScheme: type: http scheme: bearer