Skip to content

speakeasy-sdks/attentive-node-sdk

Repository files navigation

Attentive Node SDK

Attentive’s APIs allow you as a developer to integrate with the Attentive platform and build custom applications. Use our numerous endpoints to manage user subscriptions, trigger messages related to user actions, save subscriber attributes, and send personalized text messages.

SDK Installation

NPM

npm add @attentive/sdk

Yarn

yarn add @attentive/sdk

Authentication

Authentication To keep data on Attentive’s platform safe and secure, all apps connecting with Attentive’s APIs must authenticate when making API requests. This article describes the different methods of authenticating and authorizing apps with Attentive’s platform.

Types of authentication Different types of apps require different authentication or authorization methods:

Private apps use basic HTTP authentication. Public apps use OAuth 2.0.

HTTP authentication Private applications can authenticate through basic HTTP authentication by using their API key as the Bearer Token when making calls to Attentive’s APIs. To generate a unique API key, you must create an app in the Attentive platform. You should treat your API key as a password. If it is accidentally shared, other users may be able to send messages to customers on your behalf. Use the /me endpoint to verify that you are authenticating correctly.

For a GraphQL API example:

curl --location --request POST 'https://api.attentivemobile.com/v1/graphql' \
--header 'Authorization: Bearer <Unique API Key>' \
--header 'Content-Type: application/json' \
--data-raw '{"query":"\nquery {\n  viewer {\n    installedApplication {\n      installerCompany {\n          id\n          name\n      }\n    }\n  }\n}\n\n","variables":{}}'

For a REST API example:

curl 'https://api.attentivemobile.com/v1/me' \
 -X GET \
 -H 'Authorization: Bearer <Unique API Key>' \
 -H 'Content-Type: application/json' \

Note: If you are unable to access the Attentive platform, please send an email to [email protected] for access.

SDK Example Usage

import { SDK, withSecurity} from "@attentive/sdk";
import { CreateTokenViaAuthorizationCodeRequest, CreateTokenViaAuthorizationCodeResponse } from "@attentive/sdk/src/sdk/models/operations";
import { AxiosError } from "axios";

const sdk = new SDK(withSecurity(
  security: {
    oAuthFlow: {
      authorization: "Bearer YOUR_ACCESS_TOKEN_HERE",
    },
  }
));
    
const req: CreateTokenViaAuthorizationCodeRequest = {
  request: {
    clientId: "sit",
    clientSecret: "voluptas",
    code: "culpa",
    grantType: "expedita",
    redirectUri: "consequuntur",
  },
};

sdk.accessToken.createTokenViaAuthorizationCode(req).then((res: CreateTokenViaAuthorizationCodeResponse | AxiosError) => {
   // handle response
});

SDK Available Operations

Access Token

  • createTokenViaAuthorizationCode - Access Token

Custom Attributes

  • postCustomAttributes - Custom Attributes

Custom Events

  • postCustomEvents - Custom Events

Identity

  • identify - Add a client user identifier or custom identifier(s) to a user

Privacy Request

  • addDeleteRequest - Sending a request to this endpoint will delete a subscriber in accordance with CCPA regulations within thirty days provided the call was successful.
  • getDeleteRequest - Get a CCPA delete request by Id

Product Catalog

  • getUploads - View Recent Catalog Uploads
  • lookupUpload - Lookup Product Catalog Ingestion
  • postUpload - Upload Product Catalog

Subscribers

  • addSubscriptions - Subscribe user
  • getSubscriptions - Get subscription eligibility for a user
  • unsubscribeSubscriptions - Unsubscribe subscriptions for a user

Test Authentication

  • getMe - Me

Webhooks

  • createWebhook - Create webhook
  • deleteWebhook - Delete webhook
  • getWebhooks - List webhooks
  • updateWebhook - Update webhook

eCommerce

  • postAddToCartEvents - Add to cart
  • postProductViewEvents - Product view
  • postPurchaseEvents - Purchase

SDK Generated by Speakeasy