Skip to content

Latest commit

Β 

History

History
4124 lines (2930 loc) Β· 56.8 KB

reference.md

File metadata and controls

4124 lines (2930 loc) Β· 56.8 KB

Reference

Automation Journeys

client.automationJourneys.create(publicationId, automationId, { ...params }) -> Beehiiv.AutomationJourneysResponse

πŸ“ Description

Add an existing subscription to an automation flow. Requires the automation to have an active Add by API trigger. The specified email or subscription_id will be matched against your existing subscribers. If an existing subscriber is found, they will be enrolled immediately.

Looking to enroll new subscribers? Use the Create Subscription endpoint instead and specify the automation_ids param.

πŸ”Œ Usage

await client.automationJourneys.create(
    "pub_00000000-0000-0000-0000-000000000000",
    "aut_00000000-0000-0000-0000-000000000000",
    {
        email: "[email protected]",
        doubleOptOverride: "on",
    }
);

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

automationId: Beehiiv.AutomationId β€” The prefixed ID of the automation object

request: Beehiiv.AutomationJourneysCreateRequest

requestOptions: AutomationJourneys.RequestOptions

client.automationJourneys.index(publicationId, automationId) -> Beehiiv.AutomationJourneysIndexResponse

πŸ“ Description

Retrieve a list of automation journeys that have occurred within a specific automation.

πŸ”Œ Usage

await client.automationJourneys.index(
    "pub_00000000-0000-0000-0000-000000000000",
    "aut_00000000-0000-0000-0000-000000000000"
);

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

automationId: Beehiiv.AutomationId β€” The prefixed ID of the automation object

requestOptions: AutomationJourneys.RequestOptions

client.automationJourneys.show(publicationId, automationId, automationJourneyId) -> Beehiiv.AutomationJourneysResponse

πŸ“ Description

Retrieve a single automation journey by ID.

πŸ”Œ Usage

await client.automationJourneys.show(
    "pub_00000000-0000-0000-0000-000000000000",
    "aut_00000000-0000-0000-0000-000000000000",
    "aj_00000000-0000-0000-0000-000000000000"
);

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

automationId: Beehiiv.AutomationId β€” The prefixed ID of the automation object

automationJourneyId: Beehiiv.AutomationJourneyId β€” The prefixed automation journey id

requestOptions: AutomationJourneys.RequestOptions

Automations

client.automations.index(publicationId, { ...params }) -> Beehiiv.AutomationsListResponse

πŸ”Œ Usage

await client.automations.index("pub_00000000-0000-0000-0000-000000000000");

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

request: Beehiiv.AutomationsListRequest

requestOptions: Automations.RequestOptions

client.automations.show(publicationId, automationId) -> Beehiiv.AutomationsGetResponse

πŸ”Œ Usage

await client.automations.show("pub_00000000-0000-0000-0000-000000000000", "aut_00000000-0000-0000-0000-000000000000");

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

automationId: Beehiiv.AutomationId β€” The prefixed ID of the automation object

requestOptions: Automations.RequestOptions

Bulk Subscription Updates

client.bulkSubscriptionUpdates.index(publicationId) -> Beehiiv.BulkSubscriptionUpdatesListResponse

πŸ“ Description

Returns a list of Subscription Update objects for a publication.

πŸ”Œ Usage

await client.bulkSubscriptionUpdates.index("publicationId");

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

requestOptions: BulkSubscriptionUpdates.RequestOptions

client.bulkSubscriptionUpdates.show(publicationId, id) -> Beehiiv.BulkSubscriptionUpdatesGetResponse

πŸ“ Description

Returns a single Subscription Update object for a publication.

πŸ”Œ Usage

await client.bulkSubscriptionUpdates.show("publicationId", "id");

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

id: string β€” The ID of the Subscription Update object

requestOptions: BulkSubscriptionUpdates.RequestOptions

client.bulkSubscriptionUpdates.put(publicationId, { ...params }) -> Beehiiv.SubscriptionsPatchResponse

πŸ“ Description

Bulk update multiple subscriptions fields, including status, custom fields, and tiers.

πŸ”Œ Usage

