Quickstart
Create an API key and run one script to schedule a post, send a WhatsApp message, reply to a DM or create an ad campaign.
What do you want to build?
Before you start
- A Zernio account (sign up).
- A login for one of the 16 platforms. The example connects LinkedIn.
- A card only if you connect X (
twitter), because X bills every API call. Your first 2 other accounts need none (pricing).
Using a coding agent? Give it this prompt.
Before you start
- A Zernio account (sign up).
- A phone with WhatsApp on it, to receive the test message.
- Nothing else: no number purchase, no WhatsApp Business Account, no Meta review, and nothing is billed.
Using a coding agent? Give it this prompt.
Before you start
- A Zernio account (sign up).
- A connected account on a platform with direct messages (which ones). To connect one, run the "Publish a post" version first.
- At least one DM sent to that account, so there is a conversation to answer.
Using a coding agent? Give it this prompt.
Before you start
Using a coding agent? Give it this prompt.
Run it
Create an API key
- Sign up or log in.
- Open API keys and click Create API key.
- Copy the key now. Zernio stores a SHA-256 hash of it and never shows it again.
A key is sk_ followed by 64 hex characters (67 in total). Every request to https://zernio.com/api/v1 sends it in the Authorization: Bearer header. The SDKs read it from the ZERNIO_API_KEY environment variable.
Install the SDK and set the key
npm install @zernio/node
export ZERNIO_API_KEY="sk_..."Create one key per app and rotate keys through the API.
Go, Ruby, Java, PHP, .NET and Rust SDKs are on the SDKs page.
Run the script
Save this as quickstart.mjs (Node.js) or quickstart.py (Python) and run it.
It prints a URL, waits while you approve the account in a browser, then schedules the post.
import Zernio from '@zernio/node';
import { createInterface } from 'node:readline/promises';
const zernio = new Zernio(); // reads ZERNIO_API_KEY
// 1. A profile groups accounts: one per brand, or one per user of your app.
const { data: created } = await zernio.profiles.createProfile({
body: { name: 'My first profile' }
});
const profileId = created.profile._id;
// 2. Get the URL where the account owner authorizes Zernio, and approve it.
const { data: connect } = await zernio.connect.getConnectUrl({
path: { platform: 'linkedin' },
query: { profileId }
});
console.log('Open this URL and approve:', connect.authUrl);
const prompt = createInterface({ input: process.stdin, output: process.stdout });
await prompt.question('Press Enter once the account is connected ');
prompt.close();
// 3. Posts target accounts by _id, not by username.
const { data: listed } = await zernio.accounts.listAccounts();
const accountId = listed.accounts[0]._id;
// 4. Schedule the post. scheduledFor is read in the timezone you send.
const { data: scheduled } = await zernio.posts.createPost({
body: {
content: 'Hello world. This is my first post from the Zernio API.',
scheduledFor: '2027-01-01T12:00:00',
timezone: 'America/New_York',
platforms: [
{ platform: 'linkedin', accountId }
]
}
});
const postId = scheduled.post._id;
// 5. Read it back: scheduled now, published after the scheduled time.
const { data: fetched } = await zernio.posts.getPost({
path: { postId }
});
console.log(fetched.post.status);node quickstart.mjsThe last line it prints is scheduled.
Put your own phone number in phone, save this as quickstart.mjs (Node.js) or quickstart.py (Python) and run it.
It sends a WhatsApp message to your phone, waits while you reply to it, then sends through the API.
import Zernio from '@zernio/node';
import { createInterface } from 'node:readline/promises';
const zernio = new Zernio(); // reads ZERNIO_API_KEY
const phone = '+13105551234'; // your own phone, with WhatsApp on it
// 1. Find the shared sandbox number, the account to send from and its template.
const { data: numbers } = await zernio.phonenumbers.listPhoneNumbers();
if (!numbers.sandbox) throw new Error('Sandbox not configured on this environment');
const sandbox = numbers.sandbox;
// 2. Start activation: Zernio sends the sandbox template to your phone.
const { data: started } = await zernio.whatsappsandbox.createWhatsAppSandboxSession({
body: { phone }
});
console.log('Reply to the WhatsApp message from', started.sandboxNumber);
const prompt = createInterface({ input: process.stdin, output: process.stdout });
await prompt.question('Press Enter once you have replied ');
prompt.close();
// 3. Your reply activates the session.
const { data: sessions } = await zernio.whatsappsandbox.listWhatsAppSandboxSessions();
const session = sessions.sessions[0];
if (session?.status !== 'active') throw new Error('No reply yet: answer the WhatsApp message, then run this again');
// 4. Send to the activated phone.
const { data: opened } = await zernio.messages.createInboxConversation({
body: {
accountId: sandbox.accountId,
participantId: session.phoneE164,
templateName: sandbox.template.name,
templateLanguage: sandbox.template.language,
templateParams: []
}
});
console.log('Sent. Conversation:', opened.data.conversationId);node quickstart.mjsThe last line it prints is the conversation id, and the message arrives on your phone.
Save this as quickstart.mjs (Node.js) or quickstart.py (Python) and run it.
It shows the first conversation in your inbox, waits for you to confirm, then replies. The reply is a real message to that person.
import { randomUUID } from 'crypto';
import Zernio from '@zernio/node';
import { createInterface } from 'node:readline/promises';
const zernio = new Zernio(); // reads ZERNIO_API_KEY
// 1. List the conversations across your connected accounts.
const { data: conversations } = await zernio.messages.listInboxConversations({
query: { status: 'active', limit: 50 },
});
const conversation = conversations.data[0];
if (!conversation) throw new Error('No conversations yet: send a DM to your connected account, then run this again');
// 2. Check who you are about to answer. This sends a real message.
console.log(`${conversation.participantName} on ${conversation.platform}: ${conversation.lastMessage}`);
const prompt = createInterface({ input: process.stdin, output: process.stdout });
await prompt.question('Press Enter to reply, or Ctrl+C to cancel ');
prompt.close();
// 3. Reply in that conversation, from the account that received it.
const { data: sent } = await zernio.messages.sendInboxMessage({
path: { conversationId: conversation.id },
headers: { 'Idempotency-Key': randomUUID() },
body: {
accountId: conversation.accountId,
message: 'Thanks for your message. This reply was sent with the Zernio API.',
},
});
console.log(sent.data.messageId);node quickstart.mjsThe last line it prints is the id of the message it sent.
Save this as quickstart.mjs (Node.js) or quickstart.py (Python) and run it.
It prints a URL, waits while you approve Meta ads access in a browser, then creates a paused campaign in your first ad account.
import Zernio from '@zernio/node';
import { createInterface } from 'node:readline/promises';
const zernio = new Zernio(); // reads ZERNIO_API_KEY
// 1. A profile groups accounts: one per brand, or one per user of your app.
const { data: created } = await zernio.profiles.createProfile({
body: { name: 'My first profile' }
});
const profileId = created.profile._id;
// 2. Connect Meta ads. Approve in a browser unless ads are already connected.
const { data: adsStart } = await zernio.connect.connectAds({
path: { platform: 'facebook' },
query: { profileId },
});
if (!adsStart.alreadyConnected) {
console.log('Open this URL and approve:', adsStart.authUrl);
const prompt = createInterface({ input: process.stdin, output: process.stdout });
await prompt.question('Press Enter once the account is connected ');
prompt.close();
}
// 3. Find the connected account, then the Meta ad account it can reach.
const { data: listed } = await zernio.accounts.listAccounts();
const account = listed.accounts.find((a) => a.platform === 'facebook' || a.platform === 'metaads');
if (!account) throw new Error('No Facebook or Meta Ads account connected yet');
const { data: adAccounts } = await zernio.adaccounts.listAdAccounts({
query: { accountId: account._id }
});
const adAccountId = adAccounts.accounts[0].id;
// 4. Create a campaign. It is created paused and has no ads, so it spends nothing.
const { data: campaign } = await zernio.adcampaigns.createAdCampaign({
body: {
accountId: account._id,
adAccountId,
name: 'Quickstart campaign',
goal: 'traffic'
}
});
console.log(campaign.campaignId, campaign.status);node quickstart.mjsThe last line it prints is the campaign id and PAUSED.
What just happened
- A profile was created. A profile groups accounts: one per brand, or one per user of your app.
- An account was connected to it.
GET /v1/connect/{platform}returned the URL where the account owner authorized Zernio. - The script looked up the account id. Posts target accounts by
_id, not by username. - A post was scheduled.
POST /v1/poststook the content, the time, the timezone and oneplatformsentry. - The status was read back. It is
scheduleduntil the scheduled time, thenpublishing, thenpublished.
Every id is a 24-character string in an _id field. Each call returns the id the next one needs.
If your users connect their own accounts, the calls are the same with one profile per user: read Build a platform after your first post.
- The script found the sandbox.
GET /v1/phone-numbersreturns Zernio's shared WhatsApp number, theaccountIdto send from and its one template undersandbox. - Your phone was activated.
POST /v1/whatsapp/sandbox/sessionssent thesandbox_starttemplate to it, and your reply proved you control the phone. - The session turned active. It stays active for 7 days.
- A message was sent through the inbox.
POST /v1/inbox/conversationsis the same call that messages any WhatsApp contact; here it used the sandbox account and template.
The sandbox allows one test phone, 50 messages a day and one template.
Your reply also opens a 24-hour window in which free-form text works (WhatsApp inbox).
To send to your customers, get a number of your own and connect it.
- The script listed your conversations.
GET /v1/inbox/conversationsreturns DMs from every connected account in one list, each with itsplatform,accountIdand last message. - You confirmed the recipient. Nothing is sent until you press Enter.
- A reply was sent.
POST /v1/inbox/conversations/{conversationId}/messagestakes the conversation'saccountIdand themessage. The200means accepted, not yet delivered.
In Node.js the Idempotency-Key header stops a retry from sending the reply twice. The Python client takes no key, so a retry from Python sends a second message (idempotency).
Each platform sets its own rules on when a business can message a person. The compare page shows what each one supports.
- A profile was created. A profile groups accounts: one per brand, or one per user of your app.
- Meta ads were connected.
GET /v1/connect/facebook/adsreturned the URL to approve, oralreadyConnectedwhen a connected Facebook account already carries the ads scopes. - The script found the ad account.
GET /v1/ads/accountslists the Meta ad accounts the connection can reach;accounts[].idis theadAccountIdfor every other ads call. - A campaign was created.
POST /v1/ads/campaignscreates the container without an ad set or an ad. It isPAUSEDunless you passstatus: "ACTIVE".
Budgets and bids are whole units of the ad account's currency (75 is $75.00 on a USD account), never cents.
Meta reviews every ad. A successful create means the ad exists, not that it delivers. The same /v1/ads endpoints cover 7 ad platforms.
The calls, one by one
The connecting accounts guide covers the connect call for every platform, and the API reference has each call with its response: create a profile, list accounts, create a post and get a post.
The sandbox guide has each of the four calls in Node.js, Python and curl with the response it returns, plus how to switch to another test phone.
The inbox guide has both calls in Node.js, Python and curl with their responses, plus the webhooks that push new messages to you.
The Meta Ads page has the connect and ad-account calls with their responses, and campaigns has the create call.
If it fails
A 409 means the same content is already scheduled or was posted to this account in the last 24 hours. Running the script twice causes it:
{
"error": "This exact content is already scheduled, publishing, or was posted to this account within the last 24 hours.",
"details": {
"accountId": "66b2e19d8c3f5a7e9d0b1c2d",
"platform": "linkedin",
"existingPostId": "65f1c0a9e2b5af0012ab34cd"
}
}Change the content, or send an x-request-id header so a retry returns the original post instead (idempotency).
Every error uses the same envelope, described in error handling.
A 400 when you start activation while another phone still has a session names that phone, so you can revoke it first:
{
"error": "You can only test one phone at a time. Revoke +13105551234 first",
"code": "invalid_field_value"
}The script stops with "No reply yet" when the session is still pending. Reply to the WhatsApp message and run it again, which resends the template.
The sandbox guide lists the other errors.
The script stops with "No conversations yet" when no connected account has received a DM. Send one to the account from another profile and run it again.
For send errors, the inbox guide lists each one and its fix.
A 422 with linked_account_required means the account cannot run ads.
Instagram. An account connected with the default Instagram Login never has ads scopes. Connect Facebook or Meta Ads in the same profile.
Older accounts. Accounts connected before ads were enabled do not carry the ads scopes either. Reconnect them.
The Meta Ads page lists the other errors.
Next steps
Media uploads
Add images and videos to a post.
Queue scheduling
Recurring time slots, so posts need no scheduledFor.
Webhooks
Get each status change pushed to you instead of polling.
Build a platform
One profile per user, scoped keys and webhook routing.
Before production
Error handling, with rate limits and idempotency alongside.
CLI
The same API from a terminal.
The same key serves the inbox, WhatsApp, phone numbers, ads, broadcasts, workflows, comment-to-DM automations and analytics.
WhatsApp sandbox
Every sandbox call, its limits and how to change the test phone.
Get your own number
Send to more than one recipient from a number you own.
Templates
Create and send your own approved templates.
Broadcasts
Send one template to a list of contacts.
Inbox
Read replies and answer inside the 24-hour window.
Webhooks
Get message.received pushed to you for each reply.
Inbox for your users
Write an inbox from webhooks, send replies and backfill history.
Inbox webhooks
Get message.received pushed to you instead of polling.
Compare DMs by platform
Attachments, quick replies, buttons and edits per platform.
Comments
Read and answer comments through the same inbox.
Workflows
Answer DMs and comments automatically with a graph of steps.
Idempotency
Make retries safe so a reply is never sent twice.
Create an ad
Add an ad set and an ad to the campaign you just created.
Boost a post
Turn a published post into an ad, keeping its likes and comments.
Targeting
Countries, cities, interests and audiences.
Meta Ads overview
Connections, billing, the campaign tree and every ads page.
Other ad platforms
Google, LinkedIn, TikTok, Pinterest, X, OpenAI, Reddit and Microsoft ads.
Ads webhooks
Get ad status changes pushed to you.
Introduction
Publish posts, run inboxes, send email, place calls and manage ads across every platform Zernio connects to, with one API. Start with the quickstart or pick a platform.
Build a platform
Give each of your customers a profile, connect their accounts into it, post on their behalf and route webhooks back to the right customer.