OverviewPlatformsAPI ReferenceResources

Queue scheduling

Give a profile recurring posting slots and create posts with queuedFromProfile so each one lands on the next free slot.


Give a profile recurring slots and create posts with queuedFromProfile: each lands on the next free one, so 50 posts need no scheduledFor values.

Before you start

You need an API key, a profile id (create a profile) and a connected account.

Create a queue

Call POST /v1/queue/slots with profileId, name, timezone and slots. Each slot is a dayOfWeek (0 is Sunday, 6 is Saturday) and a 24-hour time.

TypeScript
import Zernio from '@zernio/node';

const zernio = new Zernio();
const profileId = '66a1f0c2a4b9d3e8f1a2b3c4';

const { data: queue } = await zernio.queue.createQueueSlot({
  body: {
    profileId,
    name: 'Weekday mornings',
    timezone: 'America/New_York',
    slots: [
      { dayOfWeek: 1, time: '09:00' },
      { dayOfWeek: 3, time: '09:00' },
      { dayOfWeek: 5, time: '09:00' }
    ]
  }
});

const queueId = queue.schedule._id;

Response (201):

JSON
{
  "success": true,
  "schedule": {
    "_id": "66d5e3bf9a1c2d4e6f7a8b9c",
    "profileId": "66a1f0c2a4b9d3e8f1a2b3c4",
    "name": "Weekday mornings",
    "timezone": "America/New_York",
    "slots": [
      { "dayOfWeek": 1, "time": "09:00" },
      { "dayOfWeek": 3, "time": "09:00" },
      { "dayOfWeek": 5, "time": "09:00" }
    ],
    "active": true,
    "isDefault": true
  },
  "nextSlots": [
    "2027-01-04T09:00:00-05:00",
    "2027-01-06T09:00:00-05:00"
  ]
}
  • GET /v1/queue/slots?profileId=...: the default queue and its next slots. all=true lists every queue on the profile.
  • Update or delete slots: the queue endpoints.

Queue a post

Call POST /v1/posts with queuedFromProfile set to the profile id and no scheduledFor. Zernio locks the next free slot; repeat per post and each takes the slot after the previous one.

TypeScript
const { data: queued } = await zernio.posts.createPost({
  body: {
    content: 'Post 1 of 50',
    platforms: [
      { platform: 'linkedin', accountId: '66b2e19d8c3f5a7e9d0b1c2d' }
    ],
    queuedFromProfile: profileId
  }
});

console.log(queued.post.scheduledFor);

Response (201):

JSON
{
  "message": "Post scheduled successfully",
  "post": {
    "_id": "65f1c0a9e2b5af0012ab34cd",
    "content": "Post 1 of 50",
    "status": "scheduled",
    "scheduledFor": "2027-01-04T14:00:00Z",
    "timezone": "America/New_York",
    "queuedFromProfile": "66a1f0c2a4b9d3e8f1a2b3c4",
    "queueId": "66d5e3bf9a1c2d4e6f7a8b9c",
    "platforms": [
      { "platform": "linkedin", "status": "pending" }
    ]
  }
}

Preview the next slot

To show when a post would publish, call GET /v1/queue/next-slot with profileId. Add queueId for a specific queue.

TypeScript
const { data: next } = await zernio.queue.getNextQueueSlot({
  query: { profileId }
});

console.log(next.nextSlot);

Response (200):

JSON
{
  "profileId": "66a1f0c2a4b9d3e8f1a2b3c4",
  "nextSlot": "2027-01-06T09:00:00-05:00",
  "timezone": "America/New_York",
  "queueId": "66d5e3bf9a1c2d4e6f7a8b9c",
  "queueName": "Weekday mornings"
}

Do not pass nextSlot as scheduledFor: that skips the queue lock, so 2 concurrent creates can land on the same slot. Use queuedFromProfile and let Zernio assign the time.

How it behaves

  • Several queues per profile. Call POST /v1/queue/slots again with the same profileId and a different name.
  • Default queue. The first queue a profile gets is its default; later ones are not until a PUT /v1/queue/slots with setAsDefault: true moves the flag.
  • Targeting. Pass queueId next to queuedFromProfile for a specific queue. Without it, the post goes to the default queue.

If it fails

ErrorCauseFix
409 queue_slot_conflict on PUT /v1/posts/{postId}The new scheduledFor is taken by another post in the same queue.Pick a free time, drop scheduledFor so the queue assigns the next open slot, or send queueId: null to schedule outside the queue.
404 on GET /v1/queue/next-slotNo queue, or no free slot.Create a queue or add slots.
400 on GET /v1/queue/next-slotQueue inactive (active: false) or a bad parameter.Activate it or fix the parameter.
400 on POST /v1/queue/slotsMalformed slot.time must match HH:mm; dayOfWeek must be 0 to 6.

The 409 body:

JSON
{
  "error": "This time slot is already taken in this queue. Choose a different time, send queuedFromProfile without scheduledFor to let the queue assign the next open slot, or send queueId: null to schedule this post outside the queue.",
  "type": "invalid_request_error",
  "code": "queue_slot_conflict",
  "param": "scheduledFor"
}

The queue endpoints list every response.

Was this page helpful?

On this page