await client.bulkSubscriptionUpdates.put("publicationId", {
    subscriptions: [
        {
            subscriptionId: "sub_1234-5678-9012-3456-7890",
            tier: "premium",
            stripeCustomerId: "cus_1234567890",
            unsubscribe: false,
            customFields: [
                {
                    name: "custom_field_name",
                    value: "custom_field_value",
                },
                {
                    name: "custom_field_name_2",
                    value: "custom_field_value_2",
                },
            ],
        },
        {
            subscriptionId: "sub_9876-5432-1098-7654-3210",
            tier: "free",
            stripeCustomerId: "cus_1234567890",
            unsubscribe: true,
            customFields: [
                {
                    name: "custom_field_name_3",
                    value: "custom_field_value_3",
                },
                {
                    name: "custom_field_name_4",
                    value: "custom_field_value_4",
                },
            ],
        },
    ],
});

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

request: Beehiiv.BulkSubscriptionsPutRequest

requestOptions: BulkSubscriptionUpdates.RequestOptions

client.bulkSubscriptionUpdates.patch(publicationId, { ...params }) -> Beehiiv.SubscriptionsPatchResponse

πŸ“ Description

Bulk update multiple subscriptions fields, including status, custom fields, and tiers.

πŸ”Œ Usage

await client.bulkSubscriptionUpdates.patch("publicationId", {
    subscriptions: [
        {
            subscriptionId: "sub_1234-5678-9012-3456-7890",
            tier: "premium",
            stripeCustomerId: "cus_1234567890",
            unsubscribe: false,
            customFields: [
                {
                    name: "custom_field_name",
                    value: "custom_field_value",
                },
                {
                    name: "custom_field_name_2",
                    value: "custom_field_value_2",
                },
            ],
        },
        {
            subscriptionId: "sub_9876-5432-1098-7654-3210",
            tier: "free",
            stripeCustomerId: "cus_1234567890",
            unsubscribe: true,
            customFields: [
                {
                    name: "custom_field_name_3",
                    value: "custom_field_value_3",
                },
                {
                    name: "custom_field_name_4",
                    value: "custom_field_value_4",
                },
            ],
        },
    ],
});

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

request: Beehiiv.BulkSubscriptionsPatchRequest

requestOptions: BulkSubscriptionUpdates.RequestOptions

client.bulkSubscriptionUpdates.putStatus(publicationId, { ...params }) -> void

πŸ“ Description

Bulk update subscriptions' status.

πŸ”Œ Usage

await client.bulkSubscriptionUpdates.putStatus("publicationId", {
    subscriptionIds: ["sub_1234-5678-9012-3456-7890", "sub_9876-5432-1098-7654-3210"],
    newStatus: "active",
});

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

request: Beehiiv.BulkSubscriptionsStatusPutRequest

requestOptions: BulkSubscriptionUpdates.RequestOptions

client.bulkSubscriptionUpdates.patchStatus(publicationId, { ...params }) -> void

πŸ“ Description

Bulk update subscriptions' status.

πŸ”Œ Usage

await client.bulkSubscriptionUpdates.patchStatus("publicationId", {
    subscriptionIds: ["sub_1234-5678-9012-3456-7890", "sub_9876-5432-1098-7654-3210"],
    newStatus: "active",
});

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

request: Beehiiv.BulkSubscriptionsStatusPatchRequest

requestOptions: BulkSubscriptionUpdates.RequestOptions

Custom Fields

client.customFields.create(publicationId, { ...params }) -> Beehiiv.CustomFieldResponse

πŸ“ Description

Create a custom field on a publication, for use in subscriptions

πŸ”Œ Usage

await client.customFields.create("publicationId", {
    kind: "string",
    display: "Display",
});

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

request: Beehiiv.CustomFieldsCreateRequest

requestOptions: CustomFields.RequestOptions

client.customFields.show(publicationId, id) -> Beehiiv.CustomFieldResponse

πŸ“ Description

View a specific custom field on a publication

πŸ”Œ Usage

await client.customFields.show("publicationId", "id");

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

id: string β€” The ID of the Custom Fields object

requestOptions: CustomFields.RequestOptions

client.customFields.index(publicationId) -> Beehiiv.CustomFieldIndexResponse

πŸ“ Description

List all custom fields on a publication

πŸ”Œ Usage

await client.customFields.index("publicationId");

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

requestOptions: CustomFields.RequestOptions

client.customFields.put(publicationId, id, { ...params }) -> Beehiiv.CustomFieldResponse

