younifyd
Menu

Create Schedule

Create schedule

POST/schedules/{projectId}/{dataset}

Use it in a workflow

  1. Add a step and choose the Sanity connector.
  2. Pick the Create Schedule action (under Scheduling).
  3. Fill in the fields below, then reference the result from later steps as {{createSchedule.response.data}}.

Request

Path parameters

projectIdstringrequired

Project ID

datasetstringrequired

Dataset name

Request body

Enter the body as JSON in the step's Body field.

documentsarray<object>required

Array of documents to be published or unpublished

documentIdstringrequired

The ID of the document to be published or unpublished. Must be a published (non-draft) document ID. Draft IDs, which start with `drafts.`, are rejected.

ifRevisionIdstring

Optional revision ID that must match the document's _rev value in order to proceed with the publish or unpublish action

namestringrequired

A custom name for the schedule. Make it human-readable and understandable

descriptionstring

A custom description for the schedule. It helps understand the purpose of the schedule

executeAtstring (date-time)required

When the schedule should execute. Must be in the future. Must be in UTC format with Z suffix (YYYY-MM-DDTHH:mm:ss.sssZ)

actionstring

The action to perform. Defaults to 'publish' if not specified

One ofpublishunpublishDefault "publish"

json
{
  "documents": [
    {
      "documentId": "f28fe6ce-0454-42c2-8a9a-c469fbf79281",
      "ifRevisionId": "string"
    }
  ],
  "name": "December 2077 release",
  "executeAt": "2077-12-25T19:45:00.000Z",
  "description": "Documents to publish at the end of 2077",
  "action": "publish"
}

Response

Returns 200 with an object. Read it in later steps with {{createSchedule.response.data.<field>}}.

idstring

Unique identifier for the schedule

namestring

A custom name for the schedule. Make it human-readable and understandable

descriptionstring

A custom description for the schedule. It helps understand the purpose of the schedule

projectIdstring

The ID of the project this schedule belongs to

datasetstring

The dataset this schedule operates on

authorstring

The ID of the user who created the schedule

actionstring

The action the schedule performs when it executes

One ofpublishunpublish

statestring

The current state of the schedule

One ofscheduledexecutingsucceededcancelled

stateReasonstring

Explanation of the current state

documentsarray<object>

List of documents to be published or unpublished

documentIdstring

The ID of the document

documentTypestring

The type of the document

ifRevisionIdstring

The revision ID of the document

createdAtstring (date-time)

When the schedule was created

executeAtstring (date-time)

When the schedule is planned to execute

executedAtstring (date-time)

When the schedule was actually executed (if applicable)

transactionIdstring

ID of the transaction that executed the schedule (if applicable)

json
{
  "id": "sch-28MRSuc1Ij4xtNa1rNbhTlMAszj",
  "name": "March update",
  "description": "string",
  "projectId": "hb6nr9ev",
  "dataset": "production",
  "author": "poLhU1V3X",
  "action": "publish",
  "state": "scheduled",
  "stateReason": "execution completed",
  "documents": [
    {
      "documentId": "f28fe6ce-0454-42c2-8a9a-c469fbf79281",
      "documentType": "article",
      "ifRevisionId": "string"
    }
  ],
  "createdAt": "2022-04-27T01:54:31.536236Z",
  "executeAt": "2022-04-27T01:55:00Z"
}

Need more? See the Sanity guide for connection setup and behaviour shared by every action.