# Zernio — integrate into the codebase

You are a coding agent integrating Zernio into your user's project. This assumes
`ZERNIO_API_KEY` is already set (if not, do `https://zernio.com/auth.md` first).

Zernio is a REST API for scheduling social media posts and unified messaging
across 15+ platforms (TikTok, Instagram, WhatsApp, Facebook, YouTube, LinkedIn,
X, Threads, Reddit, Pinterest, Bluesky, Google Business, Telegram, Snapchat,
Discord), plus ads across 6 networks.

- Base URL: `https://zernio.com/api/v1`
- Auth: `Authorization: Bearer $ZERNIO_API_KEY` on every request
- Full machine-readable surface: `https://zernio.com/llms.txt`
- OpenAPI spec: `https://zernio.com/openapi.yaml`

The SDK names, method names, and request shapes below are exact. Do not guess
variants (the package is `@zernio/node`, not `zernio-sdk`; the Node method is
`posts.createPost`, the Python method is `posts.create`). If unsure, read the
SDK's own README or `https://zernio.com/llms.txt`.

## Step 1 — Detect the stack and install the SDK

Pick the SDK that matches the project's primary language. If none fits, call the
REST API directly with the project's HTTP client.

**Node.js / TypeScript**

```bash
npm install @zernio/node
```

**Python**

```bash
pip install zernio-sdk
```

**Java (Maven)**

```xml
<dependency>
  <groupId>com.zernio</groupId>
  <artifactId>zernio-sdk</artifactId>
  <version>LATEST</version>
</dependency>
```

For Java, follow the call shapes in `https://zernio.com/llms.txt` (the REST
section below maps 1:1 to the SDK).

## Step 2 — Initialize the client

Both SDKs read `ZERNIO_API_KEY` from the environment by default. Never hardcode
the key. Confirm `.env` is gitignored.

**Node.js / TypeScript**

```ts
import Zernio from "@zernio/node";

// Reads process.env.ZERNIO_API_KEY by default.
// Or pass it explicitly: new Zernio({ apiKey: process.env.ZERNIO_API_KEY })
const zernio = new Zernio();
```

**Python**

```python
from zernio import Zernio

# Reads ZERNIO_API_KEY by default. Or: Zernio(api_key="...")
client = Zernio()
```

## Step 3 — Verify with a read-only call

Confirm auth and connectivity with a safe call that does not publish anything.
Posts target connected social accounts, so you also need an `accountId` from
here before you can create a post.

**Node.js / TypeScript**

```ts
const { data } = await zernio.accounts.listAccounts();
console.log(data); // each account has an `id` (the accountId) and `platform`
```

**Python**

```python
data = client.accounts.list()
for account in data["accounts"]:
    print(account["platform"], account["id"])
```

**REST**

```bash
curl -sS https://zernio.com/api/v1/accounts \
  -H "Authorization: Bearer $ZERNIO_API_KEY"
```

## Step 4 — Create a post

> This publishes or schedules real content. Use `scheduledFor` (a future time)
> or omit timing to create a draft while testing. `publishNow: true` posts
> immediately. `platforms` must reference real `accountId`s from Step 3.

**Node.js / TypeScript** — method is `posts.createPost`, args go under `body`.
The SDK returns `{ data }`, and the created post is nested under `data.post`
with a Mongo-style `_id`:

```ts
const { data } = await zernio.posts.createPost({
  body: {
    content: "Hello from Zernio",
    platforms: [{ platform: "twitter", accountId: "acc_xxx" }],
    scheduledFor: "2026-02-01T10:00:00Z",
  },
});

console.log(data.post._id, data.post.status);
```

**Python** — method is `posts.create`, snake_case kwargs. The response nests the
post under `["post"]` with a Mongo-style `_id`:

```python
result = client.posts.create(
    content="Hello from Zernio",
    platforms=[{"platform": "twitter", "accountId": "acc_xxx"}],
    scheduled_for="2026-02-01T10:00:00Z",
)

print(result["post"]["_id"], result["post"]["status"])
```

**REST (any language)** — note `content` (not `text`) and the `platforms`
objects:

```bash
curl -sS -X POST https://zernio.com/api/v1/posts \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "content": "Hello from Zernio",
    "platforms": [{ "platform": "twitter", "accountId": "acc_xxx" }],
    "scheduledFor": "2026-02-01T10:00:00Z"
  }'
```

The response wraps the created post: `{ "post": { "_id": "...", "status": "...", ... } }`.

## Next steps

If the user has no connected accounts yet, they must connect them in the Zernio
dashboard (`https://zernio.com`) before posts can publish.

For the full endpoint surface (media uploads, scheduling, inbox/messaging,
analytics, ads), read `https://zernio.com/llms.txt`.