πŸ“ Description

Update a custom field on a publication

πŸ”Œ Usage

await client.customFields.put("publicationId", "id", {
    display: "New Display",
});

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

id: string β€” The ID of the Custom Fields object

request: Beehiiv.CustomFieldsPutRequest

requestOptions: CustomFields.RequestOptions

client.customFields.patch(publicationId, id, { ...params }) -> Beehiiv.CustomFieldsPatchResponse

πŸ“ Description

Update a custom field on a publication

πŸ”Œ Usage

await client.customFields.patch("publicationId", "id", {
    display: "New Display",
});

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

id: string β€” The ID of the Custom Fields object

request: Beehiiv.CustomFieldsPatchRequest

requestOptions: CustomFields.RequestOptions

client.customFields.delete(publicationId, id) -> Beehiiv.CustomFieldsDeleteResponse

πŸ“ Description

Delete a custom field from a publication

πŸ”Œ Usage

await client.customFields.delete("publicationId", "id");

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

id: string β€” The ID of the Custom Fields object

requestOptions: CustomFields.RequestOptions

Email Blasts

client.emailBlasts.index(publicationId, { ...params }) -> Beehiiv.EmailBlastsListResponse

πŸ“ Description

Retrieve all email blasts belonging to a specific publication

πŸ”Œ Usage

await client.emailBlasts.index("pub_00000000-0000-0000-0000-000000000000");

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

request: Beehiiv.EmailBlastsListRequest

requestOptions: EmailBlasts.RequestOptions

client.emailBlasts.show(publicationId, emailBlastId, { ...params }) -> Beehiiv.EmailBlastsGetResponse

πŸ“ Description

Retrieve a single email blast belonging to a specific publication

πŸ”Œ Usage

await client.emailBlasts.show("pub_00000000-0000-0000-0000-000000000000", "blast_00000000-0000-0000-0000-000000000000");

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

emailBlastId: Beehiiv.EmailBlastId β€” The prefixed ID of the email blast object

request: Beehiiv.EmailBlastsGetRequest

requestOptions: EmailBlasts.RequestOptions

Posts

client.posts.create(publicationId, { ...params }) -> Beehiiv.PostsCreateResponse

πŸ“ Description

This feature is currently in beta, the API is subject to change, and available only to Enterprise users.

To inquire about Enterprise pricing, please visit our Enterprise page. Create a post for a specific publication.

πŸ”Œ Usage

