> ## Documentation Index
> Fetch the complete documentation index at: https://docs.refold.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Cron Schedule

This API updates a cron schedule for a workflow using schedule ID.

## Request description

#### Path Parameters

<ParamField path="schedule_id" type="string" required>
  ID of the schedule to be updated.
</ParamField>

#### Body

<ParamField body="trigger_type" type="string" required>
  The type of schedule trigger you want to set. Options are either `cron` or `interval`.
</ParamField>

<Info>
  Based on the trigger\_type provided, Request Body differs.
</Info>

<ParamField body="payload" type="object" required>
  Event Payload to be sent during workflow execution. Required in **both** trigger types.
</ParamField>

<ParamField body="regex" type="string" required>
  Cron expression. For Eg: \*/6 \* \* \* \*. Required in **cron** trigger type.
</ParamField>

<ParamField body="currentDate" type="string" required>
  Date currently. for Eg: 2025-01-15. Required in **cron** trigger type.
</ParamField>

<ParamField body="tz" type="string" required>
  Time Zone for the cron job. For Eg: Asia/Kolkata. Required in **cron** trigger type.
</ParamField>

<ParamField body="endDate" type="string" required>
  End Date for the cron job. For Eg: 2025-01-19. Required in **cron** trigger type.
</ParamField>

<ParamField body="startDate" type="string" required>
  Start date of the cron job. for Eg: 2025-01-16. Required in **cron** trigger type.
</ParamField>

<ParamField body="interval_dates" type="array" required>
  The dates in which schedule needs to be executed.Required in **interval** trigger type.

  <Expandable title="properties">
    <ResponseField name="date" type="object" required>
      Date for the schedule.

      <Expandable title="properties">
        <ResponseField name="day" type="string" required>
          Date of the object. Eg: "25"
        </ResponseField>

        <ResponseField name="month" type="string" required>
          Month of the object. Eg: "5"
        </ResponseField>

        <ResponseField name="year" type="string" required>
          Year of the date. Eg: "2025"
        </ResponseField>

        <ResponseField name="hour" type="string" required>
          Hour of the timestamp in 24 hr format. Eg: "21"
        </ResponseField>

        <ResponseField name="minute" type="string" required>
          Minute of the timestamp. Eg: "45"
        </ResponseField>

        <ResponseField name="second" type="string" required>
          Seconds of the timestamp. Eg: "30"
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="tz" type="string" required>
      Timezone to apply for the date.
    </ResponseField>
  </Expandable>
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl --request PUT \
    --url https://api.gocobalt.io/api/v1/workflow/public/scheduled/:schedule_id \
    --header 'Content-Type: application/json' \
    --header 'x-api-key: <api-key>' \
    --data '{
    "trigger_type": "<string>",
    "payload": {},
    "regex": "*/6 * * * *",
    "currentDate": "YYYY-MM-DD",
    "tz": "Asia/Kolkata",
    "endDate": "YYYY-MM-DD",
    "startDate": "YYYY-MM-DD",
    "interval_dates": [
          {
              "date": {
                  "day": 23,
                  "month": 1,
                  "year": 2025
                  "hour": 22,
                  "minute": 22,
                  "second": 22
              },
              "tz": "Asia/Kolkata"
          }
      ]
  }'
  ```
</RequestExample>

## Response description

<Tabs>
  <Tab title="200">
    <ResponseField name="_id" type="string">
      ID of the registered cron
    </ResponseField>

    <ResponseField name="event_id" type="string">
      Event ID
    </ResponseField>

    <ResponseField name="workflow" type="string">
      ID or Alias of the workflow
    </ResponseField>

    <ResponseField name="linked_account_id" type="string">
      Linked Account ID for which cron is registered
    </ResponseField>

    <ResponseField name="environment" type="string">
      Environment in which cron registered
    </ResponseField>

    <ResponseField name="org_id" type="string">
      Organization id
    </ResponseField>

    <ResponseField name="cron_pattern" type="string">
      Cron Pattern used for schedule register.
    </ResponseField>

    <ResponseField name="inactive" type="boolean">
      The schedule is inactive or not.
    </ResponseField>

    <ResponseField name="registered_by_api" type="boolean">
      Whether the cron is registered using API.
    </ResponseField>

    <ResponseField name="options" type="object">
      Cron body sent in the request

      <Expandable title="properties">
        <ResponseField name="currentDate" type="string">
          Date currently
        </ResponseField>

        <ResponseField name="endDate" type="string">
          End date for the schedule
        </ResponseField>

        <ResponseField name="startDate" type="string">
          Start date of the schedule
        </ResponseField>

        <ResponseField name="tz" type="string">
          Timezone for the schedule.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="trigger_interval" type="array">
      Array of the interval dates for which the schedule is registered. It is empty if cron trigger\_type is used.
    </ResponseField>

    <ResponseField name="schedule_added_at" type="string">
      Timestamp when schedule was added
    </ResponseField>

    <ResponseField name="updatedAt" type="string">
      Timestamp of schedule updation.
    </ResponseField>
  </Tab>

  <Tab title="Error">
    <ResponseField name="status_code" type="integer">
      System generated status Code
    </ResponseField>

    <ResponseField name="http_error_type" type="string">
      System generated error type
    </ResponseField>

    <ResponseField name="error_code" type="string">
      Code for the Error
    </ResponseField>

    <ResponseField name="message" type="string">
      Error message
    </ResponseField>
  </Tab>
</Tabs>

<ResponseExample>
  ```JSON 200 theme={null}
  {
      "_id": "67becf62f29636d291eaadc0",
      "event_id": "67becf62f29636d291eaadbf",
      "workflow": "663c73e4608a784bacac384a",
      "linked_account_id": "tim-cook",
      "environment": "test",
      "org_id": "65c9ef72f4b95fce32e8ccf8",
      "cron_patten": "*/6 * * * *",
      "inactive": false,
      "registered_by_api": true,
      "options": {
          "currentDate": "2025-02-26",
          "endDate": "2025-02-28",
          "startDate": "2025-02-27",
          "tz": "Asia/Kolkata"
      },
      "trigger_type": "cron",
      "trigger_interval": [],
      "schedule_added_at": "2025-02-26T08:22:58.080Z",
      "updatedAt": "2025-02-26T08:22:58.080Z"
  }
  ```

  ```JSON 400 theme={null}
  {
      "status_code": 400,
      "http_error_type": "BAD_REQUEST",
      "error_code": "SERVER_ERROR",
      "message": "Cron Job Could Not Be Added  , Regex Configuration failed to register"
  }
  ```
</ResponseExample>
