SendKuy API

SDKs

Libraries for Node.js, PHP and Laravel that cover every endpoint, retry safely and verify webhooks.

Three libraries, maintained by SendKuy, cover every endpoint in this reference. Field names are the API's own, so each request in the reference maps one to one onto an SDK call.

Send your first message

import { SendKuy } from 'sendkuy';

const sendkuy = new SendKuy('sk_live_YOUR_API_KEY');

const [message] = await sendkuy.messages.send({
  channel: 'whatsapp',
  to: ['+6281234567890'],
  body: 'Your order is on its way.',
});

What the SDKs handle for you

  • Retries without duplicates. Every write carries an Idempotency-Key, and each retry of that call reuses it, so a retry after a timeout or a dropped connection gets the first answer instead of sending again. The SDKs retry network errors, timeouts, 5xx, idempotency_request_in_progress, and 429 when Retry-After is a minute or less, up to twice. See Idempotency.
  • Pagination. autoPaginate() follows next_cursor until the last page. See Pagination.
  • Typed errors, one class per error.type, carrying code, param, the documentation link and the request id.
  • Webhook signatures, checked in one call. See Webhooks.
  • Types. The Node.js SDK ships TypeScript types generated from this API's contract; the PHP SDK gives your editor every field of every object.

Errors

error.typeNode.jsPHP
authentication_errorAuthenticationErrorAuthenticationException
authorization_errorAuthorizationErrorAuthorizationException
invalid_request_errorInvalidRequestErrorInvalidRequestException
rate_limit_errorRateLimitErrorRateLimitException
api_errorApiErrorApiException
no response at allConnectionErrorConnectionException

Every class extends SendKuyError in Node.js and SendKuyException in PHP, so one catch covers them all. Branch on the code, never on the message: error.code in Node.js, $e->getErrorCode() in PHP. The full list is on Errors.

Each error also carries the HTTP status (error.status, $e->getHttpStatus()) and, on a 429, the seconds to wait (error.retryAfter, $e->getRetryAfter()). A webhook that fails verification raises SignatureVerificationError or SignatureVerificationException, whose reason is one of malformed_header, timestamp_out_of_tolerance, signature_mismatch or invalid_payload.

Configure the client

The API key is the first argument. In Node.js you may leave it out, and SENDKUY_API_KEY is read from the environment. The other options go in the second argument:

const sendkuy = new SendKuy('sk_live_YOUR_API_KEY', { timeout: 10_000, maxRetries: 1 });
Node.jsPHPDefaultSets
timeouttimeout30000 milliseconds; 30 secondshow long one attempt may take
maxRetriesmax_retries2retries after the first attempt
fetchhttp_clientthe runtime's fetch; Guzzlethe HTTP client, for a proxy or a fake in tests
baseUrlbase_urlhttps://app.sendkuy.com/api/v1the API address; change it only to reach a proxy or a mock server in tests

With your own http_client in PHP, set the timeout on that client: the SDK's timeout does not reach it. The Node.js SDK refuses to run in a browser, where anyone who opens the page could read your key; dangerouslyAllowBrowser: true overrides that. In Laravel, every option is an environment variable; see Configuration.

One call can override the timeout and carry its own idempotency key. Node.js also takes an AbortSignal:

await sendkuy.messages.send(params, { timeout: 5_000, idempotencyKey: 'order-1042-shipped' });

Versions

Version 1.x of each SDK covers API v1. Every release is listed in the CHANGELOG for Node.js, PHP and Laravel.

Methods

Every endpoint in this reference has a method. An endpoint newer than your installed version is still one call away with request(): sendkuy.request({ method: 'GET', path: '/account' }) in Node.js, $sendkuy->request('GET', '/account') in PHP.