await client.posts.create("pub_00000000-0000-0000-0000-000000000000", {
    title: "The Kitchen Sink Post (refactored version)",
    subtitle: "Contains lots of examples of each block type and the various settings you could use",
    blocks: [
        {
            type: "heading",
            level: "2",
            textAlignment: "center",
            text: "This is my block!!!",
            anchorHeader: false,
            anchorIncludeInToc: false,
        },
        {
            type: "list",
            listType: "ordered",
            items: ["a", "b", "c"],
        },
        {
            type: "list",
            listType: "ordered",
            items: ["d", "e", "f"],
            startNumber: 4,
        },
        {
            type: "list",
            listType: "unordered",
            items: ["g", "h", "i"],
            startNumber: 4,
        },
        {
            type: "table",
            headerRow: true,
            headerColumn: true,
            rows: [
                [
                    {
                        text: "A",
                    },
                    {
                        text: "B",
                        alignment: "center",
                    },
                    {
                        text: "C",
                        alignment: "right",
                    },
                ],
                [
                    {
                        text: "D",
                        alignment: "right",
                    },
                    {
                        text: "E",
                        alignment: "center",
                    },
                    {
                        text: "F",
                        alignment: "left",
                    },
                ],
            ],
        },
        {
            type: "table",
            rows: [
                [
                    {
                        text: "A",
                    },
                    {
                        text: "B",
                    },
                    {
                        text: "C",
                    },
                ],
                [
                    {
                        text: "D",
                    },
                    {
                        text: "E",
                    },
                    {
                        text: "F",
                    },
                ],
            ],
        },
        {
            type: "table",
            headerRow: false,
            rows: [
                [
                    {
                        text: "A",
                    },
                    {
                        text: "B",
                    },
                    {
                        text: "C",
                    },
                ],
                [
                    {
                        text: "D",
                    },
                    {
                        text: "E",
                    },
                    {
                        text: "F",
                    },
                ],
            ],
        },
        {
            type: "columns",
            columns: [
                {
                    blocks: [
                        {
                            type: "paragraph",
                            plaintext: "Marble Column 1 {{email}}",
                        },
                    ],
                },
                {
                    blocks: [
                        {
                            type: "image",
                            imageUrl: "https://cdn.britannica.com/89/164789-050-D6B5E2C7/Barack-Obama-2012.jpg",
                            url: "https://www.whitehouse.gov/",
                            title: "Barry O",
                            altText: "A picture of Barry Obama",
                            caption: "One Cool President",
                            captionAlignment: "center",
                            imageAlignment: "right",
                            width: 75,
                        },
                    ],
                },
            ],
        },
        {
            type: "advertisement",
            opportunityId: "d8dfa6be-24b5-4cad-8350-ae44366dbd4c",
        },
        {
            type: "image",
            imageUrl: "https://cdn.britannica.com/89/164789-050-D6B5E2C7/Barack-Obama-2012.jpg",
            url: "https://www.whitehouse.gov/",
            title: "Barry O",
            altText: "A picture of Barry Obama",
            caption: "One Cool President",
            captionAlignment: "center",
            imageAlignment: "right",
            width: 75,
        },
        {
            type: "paragraph",
            formattedText: [
                {
                    text: "This is going to be ",
                },
                {
                    text: "a really, really awesome time ",
                    styling: ["bold"],
                },
                {
                    text: "Are you ready for this?",
                    styling: ["italic", "bold"],
                },
            ],
        },
        {
            type: "button",
            href: "/subscribe",
            target: "_blank",
            alignment: "center",
            size: "large",
            text: "Subscribe",
        },
        {
            type: "button",
            href: "/signup",
            target: "_blank",
            alignment: "right",
            size: "small",
            text: "Sign Up",
        },
        {
            type: "button",
            href: "/",
            target: "_blank",
            text: "View Posts",
        },
        {
            type: "heading",
            level: "4",
            textAlignment: "right",
            text: "This is my block!!!",
            anchorHeader: true,
            anchorIncludeInToc: true,
        },
    ],
    postTemplateId: "post_template_00000000-0000-0000-0000-000000000000",
    scheduledAt: "2024-12-25T12:00:00Z",
    customLinkTrackingEnabled: true,
    emailCaptureTypeOverride: "none",
    overrideScheduledAt: "2022-10-26T14:01:16Z",
    socialShare: "comments_and_likes_only",
    thumbnailImageUrl:
        "https://images.squarespace-cdn.com/content/v1/56e4ca0540261d39b90e4b18/1605047208324-PONGEYKEAKTMM1LANHJ5/1ED706BF-A70B-4F26-B3D5-266B449DDA8A_1_105_c.jpeg",
    emailSettings: {
        fromAddress: "from_address",
        customLiveUrl: "https://beehiiv.com",
        displayTitleInEmail: true,
        displayBylineInEmail: true,
        displaySubtitleInEmail: true,
        emailHeaderEngagementButtons: "email_header_engagement_buttons",
        emailHeaderSocialShare: "email_header_social_share",
        emailPreviewText: "email_preview_text",
        emailSubjectLine: "email_subject_line",
    },
    webSettings: {
        displayThumbnailOnWeb: true,
        hideFromFeed: true,
        slug: "and-this-is-gonna-rock",
    },
    seoSettings: {
        defaultDescription: "default_description",
        defaultTitle: "default_title",
        ogDescription: "OpenGraph description",
        ogTitle: "Opengraph Title",
        twitterDescription: "Twitter Stuff",
        twitterTitle: "My Twitter Article",
    },
    contentTags: ["Obama", "Care", "Rocks", "Healthcare"],
    recipients: {
        web: {
            tierIds: ["premium"],
        },
        email: {
            tierIds: ["premium", "free"],
            includeSegmentIds: ["seg_6426b403-39f5-42bd-86e9-9533fb0099e7"],
            excludeSegmentIds: ["seg_e34b4085-aef6-449f-a699-7563f915f852"],
        },
    },
});

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

request: Beehiiv.PostsCreateRequest

requestOptions: Posts.RequestOptions

client.posts.index(publicationId, { ...params }) -> Beehiiv.PostsListResponse

πŸ“ Description

Retrieve all posts belonging to a specific publication

