import { Col, DangerNote, Note, Properties, Row, WarningNote } from '../../../components/mdx'
import { Tag } from '../../../components/Tag'
import { LiquidFilters } from '../../../components/snippets/LiquidFilters'
import { HeroPattern } from '../../../components/HeroPattern'
import { TimelineContainer } from '../../../components/TimelineContainer'
import { TimelineHeader } from '../../../components/TimelineHeader'
import { TimelineBody } from '../../../components/TimelineBody'
import { Card, CardContent, CardFooter, CardHeader, CardTitle } from '../../../components/ui/card'
import { ShirtIcon } from '../../../components/icons/ShirtIcon'
import { UpBubbleIcon } from '../../../components/icons/UpBubbleIcon'
import { ThumbUpIcon } from '../../../components/icons/ThumbUpIcon'
import { EmailBubbleIcon } from '../../../components/icons/EmailBubbleIcon'
import { BentoCoinIcon } from '../../../components/icons/BentoCoinIcon'
import { NoCodeIcon } from '../../../components/icons/NoCodeIcon'
import { DevGuideIcon } from '../../../components/icons/DevGuideIcon'
import { SectionTitle } from '../../../components/SectionTitle'
import ClipboardButton from '../../../components/ui/ClipboardButton'
import { Code } from '../../../components/Code'
import {
  Breadcrumb,
  BreadcrumbItem,
  BreadcrumbList,
  BreadcrumbPage,
  BreadcrumbSeparator
} from '../../../components/ui/breadcrumb'
import { Collapsable } from '../../../components/MDXCollapsible'
import CodeSample from '../../../components/CodeSample'
import { ArrowIcon } from '../../../components/icons/ArrowIcon'
import Link from 'next/link'
import { GuideLinkCards } from '../../../components/GuideLinks'

export const exampleFile = 'node-guide-examples'
export const metadata = {
  title: 'Nodejs SDK Guide',
  description:
    "Today, we'll explore integrating the node SDK from Bento.",
}




# Bento Nodejs Guide

This guide will help you implement Bento into your Node.js applications, regardless of your development experience.

<div className="grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-2">
  <GuideLinkCards
    icon={UpBubbleIcon}
    title="Getting Started"
    links={[
      { label: 'Installation', href: '#installation' },
      { label: 'Basic Setup', href: '#basic-setup' },
    ]}
  />
  <GuideLinkCards
    icon={ThumbUpIcon}
    title="Beginner Guide"
    links={[
      { label: 'Tracking Your First Event', href: '#tracking-your-first-event' },
      { label: 'Managing Subscribers', href: '#managing-subscribers' },
      { label: 'Common Use Cases', href: '#common-use-cases' },
    ]}
  />
  <GuideLinkCards
    icon={EmailBubbleIcon}
    title="Intermediate Guide"
    links={[
      { label: 'Custom Fields and Tags', href: '#custom-fields-and-tags' },
      { label: 'Tracking Purchase Events', href: '#tracking-purchase-events' },
      { label: 'Namespaced Tags', href: '#namespaced-tags' },
    ]}
  />
  <GuideLinkCards
    icon={BentoCoinIcon}
    title="Advanced Guide"
    links={[
      { label: 'Batch Operations', href: '#batch-operations' },
      { label: 'Transactional Emails', href: '#transactional-emails' },
      { label: 'Subscriber Updates', href: '#subscriber-updates' },
      { label: 'Utility Features', href: '#utility-features' },
    ]}
  />
</div>

### Reference
<div className={'flex flex-col gap-y-1 mb-8'}>
  <div><span className={'text-xl text-violet-500'}>#</span> [API Reference](#api-reference)</div>
  <div><span className={'text-xl text-violet-500'}>#</span> [Troubleshooting](#troubleshooting)</div>
  <div><span className={'text-xl text-violet-500'}>#</span> [FAQ](#faq)</div>
</div>

<SectionTitle title={'Getting Started'}/>

<div className={'ml-4'}>
<TimelineContainer>
<TimelineHeader title={'Package Installation'} number={'1'}/>
<TimelineBody>
  ## Installation

  Install the Bento Node SDK in your project:

<CodeSample exampleFile={exampleFile} exampleKey="install_npm"  />
<CodeSample exampleFile={exampleFile} exampleKey="install_yarn"  />
<CodeSample exampleFile={exampleFile} exampleKey="install_bun"  />

