Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ending_at to schedule docs #760

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions content/concepts/schedules.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const schedules = await knock.workflows.createSchedules("park-alert", {
minutes: 30,
},
],
ending_at: "2024-01-02T10:00:00Z", // Schedule will stop after this date
data: { type: "dinosaurs-loose" },
tenant: "jpark",
});
Expand All @@ -63,23 +64,25 @@ const knock = new Knock(process.env.KNOCK_API_KEY);

const schedules = await knock.workflows.createSchedules("park-alert", {
recipients: ["jhammond", "esattler", "dnedry"],
scheduled_at: "2023-12-22 17:45:00Z",
scheduled_at: "2023-12-22T17:45:00Z",
ending_at: "2023-12-31T23:59:59Z", // Schedule will not execute after this time
data: { type: "dinosaurs-loose" },
tenant: "jpark",
});
```

### Schedule properties

| Variable | Type | Description |
| -------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `recipients` | RecipientIdentifier[] | One or more recipient identifiers, or complete recipients to be upserted. |
| `workflow` | string | The workflow to trigger. |
| `repeats` | ScheduleRepeat[] | A list of one or more repeats (see below). Required if you're creating a recurring schedule. |
| `data` | map | Custom data to pass to every workflow trigger. |
| `tenant` | string | A tenant to pass to the workflow trigger. |
| `actor` | RecipientIdentifier | An identifier of an actor, or a complete actor to be upserted. |
| `scheduled_at` | utc_datetime | A UTC datetime in ISO-8601 format representing the start moment for the recurring schedule, or the exact and only execution moment for the non-recurring schedule. |
| Variable | Type | Description |
| -------------- | --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `recipients` | RecipientIdentifier[] | One or more recipient identifiers, or complete recipients to be upserted. |
| `workflow` | string | The workflow to trigger. |
| `repeats` | ScheduleRepeat[] | A list of one or more repeats (see below). Required if you're creating a recurring schedule. |
| `data` | map | Custom data to pass to every workflow trigger. |
| `tenant` | string | A tenant to pass to the workflow trigger. |
| `actor` | RecipientIdentifier | An identifier of an actor, or a complete actor to be upserted. |
| `scheduled_at` | utc_datetime | A UTC datetime in ISO-8601 format representing the start moment for the recurring schedule, or the exact and only execution moment for the non-recurring schedule. |
| `ending_at` | utc_datetime | A UTC datetime in ISO-8601 format that indicates when the schedule should end. Once the current schedule time passes `ending_at`, no further occurrences will be scheduled. |

<Callout
emoji="🚨"
Expand Down Expand Up @@ -192,6 +195,7 @@ const knock = new Knock(process.env.KNOCK_API_KEY);

const schedules = await knock.workflows.updateSchedules({
schedule_ids: workflowScheduleIds,
ending_at: "2024-06-01T00:00:00Z", // Update when the schedule should end
data: { foo: "bar" },
});
```
Expand Down Expand Up @@ -289,6 +293,14 @@ Knock supports a `timezone` property on the recipient that automatically makes a
<Accordion title="Can I model exclusion rules in my repeat logic?">
Currently no, but we'll be looking to add this feature in the near future.
</Accordion>
<Accordion title="How does the ending_at parameter work with schedules?">
The `ending_at` parameter allows you to set an expiration time for both
recurring and one-off schedules. For recurring schedules, no new occurrences
will be scheduled after the `ending_at` time is reached. For one-off
schedules, the schedule will not execute if the `scheduled_at` time is after
the `ending_at` time. The `ending_at` time must be specified in UTC ISO-8601
format, for example: "2024-01-02T10:00:00Z".
</Accordion>
<Accordion title="Can I change a recurring schedule to be non-recurring?">
Yes, you can update the schedule to change from recurring to non-recurring
(or vice versa). This can be done by removing the `repeats` property and
Expand Down
Loading