πŸ”Œ Usage

await client.posts.index("pub_00000000-0000-0000-0000-000000000000");

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

request: Beehiiv.PostsListRequest

requestOptions: Posts.RequestOptions

client.posts.show(postId, publicationId, { ...params }) -> Beehiiv.PostsGetResponse

πŸ“ Description

Retreive a single Post belonging to a specific publication

πŸ”Œ Usage

await client.posts.show("post_00000000-0000-0000-0000-000000000000", "pub_00000000-0000-0000-0000-000000000000");

βš™οΈ Parameters

postId: Beehiiv.PostId β€” The prefixed ID of the post object

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

request: Beehiiv.PostsGetRequest

requestOptions: Posts.RequestOptions

client.posts.delete(postId, publicationId) -> Beehiiv.PostsDeleteResponse

πŸ“ Description

Delete or Archive a post. Any post that has been confirmed will have it's status changed to archived. Posts in the draft status will be permenantly deleted.

πŸ”Œ Usage

await client.posts.delete("post_00000000-0000-0000-0000-000000000000", "pub_00000000-0000-0000-0000-000000000000");

βš™οΈ Parameters

postId: Beehiiv.PostId β€” The prefixed ID of the post object

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

requestOptions: Posts.RequestOptions

Publications

client.publications.index({ ...params }) -> Beehiiv.PublicationsListResponse

πŸ“ Description

Retrieve all publications associated with your API key.

πŸ”Œ Usage

await client.publications.index();

βš™οΈ Parameters

request: Beehiiv.PublicationsListRequest

requestOptions: Publications.RequestOptions

client.publications.show(publicationId, { ...params }) -> Beehiiv.PublicationsGetResponse

πŸ“ Description

Retrieve a single publication

πŸ”Œ Usage

await client.publications.show("pub_ad76629e-4a39-43ad-8055-0ee89dc6db15");

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

request: Beehiiv.PublicationsGetRequest

requestOptions: Publications.RequestOptions

Referral Program

client.referralProgram.show(publicationId, { ...params }) -> Beehiiv.ReferralProgramGetResponse

πŸ“ Description

Retrieve details about the publication's referral program, including milestones and rewards.

πŸ”Œ Usage

await client.referralProgram.show("pub_00000000-0000-0000-0000-000000000000");

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

request: Beehiiv.ReferralProgramGetRequest

requestOptions: ReferralProgram.RequestOptions

Segments

client.segments.index(publicationId, { ...params }) -> Beehiiv.SegmentsListResponse

πŸ“ Description

Retrieve information about all segments belonging to a specific publication

πŸ”Œ Usage

await client.segments.index("pub_00000000-0000-0000-0000-000000000000");

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

request: Beehiiv.SegmentsListRequest

requestOptions: Segments.RequestOptions

client.segments.show(publicationId, segmentId, { ...params }) -> Beehiiv.SegmentShowResponse

πŸ“ Description

Retrieve information about a specific segment belonging to a publication

πŸ”Œ Usage

await client.segments.show("pub_00000000-0000-0000-0000-000000000000", "seg_00000000-0000-0000-0000-000000000000");

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

segmentId: Beehiiv.SegmentId β€” The prefixed ID of the segment object

request: Beehiiv.SegmentsShowRequest

requestOptions: Segments.RequestOptions

client.segments.expandResults(publicationId, segmentId, { ...params }) -> Beehiiv.SegmentsGetResponse

πŸ“ Description

List the Subscriber Ids from the most recent calculation of a specific publication.

πŸ”Œ Usage

await client.segments.expandResults(
    "pub_00000000-0000-0000-0000-000000000000",
    "seg_00000000-0000-0000-0000-000000000000"
);

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

segmentId: Beehiiv.SegmentId β€” The prefixed ID of the segment object

request: Beehiiv.SegmentsGetRequest

requestOptions: Segments.RequestOptions

client.segments.delete(publicationId, segmentId) -> Beehiiv.SegmentDeleteResponse

πŸ“ Description

Delete a segment. Deleting the segment does not effect the subscriptions in the segment.

πŸ”Œ Usage

await client.segments.delete("pub_00000000-0000-0000-0000-000000000000", "seg_00000000-0000-0000-0000-000000000000");

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

segmentId: Beehiiv.SegmentId β€” The prefixed ID of the segment object