</TimelineBody>

<TimelineHeader title={'Client Configuration'} number={'2'}/>
  <TimelineBody>
    ## Basic Setup

    To initialize the Bento client, you'll need your Site UUID, Publishable Key, and Secret Key from your Bento account.
    You can find your keys in your [Bento Team](https://app.bentonow.com/account/teams). To see your keys click
    `Your Private API Keys` Button and if do you do not see a Publishable key and Secret Key, click on `Generate Key` to
    create a set.

    <CodeSample exampleFile={exampleFile} exampleKey="basic_setup"  />
  </TimelineBody>
</TimelineContainer>
</div>

<SectionTitle title={'Beginner Guide'}/>

## Tracking Your First Event

Events represent specific actions users take within your application. Tracking these actions provides valuable insights
into user behavior patterns and engagement.

#### Streamlined Subscriber Management
We recommend using Events as the preferred method to add subscribers, as they simultaneously initiate workflows and
automations in a single operation.

#### Powerful Data Enrichment
Events excel at capturing contextual information alongside user actions. This can be used in emails via
[liquid tags](/liquid_guide) or in segmentation. For instance, when recording a purchase event, you can include detailed
transaction information such as:

| Detail                                                   | Liquid tag                                                                                                                                         |
|----------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|
| <span className="text-violet-400">Product details</span> | <ClipboardButton isColored={true} textToCopy='{{ event.details.product.size }}' defaultLabel="{{ event.details.product.size }}" />                 |
| <span className="text-violet-400">Purchase amount</span> | <ClipboardButton isColored={true} textToCopy='{{ event.details.value.amount }}' defaultLabel="{{ event.details.value.amount }}" />                 |
| <span className="text-violet-400">Transaction ID</span>  | <ClipboardButton isColored={true} textToCopy='{{ event.details.value.amount }}' defaultLabel="{{ event.details.value.amount }}" />                 |
| <span className="text-violet-400">Payment method</span>  | <ClipboardButton isColored={true} textToCopy='{{ event.details.value.payment_method }}' defaultLabel="{{ event.details.value.payment_method }}" /> |

### Practical Example
When a customer completes a purchase, you can track this as an event while including all relevant purchase details. This
approach enables you to:

- Trigger specific post-purchase workflows
- Launch targeted follow-up automations
- Track lifetime value (LTV) metrics
- Create personalized communications based on purchase history


<CodeSample exampleFile={exampleFile} exampleKey="simple_page_view"  />

<CodeSample exampleFile={exampleFile} exampleKey="track_form_submission"  />

## Managing Subscribers

If you need to manage subscribers directly there are a set of convenience methods available to you. Add, update, and
unsubscribe subscribers with these simple methods. Currently, you cannot remove subscribers via the API, but you can
remove them from the dashboard `People > All Users`.

<Collapsable defaultOpen={false} openLabel="2 More Samples">
  <summary>
    <CodeSample exampleFile={exampleFile} exampleKey="create_a_new_subscriber"  />
  </summary>
  <content>

    <CodeSample exampleFile={exampleFile} exampleKey="tag_a_subscriber"  />
    <CodeSample exampleFile={exampleFile} exampleKey="unsubscribe_a_subscriber"  />
  </content>
</Collapsable>



#### Adding Individual Subscribers
Please note, while these methods make it easy to manage a subscriber, the Bento recommended way to add **a** subscriber
is via an `event`. This allows you to kick off sequences and automations, while also recording the "event" at the same
time (1 API call).

#### Adding Multiple Subscribers
Importing or modifying multiple subscribers should be handled via the [bulk methods](/examples/nodejs#subscriber-updates),
instead of looping over these calls multiple times.


## Common Use Cases

Here are some common scenarios with ready-to-use code:
<Collapsable defaultOpen={false} openLabel="2 More Samples">
  <summary>
    <CodeSample exampleFile={exampleFile} exampleKey="tracking_user_login_event"  />
  </summary>
  <content>
    <CodeSample exampleFile={exampleFile} exampleKey="updaing_user_information"  />
    <CodeSample exampleFile={exampleFile} exampleKey="adding_multiple_tags_to_a_subscriber"  />
  </content>
  </Collapsable>

<SectionTitle title={'Intermediate Guide'}/>

## Custom Fields and Tags

Bento allows you to store custom data about your users through fields and segment them with tags:
<Collapsable defaultOpen={false} openLabel="3 More Samples">
  <summary>
    <CodeSample exampleFile={exampleFile} exampleKey="create_a_new_custom_field_definition"  />
  </summary>
  <content>
    <CodeSample exampleFile={exampleFile} exampleKey="get_all_fields"  />
    <CodeSample exampleFile={exampleFile} exampleKey="create_a_new_tag"  />
    <CodeSample exampleFile={exampleFile} exampleKey="get_all_tags"  />
</content>
</Collapsable>

## Using Custom Fields & Tags
While custom fields and tags can be used to segment subscribers, most Bento users find that namespaced tags provide a more
effective and easier-to-maintain solution for most segmentation use cases.

#### Namespaced Tags
Namespaced tags follow this format: `namespace`:`detail`
For example, if you offer three subscription plans, you could create these tags:
* `subscription:basic`
* `subscription:pro`
* `subscription:enterprise`

We recommend applying these tags either through an automated flow or via bulk updates.

<Note>Tags do not need to be namespaced, but for many customers the organization pays off by using namespaced tags when
it makes sense.</Note>

#### Fields
Fields are perfect for storing information about your subscribers, such as their language, timezone,
or other relevant details. By using fields, you can easily segment subscribers based on their specific needs and
preferences, allowing you to tailor your marketing efforts and messaging to each group.

The primary difference between
fields and namespaced tags is that fields are not limited to a specific detail and do not need to be predefined. You can
store any type of data in a field, including strings, numbers, or even objects. This flexibility makes fields a powerful
tool for storing data.

#### Best Practices
For optimal organization, consider using tags for segmentation while storing more detailed user information in custom
fields. Many successful implementations use a strategic combination of both approaches.


## Tracking Purchase Events

When recording purchase events, you must include a `unique:` key as part of the tracking data. This requirement prevents
duplicate transactions from being recorded in your analytics.

Most users find it beneficial to use their internal cart or order number as the `unique:` key. This approach simplifies
future lookups and maintains consistency across your systems. The `unique:` key value you provide is accessible through
liquid tags when creating custom email templates, allowing for personalized transactional messaging based on specific
purchase details.

Tracking purchases is a great way to monitor customer lifetime value (LTV) and identify recurring customers. Bento reports
on the LTV of each subscriber, allowing you to identify high-value customers and tailor your marketing efforts accordingly.

<CodeSample exampleFile={exampleFile} exampleKey="tracking_purchase_events"  />

<SectionTitle title={'Advanced Guide'}/>

## Batch Operations

For efficiency, we suggest using batch operations when integrating with Bento. These methods allow for single or bulk
operations on subscribers and events, improving the performance and scalability of your integration. They also cover more
than 80% of the API use cases for most customers.

<CodeSample exampleFile={exampleFile} exampleKey="import_multiple_subscribers"  />
<CodeSample exampleFile={exampleFile} exampleKey="import_multiple_events"  />


## Transactional Emails

Bento allows you to send personalized transactional emails for time-sensitive, direct communications. These emails serve
specific functional purposes rather than marketing objectives.

<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
  <div className=" ">
    #### Ideal Transactional Email Use Cases
    * User onboarding (confirmation etc)
    * Password reset notifications
    * Sign-in verification links
    * Order confirmations and details
    * Account notifications
  </div>

  <div className="md:bg-neutral-900 rounded-lg md:pl-4">
    #### NOT Ideal Transactional Email Use Cases
    * CC / BCC recipients
    * Emails that require an attachment (we suggest always using links for emails for best deliverability)
    * Marketing of any kind
    * Promotional content
    * Newsletters
  </div>
</div>

#### From Address Requirements
The sender address used in your transactional emails must be configured as an Author email within your Bento settings.
Please note that generic addresses such as "~[no-reply@domain.com](mailto:no-reply@domain.com)~" or similar non-personal
addresses are not currently supported.

#### Important Distinction
**Transactional** emails are designed for **essential communications** that facilitate specific **user actions** or provide
critical information.

<DangerNote>Transactional emails should **not** be used as substitutes for **marketing** campaigns or **promotional**
  content.</DangerNote>


<CodeSample exampleFile={exampleFile} exampleKey="send_transactional_emails"  />

## Subscriber Updates

Many organizations joining Bento already have an established subscriber base that requires bulk updates over time. These
updates commonly include setting field data and managing tags across multiple subscribers. We firmly believe that these
methods are the best way to manage a single or multiple subscribers, and we recommend using them for all subscriber
updates.

<Note>These methods cover more than 80% of the API use cases for most customers.</Note>

#### Choosing the Right Update Method:


The SDK offers multiple approaches for creating subscribers in Bento, each suited to different scenarios.

#### Preferred Method: Events

The recommended way to create subscribers is via events in response to user activity. This approach activates
automations, workflows, and can contain data enrichment.

<Collapsable defaultOpen={false} openLabel="1 More Sample">
  <summary>
    <CodeSample exampleFile={exampleFile} exampleKey="create_a_subscriber_when_they_sign_up"  />
</summary>
<content>
    <CodeSample exampleFile={exampleFile} exampleKey="create_a_subscriber_when_they_make_a_purchase"  />
</content>
</Collapsable>

#### Alternative Methods

For scenarios where you need to create subscribers independently of user actions:
<TimelineContainer>
  <TimelineHeader title={'Single Subscriber Creation'} number={'1'} />
  <TimelineBody>
    Use this method when you need to quickly create a single subscriber with minimal data:

    <CodeSample exampleFile={exampleFile} exampleKey="create_a_single_subscriber"  />

    <WarningNote> This endpoint is rate-limited and not suitable for loops or bulk creation. Use only for individual subscriber creation.</WarningNote>

  </TimelineBody>
  <TimelineHeader title={'Multiple Or Enriched Subscriber Creation'} number={'2'} />
  <TimelineBody>
    For creating multiple subscribers or including additional fields:

    <CodeSample exampleFile={exampleFile} exampleKey="import_multiple_subscribers_at_once"  />

    Best Practices for Batch Imports:
    * Though the API supports up to 1,000 subscribers per call, we recommend batches of 200-300 for optimal performance when dealing with extensive data.
    * Include all relevant custom fields in the initial import to minimize follow-up updates.
    * For very large imports (10,000+ subscribers), consider implementing a queue system with delay between batches.

  </TimelineBody>
</TimelineContainer>

#### Updating Subscribers
Depending on your requirements, several approaches are available for updating subscriber information.

#### Event-Based Updates (Preferred)
When updates occur in response to user actions, tracking events is the recommended approach:

<CodeSample exampleFile={exampleFile} exampleKey="update_subscriber_when_they_update_their_profile"  />

<Note>Becuase you can apply as many changes via automations / workflows as you want this is the most flexible method.
It doesn't require code or deployment changes, and can be completely handled in Bento. </Note>

#### Alternative Update Methods

For updates outside of user-triggered actions:
<TimelineContainer>
  <TimelineHeader title="Single Attribute Updates" number={'1'}/>
  <TimelineBody>
    For quickly updating a specific attribute on a single subscriber:
    <Collapsable defaultOpen={false} openLabel="2 More Samples">
      <summary>
        <CodeSample exampleFile={exampleFile} exampleKey="add_or_update_a_single_field"  />
      </summary>
      <content>
        <CodeSample exampleFile={exampleFile} exampleKey="add_a_tag"  />
        <CodeSample exampleFile={exampleFile} exampleKey="remove_a_field"  />
      </content>
    </Collapsable>

    <WarningNote>The Command API is not recommended for multiple updates or bulk operations. Given its heavy rate limit, use the Batch API instead.</WarningNote>
  </TimelineBody>
  <TimelineHeader title="Batch Updates" number={'2'}/>
  <TimelineBody>
    For updating multiple subscribers or multiple fields at once, use the batch import method:

    <CodeSample exampleFile={exampleFile} exampleKey="update_multiple_subscribers"  />

    Recommendations:
    * Even for single-subscriber updates, consider using the batch import method when multiple fields need updating.
    * The batch import performs an "upsert" operation – it creates subscribers that don't exist and updates those that do.
    * This approach provides the most flexibility as your use cases evolve, whether you need to add more changes or modify multiple users simultaneously.

  </TimelineBody>
</TimelineContainer>

#### Specialized Update Operations
For specific update scenarios, the SDK offers dedicated methods:

<Collapsable defaultOpen={false} openLabel="2 More Samples">
  <summary>
    <CodeSample exampleFile={exampleFile} exampleKey="change_a_subscribers_email_address"  />
    </summary>
    <content>

    <CodeSample exampleFile={exampleFile} exampleKey="update_all_fields_at_once"  />
    <CodeSample exampleFile={exampleFile} exampleKey="unsubscribe_a_user"  />
    </content>
  </Collapsable>

## Utility Features

These features provide additional convenience utility for Bento users, to handle some of the common secondary use cases
we commonly see, such as validation and blacklist checks.

<Collapsable defaultOpen={false} openLabel="3 More Samples">
  <summary>
    <CodeSample exampleFile={exampleFile} exampleKey="validate_email"  />
    </summary>
    <content>
      <CodeSample exampleFile={exampleFile} exampleKey="guess_gender"  />
      <CodeSample exampleFile={exampleFile} exampleKey="geolocate_ip"  />
      <CodeSample exampleFile={exampleFile} exampleKey="check_blacklist"  />

    </content>
  </Collapsable>

<SectionTitle title={'API Reference'}/>

### Core API

- **Analytics** - Main class for initializing the SDK
- `new Analytics(options)` - Create a new instance
- `V1` - Access to the V1 API

### Convenience Methods




| Use Case                                                                                | Convenience Method                                                                                                 |
|-----------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------|
| <span className="text-violet-400"> Add a new subscriber </span>                         | <ClipboardButton isColored={true} textToCopy='addSubscriber(params)' defaultLabel="addSubscriber(params)" />       |
| <span className="text-violet-400">Unsubscribe a subscriber </span>                      | <ClipboardButton isColored={true} textToCopy='removeSubscriber(params)' defaultLabel="removeSubscriber(params)" /> |
| <span className="text-violet-400">Update merge a data to an existing subscriber </span> | <ClipboardButton isColored={true} textToCopy='upsertSubscriber(params)' defaultLabel="upsertSubscriber(params)" /> |
| <span className="text-violet-400">Add a tag to a subscriber </span>                     | <ClipboardButton isColored={true} textToCopy='tagSubscriber(params)' defaultLabel="tagSubscriber(params)" />       |
| <span className="text-violet-400">Update subscriber fields </span>                      | <ClipboardButton isColored={true} textToCopy='updateFields(params)' defaultLabel="updateFields(params)" />         |
| <span className="text-violet-400">Track a custom event </span>                          | <ClipboardButton isColored={true} textToCopy='track(params)' defaultLabel="track(params)" />                       |
| <span className="text-violet-400">Track a purchase event </span>                        | <ClipboardButton isColored={true} textToCopy='trackPurchase(params)' defaultLabel="trackPurchase(params)" />       |

### Modules

#### Batch
| Use Case                                                              | Method                                                                                                                           | API Reference                                                                                                                                         |
|-----------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|
| <span className="text-violet-400">Import multiple subscribers </span> | <ClipboardButton isColored={true} textToCopy='importSubscribers(params)' defaultLabel="importSubscribers(params)" />             | <Link href="/subscribers#import-subscribers" className="inline-flex items-center gap-1">Import Subscribers <ArrowIcon className={'h-6 w-6'} /></Link> |
| <span className="text-violet-400">Import multiple events </span>      | <ClipboardButton isColored={true} textToCopy='importEvents(params)' defaultLabel="importEvents(params)" />                       | <Link href="/events_api#create-events" className="inline-flex items-center gap-1">Import Events <ArrowIcon className={'h-6 w-6'} /></Link>            |
| <span className="text-violet-400">Send multiple emails </span>        | <ClipboardButton isColored={true} textToCopy='sendTransactionalEmails(params)' defaultLabel="sendTransactionalEmails(params)" /> | <Link href="/emails_api#create-emails" className="inline-flex items-center gap-1">Send Emails <ArrowIcon className={'h-6 w-6'} /></Link>              |

#### Commands
| Use Case                                                       | Method                                                                                                   | API Reference                                                                                                                                        |
|----------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|
| <span className="text-violet-400">Add a tag </span>            | <ClipboardButton isColored={true} textToCopy='addTag(params)' defaultLabel="addTag(params)" />           | <Link href="/subscribers#import-subscribers" className="inline-flex items-center gap-1">Subscriber Upsert <ArrowIcon className={'h-6 w-6'} /></Link> |
| <span className="text-violet-400">Remove a tag </span>         | <ClipboardButton isColored={true} textToCopy='removeTag(params)' defaultLabel="removeTag(params)" />     | <Link href="/subscribers#import-subscribers" className="inline-flex items-center gap-1">Subscriber Upsert <ArrowIcon className={'h-6 w-6'} /></Link> |
| <span className="text-violet-400">Add a field </span>          | <ClipboardButton isColored={true} textToCopy='addField(params)' defaultLabel="addField(params)" />       | <Link href="/subscribers#import-subscribers" className="inline-flex items-center gap-1">Subscriber Upsert <ArrowIcon className={'h-6 w-6'} /></Link> |
| <span className="text-violet-400">Remove a field </span>       | <ClipboardButton isColored={true} textToCopy='removeField(params)' defaultLabel="removeField(params)" /> | <Link href="/subscribers#import-subscribers" className="inline-flex items-center gap-1">Subscriber Upsert <ArrowIcon className={'h-6 w-6'} /></Link> |
| <span className="text-violet-400">Subscribe a user </span>     | <ClipboardButton isColored={true} textToCopy='subscribe(params)' defaultLabel="subscribe(params)" />     | <Link href="/subscribers#run-command" className="inline-flex items-center gap-1">Subscriber Command <ArrowIcon className={'h-6 w-6'} /></Link>       |
| <span className="text-violet-400">Unsubscribe a user </span>   | <ClipboardButton isColored={true} textToCopy='unsubscribe(params)' defaultLabel="unsubscribe(params)" /> | <Link href="/subscribers#run-command" className="inline-flex items-center gap-1">Subscriber Command <ArrowIcon className={'h-6 w-6'} /></Link>       |
| <span className="text-violet-400">Change email address </span> | <ClipboardButton isColored={true} textToCopy='changeEmail(params)' defaultLabel="changeEmail(params)" /> | <Link href="/subscribers#run-command" className="inline-flex items-center gap-1">Subscriber Command <ArrowIcon className={'h-6 w-6'} /></Link>       |

#### Experimental
| Use Case                                                              | Method                                                                                                         | API Reference                                                                                                                                   |
|-----------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------|
| <span className="text-violet-400">Validate email address </span>      | <ClipboardButton isColored={true} textToCopy='validateEmail(params)' defaultLabel="validateEmail(params)" />   | <Link href="/utility#validate-email" className="inline-flex items-center gap-1">Validate Email <ArrowIcon className={'h-6 w-6'} /></Link>       |
| <span className="text-violet-400">Predict in-domain placement </span> | <ClipboardButton isColored={true} textToCopy='guessGender(params)' defaultLabel="guessGender(params)" />       | <Link href="/utility#guess-gender" className="inline-flex items-center gap-1">Gender Guess <ArrowIcon className={'h-6 w-6'} /></Link>           |
| <span className="text-violet-400">Get IP geolocation </span>          | <ClipboardButton isColored={true} textToCopy='geolocate(params)' defaultLabel="geolocate(params)" />           | <Link href="/utility#geolocate-ip-address" className="inline-flex items-center gap-1">IP Geolocation <ArrowIcon className={'h-6 w-6'} /></Link> |
| <span className="text-violet-400">Check domain/IP blacklist </span>   | <ClipboardButton isColored={true} textToCopy='checkBlacklist(params)' defaultLabel="checkBlacklist(params)" /> | <Link href="/utility#search-blacklists" className="inline-flex items-center gap-1">Blacklist Check <ArrowIcon className={'h-6 w-6'} /></Link>   |

#### Fields
| Use Case                                                 | Method                                                                                                   | API Reference                                                                                                                  |
|----------------------------------------------------------|----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------|
| <span className="text-violet-400">Get all fields </span> | <ClipboardButton isColored={true} textToCopy='getFields()' defaultLabel="getFields()" />                 | <Link href="/fields#get-fields" className="inline-flex items-center gap-1">Fields <ArrowIcon className={'h-6 w-6'} /></Link>   |
| <span className="text-violet-400">Create a field </span> | <ClipboardButton isColored={true} textToCopy='createField(params)' defaultLabel="createField(params)" /> | <Link href="/fields#create-field" className="inline-flex items-center gap-1">Fields <ArrowIcon className={'h-6 w-6'} /></Link> |

#### Forms
| Use Case                                                     | Method                                                                                                     | API Reference |
|--------------------------------------------------------------|------------------------------------------------------------------------------------------------------------|---------------|
| <span className="text-violet-400">Get form responses </span> | <ClipboardButton isColored={true} textToCopy='getResponses(formId)' defaultLabel="getResponses(formId)" /> | --            |

#### Subscribers
| Use Case                                                      | Method                                                                                                             | API Reference                                                                                                                                     |
|---------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| <span className="text-violet-400">Get subscriber </span>      | <ClipboardButton isColored={true} textToCopy='getSubscribers(params)' defaultLabel="getSubscribers(params)" />     | <Link href="/subscribers#find-subscriber" className="inline-flex items-center gap-1">Find Subscriber <ArrowIcon className={'h-6 w-6'} /></Link>   |
| <span className="text-violet-400">Create a subscriber </span> | <ClipboardButton isColored={true} textToCopy='createSubscriber(params)' defaultLabel="createSubscriber(params)" /> | <Link href="/subscribers#find-subscriber" className="inline-flex items-center gap-1">Create Subscriber <ArrowIcon className={'h-6 w-6'} /></Link> |
| <span className="text-violet-400">Run command </span>         | <ClipboardButton isColored={true} textToCopy='runCommand(params)' defaultLabel="runCommand(params)" />             | <Link href="/subscribers#run-command" className="inline-flex items-center gap-1">Subscriber Commands <ArrowIcon className={'h-6 w-6'} /></Link>   |

#### Tags
| Use Case                                               | Method                                                                                               | API Reference                                                                                                                      |
|--------------------------------------------------------|------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------|
| <span className="text-violet-400">Get all tags </span> | <ClipboardButton isColored={true} textToCopy='getTags()' defaultLabel="getTags()" />                 | <Link href="/tags_api#get-tags" className="inline-flex items-center gap-1">List Tags <ArrowIcon className={'h-6 w-6'} /></Link>    |
| <span className="text-violet-400">Create a tag </span> | <ClipboardButton isColored={true} textToCopy='createTag(params)' defaultLabel="createTag(params)" /> | <Link href="/tags_api#create-tag" className="inline-flex items-center gap-1">Create Tag <ArrowIcon className={'h-6 w-6'} /></Link> |


<SectionTitle title={'Troubleshooting'}/>

#### Common Errors

|                                                            |                                                                   |
|------------------------------------------------------------|-------------------------------------------------------------------|
| <Tag color={'rose'} variant={'large'}>Not Authorized</Tag> | Check your API keys and ensure they have appropriate permissions  |
| <Tag color={'rose'} variant={'large'}>Rate Limited</Tag>   | Implement backoff/retry logic for batch operations                |
| <Tag color={'rose'} variant={'large'}>Network Errors</Tag> | Check internet connectivity and API endpoint availability         |
| <Tag color={'rose'} variant={'large'}>Exceptions</Tag>     | Double check you are using a valid `Author` & the payload format. |


#### Debugging Tips

|    |                                                                           |
|----|---------------------------------------------------------------------------|
| 1. | Enable `logErrors: true` in your configuration for detailed error logging |
| 2. | Use try/catch blocks around API calls to handle errors gracefully         |
| 3. | For batch operations, start with smaller batches to isolate issues        |


<SectionTitle title={'FAQ'}/>

**Q: Can I use this SDK in a browser environment?**
A: No, this SDK is designed for server-side Node.js environments as it requires secret API keys.

**Q: How do I handle rate limiting?**
A: Implement exponential backoff when you encounter `RateLimitedError` exceptions.

**Q: What's the maximum batch size for importing subscribers or events?**
A: Up to 1,000 subscribers or events can be imported in a single batch operation.

**Q: How do I track anonymous users?**
A: Currently, the SDK requires an email for all tracking. Anonymous tracking support is planned for future releases.

**Q: Is this SDK compatible with TypeScript?**
A: Yes, the SDK is written in TypeScript and provides full type definitions for improved developer experience.

**Q: How can I contribute to the SDK?**
A: Check the GitHub repository at [github.com/bentonow/bento-node-sdk](https://github.com/bentonow/bento-node-sdk) for contribution guidelines, or contact us in discord.