convoup Docs
Docs / API Reference / Client Constructor

Client Constructor

The Convoup client is the entry point for all SDK operations.

Basic Usage

TypeScript
import { Convoup } from 'convoup';

const client = new Convoup({
  apiKey: process.env.CONVOUP_API_KEY!,
});

Constructor Options

Option Type Required Description
apiKey string Yes API key from the Convoup dashboard
wabaId string No WABA ID (required when key has multiple scopes)
baseUrl string No API base URL (default: https://api.convoup.com/api)
fetch typeof fetch No Custom fetch implementation

WABA Scoping

When your API key has access to multiple WABAs, you must pass the wabaId:

TypeScript
const client = new Convoup({
  apiKey: 'your-api-key',
  wabaId: 'waba-id-123',
});

When your key is scoped to exactly one WABA, the server resolves it automatically:

TypeScript
const client = new Convoup({
  apiKey: 'your-api-key',
  // wabaId is optional here
});
Note

The wabaId is only required when your API key has access to multiple WABAs. If it is scoped to exactly one WABA, the server resolves it automatically.

Custom Base URL

Point to a local or staging server:

TypeScript
const client = new Convoup({
  apiKey: 'test-key',
  baseUrl: 'http://localhost:5000/api',
});

Custom Fetch

Provide your own fetch implementation (e.g., for testing or proxies):

TypeScript
import nodeFetch from 'node-fetch';

const client = new Convoup({
  apiKey: process.env.CONVOUP_API_KEY!,
  fetch: nodeFetch,
});

Full Example

TypeScript
import { Convoup } from 'convoup';

const client = new Convoup({
  apiKey: process.env.CONVOUP_API_KEY!,
  wabaId: process.env.CONVOUP_WABA_ID,
  baseUrl: 'https://api.convoup.com/api',
});

// Now use the client methods
const result = await client.sendOtp({
  to: '+918851479441',
  template: 'test_welcome_template',
  code: '123456',
});

console.log(result.messageId); // Meta message ID

Next Steps