requestOptions: Segments.RequestOptions

Subscriptions

client.subscriptions.create(publicationId, { ...params }) -> Beehiiv.SubscriptionResponse

πŸ“ Description

Create new subscriptions for a publication.

πŸ”Œ Usage

await client.subscriptions.create("pub_00000000-0000-0000-0000-000000000000", {
    email: "[email protected]",
    reactivateExisting: false,
    sendWelcomeEmail: false,
    utmSource: "WayneEnterprise",
    utmMedium: "organic",
    utmCampaign: "fall_2022_promotion",
    referringSite: "www.wayneenterprise.com/blog",
    customFields: [
        {
            name: "First Name",
            value: "Bruce",
        },
        {
            name: "Last Name",
            value: "Wayne",
        },
    ],
    stripeCustomerId: "stripe_customer_id",
});

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

request: Beehiiv.SubscriptionsCreateRequest

requestOptions: Subscriptions.RequestOptions

client.subscriptions.index(publicationId, { ...params }) -> Beehiiv.SubscriptionsListResponse

πŸ“ Description

Retrieve all subscriptions belonging to a specific publication

πŸ”Œ Usage

await client.subscriptions.index("pub_00000000-0000-0000-0000-000000000000", {
    email: "[email protected]",
});

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

request: Beehiiv.SubscriptionsListRequest

requestOptions: Subscriptions.RequestOptions

client.subscriptions.getByEmail(publicationId, email, { ...params }) -> Beehiiv.SubscriptionResponse

πŸ“ Description

Please note that this endpoint requires the email to be URL encoded. Please reference your language's documentation for the correct method of encoding. Retrieve a single subscription belonging to a specific email address in a specific publication.

πŸ”Œ Usage

await client.subscriptions.getByEmail("pub_00000000-0000-0000-0000-000000000000", "[email protected]");

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

email: string β€” The ID of the subscriber object

request: Beehiiv.SubscriptionsGetRequest

requestOptions: Subscriptions.RequestOptions

client.subscriptions.getById(publicationId, subscriptionId, { ...params }) -> Beehiiv.SubscriptionResponse

πŸ“ Description

In previous versions of the API, another endpoint existed to retrieve a subscription by the subscriber ID. This endpoint is now deprecated and will be removed in a future version of the API. Please use this endpoint instead. The subscription ID can be found by exporting a list of subscriptions either via the Settings > Publications > Export Data or by exporting a CSV in a segment. Retrieve a single subscription belonging to a specific publication.

πŸ”Œ Usage

await client.subscriptions.getById(
    "pub_00000000-0000-0000-0000-000000000000",
    "sub_00000000-0000-0000-0000-000000000000"
);

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

subscriptionId: Beehiiv.SubscriptionId β€” The prefixed ID of the subscription object

request: Beehiiv.SubscriptionsGetByIdRequest

requestOptions: Subscriptions.RequestOptions

client.subscriptions.getBySubscriberId(publicationId, subscriberId, { ...params }) -> Beehiiv.SubscriptionResponse

πŸ“ Description

Retrieve a single subscription belonging to a specific publication via the subscriber ID.

πŸ”Œ Usage

await client.subscriptions.getBySubscriberId(
    "pub_00000000-0000-0000-0000-000000000000",
    "00000000-0000-0000-0000-000000000000"
);

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

subscriberId: string β€” The ID of the subscriber object

request: Beehiiv.SubscriptionsGetBySubscriberIdRequest

requestOptions: Subscriptions.RequestOptions

client.subscriptions.getJwtToken(publicationId, subscriptionId) -> Beehiiv.SubscriptionJwtTokenResponse

πŸ“ Description

Generate a JWT token that can be used to automatically log in subscribers via URL. This token is short lived and should be used immediately.

πŸ”Œ Usage

await client.subscriptions.getJwtToken(
    "pub_00000000-0000-0000-0000-000000000000",
    "sub_00000000-0000-0000-0000-000000000000"
);

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

subscriptionId: Beehiiv.SubscriptionId β€” The prefixed ID of the subscription object

requestOptions: Subscriptions.RequestOptions

client.subscriptions.put(publicationId, subscriptionId, { ...params }) -> Beehiiv.SubscriptionResponse

πŸ“ Description

Update a single subscription.

πŸ”Œ Usage

