Skip to documentation

@lumopilot/sdk

Publish from your own code.

Use the LumoPilot JavaScript and TypeScript SDK to list connected accounts, schedule posts, or publish immediately from your server.

Start the quickstart

Quickstart

Use Node.js with built-in fetch (Node.js 18+) and an ESM project. You’ll need an active paid LumoPilot account and a connected social account.

  1. Connect a test social account under Settings → Connected Accounts.
  2. Open Developer settings, create an API key, and store it in your server’s LUMOPILOT_API_KEY environment variable.
  3. Once the npm beta is published, install the package and save the example as schedule.mjs. Set LUMOPILOT_TEST_SCHEDULED_AT to a future ISO 8601 timestamp with a timezone, select your connected platform, and run node schedule.mjs.
Install command
npm install @lumopilot/sdk@beta

schedule.mjs
import { LumoPilot, LumoPilotError } from '@lumopilot/sdk';

// Use the same job ID and scheduled time if your job runs again.
export async function scheduleAnnouncement(jobId, scheduledAt) {
  const apiKey = process.env.LUMOPILOT_API_KEY;
  if (!apiKey) {
    console.warn('LumoPilot: API key is missing.');
    return { ok: false, warning: 'missing_api_key' };
  }

  let operation = 'accounts.list';
  try {
    const client = new LumoPilot({ apiKey });
    const accounts = await client.accounts.list();
    const account = accounts.find(a => a.platform === 'linkedin');
    if (!account) {
      console.warn('LumoPilot: connect a LinkedIn account first.');
      return { ok: false, warning: 'missing_account' };
    }

    operation = 'posts.schedule';
    const post = await client.posts.schedule({
      accountIds: [account.id],
      caption: 'Our next release is coming soon.',
      scheduledAt,
      idempotencyKey: jobId,
    });
    return { ok: true, postId: post.id, status: post.status };
  } catch (error) {
    const status = error instanceof LumoPilotError ? error.status : undefined;
    console.warn('LumoPilot request failed', { operation, status });
    return { ok: false, warning: 'request_failed', status };
  }
}

// Use a fixed future timestamp for this test job.
const result = await scheduleAnnouncement(
  'announcement-test-001',
  process.env.LUMOPILOT_TEST_SCHEDULED_AT,
);
console.log(result);

Keep the key in a server-side secret store. Use a test account and review the scheduled post in LumoPilot. Each new post needs its own job ID.

API reference

new LumoPilot(options)
apiKey is required. Optional baseUrl overrides the default API origin (https://api.lumopilot.com). Optional fetch supplies a custom implementation.
accounts.list()
Returns Promise<SocialAccount[]>. Each account has an id, platform, and nullable handle and displayName. An empty array means no connected accounts were found.
posts.schedule(input)
Returns Promise<Post>. Provide a future scheduledAt as a Date or an ISO 8601 string with a timezone.
posts.publish(input)
Returns Promise<Post> for an immediate publishing attempt. Check the returned status before showing success.

Post input

TypeScript publish example
import type { PostInput } from '@lumopilot/sdk';

const input: PostInput = {
  accountIds: [accountId], // Use an ID from accounts.list().
  caption: 'Our release is live.',
  idempotencyKey: 'release-announcement-001',
};
// Inside your integration's try/catch:
const post = await client.posts.publish(input);

  • caption: string and accountIds: string[] are required. Use distinct IDs from accounts.list().
  • contentType accepts text, image, video, or carousel and defaults to text.
  • mediaIds?: string[] references assets already in your LumoPilot media library. Supported formats depend on the destination.
  • tags?: string[] and contentPillar?: string are optional.
  • idempotencyKey?: string identifies one logical post within your LumoPilot account. Use at most 120 characters.

Post result

A result includes id, status, caption, contentType, createdAt, and nullable scheduledAt. Timestamps are ISO 8601 strings.

scheduled means the post is queued. publishing means processing is in progress. published and failed are aggregate outcomes. Review individual destinations in LumoPilot before resending a post with an uncertain or failed outcome.

Errors and retries

  • 401: Check that your key is set and hasn’t been revoked. Create a replacement in Developer settings if needed.
  • 403: Check that your paid subscription is active.
  • Rejected input: Check the target account IDs, media IDs, and schedule time. Correct the request before retrying.
  • Timeout or connection loss: The API may have received the request. Check LumoPilot for the original post before resending. If retrying the same operation, reuse the original job ID and payload.

API response errors reject with LumoPilotError, which exposes an HTTP status and a GraphQL errors array. A GraphQL error can arrive with HTTP 200. Local configuration and network failures can reject with other error types.

Catch failures at your integration boundary. Keep the rest of your app running, show a clear warning, and log the operation and status. Keep authorization headers, keys, captions, and raw payloads out of your logs.

Developer support

For recurring failures, open Developer settings and submit an SDK issue. Choose the operation and symptom so LumoPilot can investigate. Save the report ID for follow-up.

Report an issue in LumoPilot