EndpointNode.js, then PHP
Messages
List messages you have sentsendkuy.messages.list()$sendkuy->messages()->list()
Send one message to one or more recipientssendkuy.messages.send()$sendkuy->messages()->send()
Send up to 500 independent messages in one callsendkuy.messages.sendBatch()$sendkuy->messages()->sendBatch()
Read one messagesendkuy.messages.get()$sendkuy->messages()->get()
Cancel a message that has not gone out yetsendkuy.messages.cancel()$sendkuy->messages()->cancel()
Send a failed message againsendkuy.messages.resend()$sendkuy->messages()->resend()
Numbers
Check which numbers are on WhatsAppsendkuy.numbers.check()$sendkuy->numbers()->check()
Verify
Send a one-time codesendkuy.verifications.create()$sendkuy->verifications()->create()
Read one verificationsendkuy.verifications.get()$sendkuy->verifications()->get()
Check a codesendkuy.verifications.check()$sendkuy->verifications()->check()
Contacts
List your contactssendkuy.contacts.list()$sendkuy->contacts()->list()
Create a contactsendkuy.contacts.create()$sendkuy->contacts()->create()
Import up to 1000 contacts in the backgroundsendkuy.contacts.bulkImport()$sendkuy->contacts()->bulkImport()
Find a contact by phone number or by your own idsendkuy.contacts.lookup()$sendkuy->contacts()->lookup()
Read one contactsendkuy.contacts.get()$sendkuy->contacts()->get()
Change a contactsendkuy.contacts.update()$sendkuy->contacts()->update()
Delete a contactsendkuy.contacts.delete()$sendkuy->contacts()->delete()
List the attributes defined on your contactssendkuy.contacts.listAttributes()$sendkuy->contacts()->listAttributes()
Groups
List contact groupssendkuy.groups.list()$sendkuy->groups()->list()
Create a groupsendkuy.groups.create()$sendkuy->groups()->create()
Read one groupsendkuy.groups.get()$sendkuy->groups()->get()
Rename a groupsendkuy.groups.update()$sendkuy->groups()->update()
Delete a groupsendkuy.groups.delete()$sendkuy->groups()->delete()
Add contacts to a groupsendkuy.groups.addContacts()$sendkuy->groups()->addContacts()
Take contacts out of a groupsendkuy.groups.removeContacts()$sendkuy->groups()->removeContacts()
Templates
List message templatessendkuy.templates.list()$sendkuy->templates()->list()
Create a templatesendkuy.templates.create()$sendkuy->templates()->create()
Read one templatesendkuy.templates.get()$sendkuy->templates()->get()
Change a templatesendkuy.templates.update()$sendkuy->templates()->update()
Delete a templatesendkuy.templates.delete()$sendkuy->templates()->delete()
Campaigns
List campaignssendkuy.campaigns.list()$sendkuy->campaigns()->list()
Create a campaignsendkuy.campaigns.create()$sendkuy->campaigns()->create()
Read one campaign, with its numberssendkuy.campaigns.get()$sendkuy->campaigns()->get()
Change a campaignsendkuy.campaigns.update()$sendkuy->campaigns()->update()
Delete a campaignsendkuy.campaigns.delete()$sendkuy->campaigns()->delete()
List what a campaign is sending, per contactsendkuy.campaigns.listDispatches()$sendkuy->campaigns()->listDispatches()
Start a campaignsendkuy.campaigns.start()$sendkuy->campaigns()->start()
Pause a running campaignsendkuy.campaigns.pause()$sendkuy->campaigns()->pause()
Resume a paused campaignsendkuy.campaigns.resume()$sendkuy->campaigns()->resume()
Cancel a campaignsendkuy.campaigns.cancel()$sendkuy->campaigns()->cancel()
Inbox
List conversations in your inboxsendkuy.conversations.list()$sendkuy->conversations()->list()
Read one conversationsendkuy.conversations.get()$sendkuy->conversations()->get()
Read the messages in a conversationsendkuy.conversations.listMessages()$sendkuy->conversations()->listMessages()
Mark a conversation as readsendkuy.conversations.markRead()$sendkuy->conversations()->markRead()
Reply in a conversationsendkuy.conversations.reply()$sendkuy->conversations()->reply()
Automation
List automation workflowssendkuy.workflows.list()$sendkuy->workflows()->list()
Read one workflowsendkuy.workflows.get()$sendkuy->workflows()->get()
List the runs of one workflowsendkuy.workflows.listExecutions()$sendkuy->workflows()->listExecutions()
Trigger a workflowsendkuy.workflows.trigger()$sendkuy->workflows()->trigger()
Read one workflow runsendkuy.executions.get()$sendkuy->executions()->get()
Webhooks
List your webhook endpointssendkuy.webhooks.list()$sendkuy->webhooks()->list()
Register a webhook endpointsendkuy.webhooks.create()$sendkuy->webhooks()->create()
Read one webhook endpointsendkuy.webhooks.get()$sendkuy->webhooks()->get()
Change a webhook endpointsendkuy.webhooks.update()$sendkuy->webhooks()->update()
Delete a webhook endpointsendkuy.webhooks.delete()$sendkuy->webhooks()->delete()
Read the delivery history of an endpointsendkuy.webhooks.listDeliveries()$sendkuy->webhooks()->listDeliveries()
Gateways
List the gateways your messages can leave throughsendkuy.gateways.list()$sendkuy->gateways()->list()
Read one gatewaysendkuy.gateways.get()$sendkuy->gateways()->get()
Account
Read the account behind this keysendkuy.account.get()$sendkuy->account()->get()
Read this period's usage per channelsendkuy.account.usage()$sendkuy->account()->usage()
Jobs
Read the status of background worksendkuy.jobs.get()$sendkuy->jobs()->get()