await client.subscriptions.put("pub_00000000-0000-0000-0000-000000000000", "sub_00000000-0000-0000-0000-000000000000", {
    tier: "premium",
    stripeCustomerId: "cus_12345abcde",
    customFields: [
        {
            name: "First Name",
            value: "Bruce",
        },
        {
            name: "Last Name",
            value: "Wayne",
        },
    ],
});

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

subscriptionId: Beehiiv.SubscriptionId β€” The prefixed ID of the subscription object

request: Beehiiv.SubscriptionsUpdateRequest

requestOptions: Subscriptions.RequestOptions

client.subscriptions.patch(publicationId, subscriptionId, { ...params }) -> Beehiiv.SubscriptionResponse

πŸ“ Description

Update a single subscription.

πŸ”Œ Usage

await client.subscriptions.patch(
    "pub_00000000-0000-0000-0000-000000000000",
    "sub_00000000-0000-0000-0000-000000000000",
    {
        tier: "premium",
        stripeCustomerId: "cus_12345abcde",
        customFields: [
            {
                name: "First Name",
                value: "Bruce",
            },
            {
                name: "Last Name",
                value: "Wayne",
            },
        ],
    }
);

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

subscriptionId: Beehiiv.SubscriptionId β€” The prefixed ID of the subscription object

request: Beehiiv.SubscriptionsPatchSingleRequest

requestOptions: Subscriptions.RequestOptions

client.subscriptions.delete(subscriptionId, publicationId) -> Beehiiv.SubscriptionDeleteResponse

πŸ“ Description

This cannot be undone. All data associated with the subscription will also be deleted. We recommend unsubscribing when possible instead of deleting.

If a premium subscription is deleted they will no longer be billed. Deletes a subscription.

πŸ”Œ Usage

await client.subscriptions.delete(
    "sub_00000000-0000-0000-0000-000000000000",
    "pub_00000000-0000-0000-0000-000000000000"
);

βš™οΈ Parameters

subscriptionId: Beehiiv.SubscriptionId β€” The prefixed ID of the subscription object

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

requestOptions: Subscriptions.RequestOptions

Subscription Tags

client.subscriptionTags.create(publicationId, subscriptionId, { ...params }) -> Beehiiv.SubscriptionTagsCreateResponse

πŸ“ Description

Adds tags to a subscription. If the tag does not exist on the publication, it will be created automatically.

πŸ”Œ Usage

await client.subscriptionTags.create("publicationId", "subscriptionId");

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId

subscriptionId: Beehiiv.SubscriptionId

request: Beehiiv.SubscriptionTagsCreateRequest

requestOptions: SubscriptionTags.RequestOptions

Tiers

client.tiers.create(publicationId, { ...params }) -> Beehiiv.TierResponse

πŸ“ Description

Create a new tier for a publication.

πŸ”Œ Usage

await client.tiers.create("pub_00000000-0000-0000-0000-000000000000", {
    name: "Gold Tier",
    description: "Our premium tier with exclusive benefits",
    pricesAttributes: [
        {
            currency: "usd",
            amountCents: 500,
            enabled: true,
            interval: "month",
            intervalDisplay: "Monthly",
            cta: "Subscribe Now",
            features: ["Exclusive content", "Ad-free experience", "Priority support"],
        },
    ],
});

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

request: Beehiiv.PostPublicationsPublicationIdTiersRequest

requestOptions: Tiers.RequestOptions

client.tiers.index(publicationId, { ...params }) -> Beehiiv.IndexTiersResponse

πŸ“ Description

Retrieve all tiers belonging to a specific publication

πŸ”Œ Usage

await client.tiers.index("pub_00000000-0000-0000-0000-000000000000");

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

request: Beehiiv.GetPublicationsPublicationIdTiersRequest

requestOptions: Tiers.RequestOptions

client.tiers.show(publicationId, tierId, { ...params }) -> Beehiiv.TierResponse

πŸ“ Description

Retrieve a single tier belonging to a specific publication

πŸ”Œ Usage

await client.tiers.show("pub_00000000-0000-0000-0000-000000000000", "tier_00000000-0000-0000-0000-000000000000");

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

tierId: Beehiiv.TierId β€” The prefixed ID of the tier object

request: Beehiiv.GetPublicationsPublicationIdTiersTierIdRequest

