johnboy-leeds / braze-api

:mailbox: Node.js library for Braze API.

Home Page:https://b.remarkabl.org/braze-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

braze-api

NPM

NPM version build codecov NPM downloads

Node.js library for Braze (see demo). The types are inspired by Braze's Postman collection.

Quick Start

import { Braze } from 'braze-api'

const braze = new Braze('YOUR_API_URL', 'YOUR_API_KEY')

await braze.messages.send({
  external_user_ids: ['your_external_user_id'],
  messages: {
    email: {
      app_id: 'your_app_id',
      from: 'Company <company@example.com>',
      email_template_id: 'your_email_template_id',
    },
  },
})

Documentation

See Braze API guide and Braze's Postman collection.

Prerequisites

Installation

NPM:

npm install braze-api

Yarn:

yarn add braze-api

Usage

The package needs to be configured with your account's REST endpoint and API key:

const { Braze } = require('braze-api')

const braze = new Braze('YOUR_API_URL', 'YOUR_API_KEY')

The same can be done with ES Modules:

import { Braze } from 'braze-api'

const braze = new Braze('YOUR_API_URL', 'YOUR_API_KEY')

API URL

Use the REST endpoint provisioned to your account when you log in to the dashboard:

Instance REST Endpoint
US-01 https://rest.iad-01.braze.com
US-02 https://rest.iad-02.braze.com
US-03 https://rest.iad-03.braze.com
US-04 https://rest.iad-04.braze.com
US-05 https://rest.iad-05.braze.com
US-06 https://rest.iad-06.braze.com
US-08 https://rest.iad-08.braze.com
EU-01 https://rest.fra-01.braze.eu
EU-02 https://rest.fra-02.braze.eu

API Key

The API key can be created in your Braze dashboard.

API Methods

This library currently supports a subset of the Braze API endpoints. Pull requests are welcome.

User data

  • /users/alias/new
  • /users/delete
  • /users/export/global_control_group
  • /users/export/ids
  • /users/export/segment
  • /users/external_ids/rename
  • /users/external_ids/remove
  • /users/identify
  • /users/track

Send messages

  • /campaigns/trigger/send
  • /canvas/trigger/send
  • /messages/send
  • /sends/id/create
  • /transactional/v1/campaigns/{{CAMPAIGN_ID}}/send

Schedule messages

  • /campaigns/trigger/schedule/create
  • /campaigns/trigger/schedule/delete
  • /campaigns/trigger/schedule/update
  • /canvas/trigger/schedule/create
  • /canvas/trigger/schedule/delete
  • /canvas/trigger/schedule/update
  • /messages/schedule/create
  • /messages/schedule/delete
  • /messages/schedule/update
  • /messages/scheduled_broadcasts

Subscription groups

  • /subscription/status/set
  • /v2/subscription/status/set
  • /subscription/status/get
  • /subscription/user/status

Email and email templates

  • /email/blacklist
  • /email/bounce/remove
  • /email/spam/remove
  • /email/status
  • /templates/email/create
  • /templates/email/update
  • /email/hard_bounces
  • /email/unsubscribes
  • /templates/email/info
  • /templates/email/list

Campaigns

  • /campaigns/data_series
  • /campaigns/details
  • /campaigns/list
  • /sends/data_series

Canvas

  • /canvas/data_series
  • /canvas/data_summary
  • /canvas/details
  • /canvas/list

Segments

  • /segments/data_series
  • /segments/details
  • /segments/list
  • /sessions/data_series

Custom events

  • /events/data_series
  • /events/list

Content Blocks

  • /content_blocks/create
  • /content_blocks/update
  • /content_blocks/info
  • /content_blocks/list

KPI

  • /kpi/dau/data_series
  • /kpi/mau/data_series
  • /kpi/new_users/data_series
  • /kpi/uninstalls/data_series

News Feed

  • /feed/data_series
  • /feed/details
  • /feed/list

SMS

  • /sms/invalid_phone_numbers/remove
  • /sms/invalid_phone_numbers

Purchases

  • /purchases/product_list

Catalogs

  • /synchronous/catalogs/delete
  • /synchronous/catalogs/get
  • /synchronous/catalogs/post
  • /synchronous/catalog-items/delete
  • /synchronous/catalog-items/list
  • /synchronous/catalog-items/get
  • /synchronous/catalog-items/update
  • /synchronous/catalog-items/create
  • /asynchronous/catalog-items/delete-multiple
  • /asynchronous/catalog-items/update-multiple
  • /asynchronous/catalog-items/create-multiple

Contributing

We encourage contributions! Check out the contributing guide on how to proceed.

License

MIT

About

:mailbox: Node.js library for Braze API.

https://b.remarkabl.org/braze-api

License:MIT License


Languages

Language:TypeScript 98.5%Language:Shell 1.5%