Skip to content

JavaScript SDK

Coming Soon

The official JavaScript SDK is under development. In the meantime, use the REST API directly.

Preview

The JavaScript SDK will work in both Node.js and browser environments:

javascript
import { CubeConnect } from '@cubeconnect/sdk'

const cube = new CubeConnect('YOUR_API_KEY')

// Send a text message
const result = await cube.messages.sendText('+966501234567', 'Hello!')

// Send a template
const result = await cube.messages.sendTemplate('+966501234567', 'order_confirmation', {
  params: ['ORD-1234', '500 SAR'],
})

// Check result
console.log(result.messageLogId)
console.log(result.status) // "queued"

Requirements

  • Node.js 18+ or modern browser
  • ES modules support

Installation (Coming Soon)

bash
npm install @cubeconnect/sdk

Current Alternative

Use fetch or any HTTP client:

javascript
const response = await fetch('https://cubeconnect.io/api/v1/messages/send', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    phone: '+966501234567',
    message_type: 'text',
    data: { body: 'Hello!' },
  }),
})

See the API Reference for the complete API specification.

CubeConnect WhatsApp Business Platform