requestOptions: Tiers.RequestOptions

client.tiers.put(publicationId, tierId, { ...params }) -> Beehiiv.TierResponse

πŸ“ Description

Update an existing tier belonging to a specific publication

πŸ”Œ Usage

await client.tiers.put("pub_00000000-0000-0000-0000-000000000000", "tier_00000000-0000-0000-0000-000000000000", {
    name: "Gold",
    description: "Our premium tier with exclusive benefits",
    pricesAttributes: [
        {
            id: "price_00000000-0000-0000-0000-000000000000",
            currency: "usd",
            amountCents: 500,
            interval: "month",
            intervalDisplay: "Monthly",
            cta: "Subscribe Now",
            features: ["Exclusive content"],
            delete: true,
        },
    ],
});

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

tierId: Beehiiv.TierId β€” The prefixed ID of the tier object

request: Beehiiv.UpdatePutTierRequest

requestOptions: Tiers.RequestOptions

client.tiers.patch(publicationId, tierId, { ...params }) -> Beehiiv.TierResponse

πŸ“ Description

Update an existing tier belonging to a specific publication

πŸ”Œ Usage

await client.tiers.patch("pub_00000000-0000-0000-0000-000000000000", "tier_00000000-0000-0000-0000-000000000000", {
    name: "Gold",
    description: "Our premium tier with exclusive benefits",
    pricesAttributes: [
        {
            id: "price_00000000-0000-0000-0000-000000000000",
            currency: "usd",
            amountCents: 500,
            interval: "month",
            intervalDisplay: "Monthly",
            cta: "Subscribe Now",
            features: ["Exclusive content"],
            delete: true,
        },
    ],
});

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

tierId: Beehiiv.TierId β€” The prefixed ID of the tier object

request: Beehiiv.UpdatePatchTierRequest

requestOptions: Tiers.RequestOptions

Webhooks

client.webhooks.create(publicationId, { ...params }) -> Beehiiv.WebhookResponse

πŸ“ Description

Create a new webhook for a given publication.

πŸ”Œ Usage

await client.webhooks.create("pub_00000000-0000-0000-0000-000000000000", {
    url: "https://example.com/webhook",
    eventTypes: ["post.sent"],
});

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

request: Beehiiv.PostWebhooksRequest

requestOptions: Webhooks.RequestOptions

client.webhooks.index(publicationId, { ...params }) -> Beehiiv.IndexWebhooksResponse

πŸ“ Description

Retrieve all webhooks belonging to a specific publication.

πŸ”Œ Usage

await client.webhooks.index("pub_00000000-0000-0000-0000-000000000000");

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

request: Beehiiv.GetWebhooksRequest

requestOptions: Webhooks.RequestOptions

client.webhooks.show(publicationId, endpointId) -> Beehiiv.WebhookResponse

πŸ“ Description

Retrieve a specific webhook belonging to a publication.

πŸ”Œ Usage

await client.webhooks.show("pub_00000000-0000-0000-0000-000000000000", "ep_0000000000000000000000000000");

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

endpointId: Beehiiv.EndpointId β€” The prefixed ID of the webhook object

requestOptions: Webhooks.RequestOptions

client.webhooks.delete(publicationId, endpointId) -> Beehiiv.WebhooksDeleteResponse

πŸ“ Description

Delete a webhook subscription from a publication.

πŸ”Œ Usage

await client.webhooks.delete("pub_00000000-0000-0000-0000-000000000000", "ep_0000000000000000000000000000");

βš™οΈ Parameters

publicationId: Beehiiv.PublicationId β€” The prefixed ID of the publication object

endpointId: Beehiiv.EndpointId β€” The prefixed ID of the webhook object

requestOptions: Webhooks.RequestOptions

client.webhooks.test(publicationId, endpointId) -> Beehiiv.GetPublicationsPublicationIdWebhooksWebhookIdTestsResponse

πŸ“ Description

Send test info to an already set up webhook endpoint.

πŸ”Œ Usage

await client.webhooks.test("pub_00000000-0000-0000-0000-000000000000", "ep_0000000000000000000000000000");

βš™οΈ Parameters

publicationId: string β€” The prefixed ID of the publication object

endpointId: Beehiiv.EndpointId β€” The prefixed ID of the webhook object

requestOptions: Webhooks.RequestOptions