> ## Documentation Index
> Fetch the complete documentation index at: https://docs.postlybee.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Node.js SDK

> Use the official PostlyBee package from Node.js and TypeScript.

The `postlybee` package wraps the core posts, media, and connected-account endpoints. The constructor accepts the raw workspace API key and adds the Bearer prefix automatically.

## Install

```bash theme={null}
npm install postlybee
```

## Initialize

```typescript theme={null}
import Postlybee from 'postlybee';

const client = new Postlybee(process.env.POSTLYBEE_API_KEY!);
```

Self-hosted installations can pass a custom backend origin as the second argument:

```typescript theme={null}
const client = new Postlybee(
  process.env.POSTLYBEE_API_KEY!,
  'https://api.example.com'
);
```

## Available methods

| Method                    | Description                                         |
| ------------------------- | --------------------------------------------------- |
| `post(payload)`           | Create drafts, scheduled posts, or immediate posts. |
| `postList(filters)`       | List posts within a UTC date range.                 |
| `upload(file, extension)` | Upload an image buffer.                             |
| `integrations()`          | List connected social accounts.                     |
| `deletePost(id)`          | Delete a root post and its group.                   |

## Schedule a post

```typescript theme={null}
const accounts = await client.integrations();

const result = await client.post({
  type: 'schedule',
  date: '2030-01-15T09:00:00.000Z',
  shortLink: false,
  tags: [],
  posts: [
    {
      integration: { id: accounts[0].id },
      value: [{ content: 'Scheduled from Node.js', image: [] }],
      settings: {},
    },
  ],
});
```

<Warning>
  Use the SDK from trusted server-side code. Do not bundle a workspace API key
  into a browser or mobile application.
</Warning>
