# Scheduled Activities

Scheduled activities let a user write an activity now and have it published later. Nothing is added to any feed until the publish time. At that moment the activity is published exactly as if it had been added with `addActivity` then: followers receive it, `feeds.activity.added` is sent, and notifications, mentions, activity processors and moderation run as for any other new activity.

>
> **Info:** Scheduled activities are off by default. [Contact support](https://getstream.io/contact/support/) to enable them for your app.
>

## How it works

1. You schedule an activity with the same fields you would send to `addActivity`, plus `scheduled_at`.
2. Stream stores the request and returns a scheduled activity with the status `scheduled`. The activity is not visible in any feed, and it is not returned by activity queries.
3. Until the publish time, the author (or your backend) can list, read, edit, cancel or publish the scheduled activity.
4. At the publish time, Stream adds the activity. The activity's `created_at` is the time it was published, not the time it was scheduled, so it sorts with other activities published at that time.
5. Once published, the scheduled activity is removed. The activity keeps the scheduled activity's `id`, so you can read it with `getActivity`.

## Scheduling an activity

Send the activity fields you would send to `addActivity`, plus `scheduled_at`, an RFC 3339 time.

```js label="React"
const response = await client.scheduleActivity({
  feeds: ["user:john"],
  type: "post",
  text: "Our new release is live!",
  scheduled_at: new Date("2026-11-02T09:00:00Z"),
});

console.log(response.scheduled_activity.id);
console.log(response.scheduled_activity.scheduled_at);
```

```js label="JavaScript"
const response = await client.scheduleActivity({
  feeds: ["user:john"],
  type: "post",
  text: "Our new release is live!",
  scheduled_at: new Date("2026-11-02T09:00:00Z"),
});

console.log(response.scheduled_activity.id);
console.log(response.scheduled_activity.scheduled_at);
```

A few rules apply to the request:

- **Publish time.** `scheduled_at` is rounded up to the next whole minute (UTC). A time that is in the past, or less than one minute away, is moved to the first whole minute at least one minute from now, so the activity is never published during the request. To publish immediately, use `addActivity` instead. The response contains the actual publish time in `scheduled_at`.
- **Maximum lead time.** `scheduled_at` can be at most 120 days in the future.
- **Same fields as `addActivity`.** Text, attachments, custom data, visibility, mentions, polls, collections, `parent_id`, `expires_at` and the other activity fields are supported. `skip_existing` and `enrich_own_fields` are not accepted. `expires_at`, when set, must be after `scheduled_at`.
- **Activity ID.** You can set `id` yourself. It becomes the published activity's ID. An ID that already belongs to an activity (including a deleted one) or to another scheduled activity is rejected. The ID of a failed or canceled scheduled activity can be reused by the same user. If you don't set `id`, one is generated.
- **Target feeds.** Feeds that don't exist yet are allowed and are created when the activity is published, as with `addActivity`. A feed that has been deleted is rejected with error 140, both when scheduling and when updating `activity`.
- **Validation happens now.** Permissions, bans, polls, parent activities and feed groups are checked when you schedule, so most mistakes are reported immediately rather than at publish time. They are checked again when the activity is published.

## Querying scheduled activities

Query returns scheduled activities ordered by `scheduled_at`, soonest first. You can filter by user, by feed and by status.

```js label="React"
// The current user's upcoming activities for one feed
const response = await client.queryScheduledActivities({
  filter: { fid: "user:john", status: ["scheduled"] },
  limit: 25,
});

console.log(response.scheduled_activities);

// Next page
if (response.next) {
  const nextPage = await client.queryScheduledActivities({
    filter: { fid: "user:john", status: ["scheduled"] },
    limit: 25,
    next: response.next,
  });
}
```

```js label="JavaScript"
// The current user's upcoming activities for one feed
const response = await client.queryScheduledActivities({
  filter: { fid: "user:john", status: ["scheduled"] },
  limit: 25,
});

console.log(response.scheduled_activities);

// Next page
if (response.next) {
  const nextPage = await client.queryScheduledActivities({
    filter: { fid: "user:john", status: ["scheduled"] },
    limit: 25,
    next: response.next,
  });
}
```

| Parameter        | Description                                                                                                         |
| ---------------- | ------------------------------------------------------------------------------------------------------------------- |
| `filter.user_id` | Only this user's scheduled activities. Server-side only: client-side requests always return the current user's own. |
| `filter.fid`     | Only scheduled activities that target this feed.                                                                    |
| `filter.status`  | Any of `scheduled`, `publishing` and `failed`. Without it, all three are returned.                                  |
| `limit`          | Page size, 1 to 100. Defaults to 25.                                                                                |
| `next`           | The `next` cursor from the previous response. The last page has no `next`.                                          |

To read one scheduled activity by its ID:

```js label="React"
const response = await client.getScheduledActivity({
  id: "scheduled-activity-id",
});

console.log(response.scheduled_activity.status);
```

```js label="JavaScript"
const response = await client.getScheduledActivity({
  id: "scheduled-activity-id",
});

console.log(response.scheduled_activity.status);
```

### The scheduled activity object

| Field            | Description                                                                                                                                                                                          |
| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`             | ID of the scheduled activity. The published activity gets the same ID.                                                                                                                               |
| `user_id`        | The author. The activity is published as this user.                                                                                                                                                  |
| `feeds`          | The feeds the activity will be added to.                                                                                                                                                             |
| `activity`       | A preview of the activity that will be published: `type`, `text`, `attachments`, `custom`, `visibility`, `expires_at` and the other request fields. It has no reactions, comments or timestamps yet. |
| `scheduled_at`   | When the activity will be published, rounded up to a whole minute.                                                                                                                                   |
| `status`         | `scheduled`, `publishing` or `failed`. See [Statuses](#statuses).                                                                                                                                    |
| `failure_reason` | Why the publish failed. Set only when `status` is `failed`. See [Failures](#failures).                                                                                                               |
| `created_at`     | When the activity was scheduled.                                                                                                                                                                     |
| `updated_at`     | When the scheduled activity was last changed.                                                                                                                                                        |

### Statuses

| Status       | Meaning                                                                                                                                                                  |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `scheduled`  | Waiting for its publish time. It can be edited, canceled or published now.                                                                                               |
| `publishing` | A publish attempt hit a temporary error and will be retried shortly. It can't be changed until the retry finishes, because the first attempt may already have succeeded. |
| `failed`     | The publish failed and won't be retried. It can't be changed. Failed scheduled activities are kept for 7 days, so you can show the author what went wrong.               |

A published scheduled activity is removed, so there is no `published` status. Read the activity with `getActivity` using the same ID. A canceled scheduled activity is not returned.

## Updating a scheduled activity

You can change the publish time, the activity, or both. `activity` replaces the whole activity, so send every field you want to keep. Its `id` and `user_id` can't change. The new `scheduled_at` follows the same rounding and lead-time rules as when scheduling.

```js label="React"
// Move the publish time
await client.updateScheduledActivity({
  id: "scheduled-activity-id",
  scheduled_at: new Date("2026-11-03T09:00:00Z"),
});

// Replace the content
await client.updateScheduledActivity({
  id: "scheduled-activity-id",
  activity: {
    feeds: ["user:john"],
    type: "post",
    text: "Our new release is live, with dark mode!",
  },
});
```

```js label="JavaScript"
// Move the publish time
await client.updateScheduledActivity({
  id: "scheduled-activity-id",
  scheduled_at: new Date("2026-11-03T09:00:00Z"),
});

// Replace the content
await client.updateScheduledActivity({
  id: "scheduled-activity-id",
  activity: {
    feeds: ["user:john"],
    type: "post",
    text: "Our new release is live, with dark mode!",
  },
});
```

## Canceling a scheduled activity

Deleting a scheduled activity cancels it: it is never published, and it is no longer returned by query or get.

```js label="React"
await client.deleteScheduledActivity({ id: "scheduled-activity-id" });
```

```js label="JavaScript"
await client.deleteScheduledActivity({ id: "scheduled-activity-id" });
```

## Publishing now

Publishing now moves the publish time to now. The activity is published in the background within a few seconds, not during the request, so wait for `feeds.scheduled_activity.published` (or `feeds.activity.added`) before reading it.

```js label="React"
await client.publishScheduledActivityNow({ id: "scheduled-activity-id" });
```

```js label="JavaScript"
await client.publishScheduledActivityNow({ id: "scheduled-activity-id" });
```

Only scheduled activities with the status `scheduled` can be updated, canceled or published now. A `publishing` one returns a 409 until the retry finishes, and a `failed` one returns a 400.

## Client-side and server-side requests

|                | Client-side                                         | Server-side                                                                   |
| -------------- | --------------------------------------------------- | ----------------------------------------------------------------------------- |
| Author         | Always the connected user. `user_id` is ignored.    | `user_id` is required. `create_users: true` creates the user if it's missing. |
| Query, get     | Only the connected user's own scheduled activities. | Any user's. Filter with `filter.user_id`.                                     |
| Update, cancel | Only the connected user's own. Others' return 404.  | Any user's.                                                                   |
| Moderation     | Runs at publish time.                               | Runs at publish time only when `force_moderation` is `true`.                  |

A client-side scheduled activity is published as its author without a token, so revoking the user's token does not cancel it. Bans and permission changes made after scheduling do apply: the publish fails with `banned` or `no_permission`.

## Moderation

Moderation runs when the activity is published, not when it is scheduled, so the content is checked once, as it is published. The outcome is the same as for an activity added at that time: a bounced activity is not published and the scheduled activity fails with `moderation_blocked`, while flag, mask, shadow block and remove behave as they do for `addActivity`. See [Moderation](https://getstream.io/activity-feeds/docs/react/moderation/).

## Failures

If a scheduled activity can't be published, its status becomes `failed`, `failure_reason` says why, and `feeds.scheduled_activity.failed` is sent.

| Reason               | Cause                                                                                                     |
| -------------------- | --------------------------------------------------------------------------------------------------------- |
| `user_deleted`       | The author was deleted or deactivated.                                                                    |
| `feed_deleted`       | A target feed was deleted. Deleting a feed also fails the scheduled activities that target it right away. |
| `banned`             | The author is banned.                                                                                     |
| `no_permission`      | The author can no longer add activities to a target feed.                                                 |
| `moderation_blocked` | Moderation bounced the activity.                                                                          |
| `id_conflict`        | Another activity with the same ID was created in the meantime.                                            |
| `expired`            | The activity's `expires_at` had passed by the publish time.                                               |
| `invalid_activity`   | The activity is no longer valid, for example because its feed group was deleted.                          |
| `internal_error`     | Publishing kept failing with temporary errors and was given up after several attempts.                    |

Temporary errors are retried automatically, and the status is `publishing` while a retry is pending. If publishing is delayed, the activity is still published when it catches up, never dropped for being late.

## Events

| Event                                | When                                                                   | WebSocket | Webhook |
| ------------------------------------ | ---------------------------------------------------------------------- | --------- | ------- |
| `feeds.scheduled_activity.created`   | An activity was scheduled                                              | Yes       | No      |
| `feeds.scheduled_activity.updated`   | A scheduled activity was updated or published now                      | Yes       | No      |
| `feeds.scheduled_activity.deleted`   | A scheduled activity was canceled                                      | Yes       | No      |
| `feeds.scheduled_activity.published` | The activity was published                                             | Yes       | Yes     |
| `feeds.scheduled_activity.failed`    | The activity could not be published. The event has a `failure_reason`. | Yes       | Yes     |

Every event carries the `scheduled_activity` object and the author as `user`. In `feeds.scheduled_activity.deleted`, the object's `status` is `canceled`, and in `feeds.scheduled_activity.published` it is `publishing`, the status it had while being published. WebSocket events go only to the author's own connections, not to feed watchers. Apps that use server-side-only feeds don't receive the WebSocket events, but still receive the `published` and `failed` webhooks.

```js label="React"
client.on("feeds.scheduled_activity.published", (event) => {
  if (event.type === "feeds.scheduled_activity.published") {
    console.log("Published", event.scheduled_activity.id);
  }
});

client.on("feeds.scheduled_activity.failed", (event) => {
  if (event.type === "feeds.scheduled_activity.failed") {
    console.log("Failed", event.scheduled_activity.id, event.failure_reason);
  }
});
```

```js label="JavaScript"
client.on("feeds.scheduled_activity.published", (event) => {
  if (event.type === "feeds.scheduled_activity.published") {
    console.log("Published", event.scheduled_activity.id);
  }
});

client.on("feeds.scheduled_activity.failed", (event) => {
  if (event.type === "feeds.scheduled_activity.failed") {
    console.log("Failed", event.scheduled_activity.id, event.failure_reason);
  }
});
```

When the activity is published, followers and feed watchers also receive the usual `feeds.activity.added` event. In rare cases, such as a retry after a temporary error, `feeds.activity.added` can arrive twice, so deduplicate it by activity ID. `feeds.scheduled_activity.published` is sent once, after the activity is published.

## Limits

| Limit                       | Default                                                                      |
| --------------------------- | ---------------------------------------------------------------------------- |
| Pending activities per user | 100. Scheduled activities with the status `scheduled` or `publishing` count. |
| Maximum lead time           | 120 days                                                                     |
| Publish time precision      | Whole minutes, at least one minute after the request                         |
| Failed activities kept for  | 7 days                                                                       |

If you need different limits, [contact support](https://getstream.io/contact/support/).

If scheduled activities are disabled for your app later, scheduling, updating and publishing now are rejected, while query, get and cancel keep working. Activities that were already scheduled are still published.

## Errors

Scheduled activity errors carry a `reason` in `exception_fields`, so you can handle them without relying on the numeric code.

| Code | HTTP | Reason                             | Cause                                                                                          |
| ---- | ---- | ---------------------------------- | ---------------------------------------------------------------------------------------------- |
| 133  | 400  | `scheduled_activities_disabled`    | Scheduled activities are not enabled for your app.                                             |
| 134  | 400  | `scheduled_activity_limit_reached` | The user already has the maximum number of pending scheduled activities.                       |
| 135  | 400  | `scheduled_at_too_far`             | `scheduled_at` is further ahead than the maximum lead time.                                    |
| 136  | 400  | `scheduled_at_invalid`             | `scheduled_at` is missing or invalid.                                                          |
| 137  | 400  | `scheduled_activity_id_taken`      | The `id` already belongs to an activity or to another scheduled activity.                      |
| 138  | 404  | `scheduled_activity_not_found`     | No scheduled activity with this ID, or it was canceled, published, or belongs to another user. |
| 139  | 409  | `scheduled_activity_publishing`    | The scheduled activity is being published and can't be changed right now.                      |
| 140  | 400  | `scheduled_activity_feed_deleted`  | A target feed was deleted. `exception_fields.feed_id` names the feed.                          |

---

For the most recent version of this documentation, visit [https://getstream.io/activity-feeds/docs/react/scheduled-activities/](https://getstream.io/activity-feeds/docs/react/scheduled-activities/).