convoup Docs
Docs / Core Concepts / SDK vs REST

SDK vs REST

The Convoup SDK is a convenience layer over the REST API. This page explains when to use each approach.

When to Use the SDK

Use the SDK when:

TypeScript
import { Convoup } from 'convoup';

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

await client.sendOtp({
  to: '+918851479441',
  template: 'test_welcome_template',
  code: '123456',
});

When to Use the REST API

Use the REST API when:

bash
curl -X POST https://api.convoup.com/api/v1/templates \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "to": "+918851479441",
    "template_name": "test_welcome_template",
    "language": "en_US",
    "body_params": [{"type": "text", "text": "123456"}]
  }'

Method-to-Endpoint Mapping

SDK MethodREST EndpointMethod
client.sendOtp()/api/v1/templatesPOST
client.sendInvoice()/api/v1/templatesPOST
client.sendReminder()/api/v1/templatesPOST
client.sendTemplate()/api/v1/templatesPOST
(SDK does not wrap)/api/v1/messagesPOST
(SDK does not wrap)/api/v1/templatesGET
(SDK does not wrap)/api/v1/contacts/window-statusGET

All four SDK methods map to the same POST /api/v1/templates endpoint with different parameter construction.

Key Differences

AspectSDKREST
AuthenticationPass apiKey in constructorPass x-api-key header per request
Payload constructionTyped params (to, template, code)Manual JSON body
Error handlingConvoupError with status, code, detailsParse response JSON yourself
Language defaulten_USMust specify language in body
Type safetyFull TypeScript typesNone (unless you define them)

Example: Same Call in Both Approaches

await client.sendOtp({
  to: '+918851479441',
  template: 'test_welcome_template',
  code: '123456',
});
curl -X POST https://api.convoup.com/api/v1/templates \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "to": "+918851479441",
    "template_name": "test_welcome_template",
    "language": "en_US",
    "body_params": [{"type": "text", "text": "123456"}]
  }'

Next Steps