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

# Scheduler API

export const LwTemplate = ({title = "Key questions to get you started", icon = "sparkles", cta = "Powered by Agent Studio", linkHref = "https://lucidworks.com/demo/?utm_source=docs&utm_medium=referral&utm_campaign=docs_cta_ai"}) => {
  const [isLoaded, setIsLoaded] = useState(false);
  useEffect(() => {
    const timer = setTimeout(() => {
      setIsLoaded(true);
    }, 500);
    return () => clearTimeout(timer);
  }, []);
  return <div className="lw-template-container">
      <Card title={title} icon={icon}>
        {isLoaded && <span dangerouslySetInnerHTML={{
    __html: `<lw-template id="a029c1a9-28be-427e-b0e1-5d918920246a"></lw-template
            >`
  }} />}
        <Link href={linkHref} className="agent-studio-link text-left text-gray-600 gap-2 dark:text-gray-400 text-sm font-medium flex flex-row items-center hover:text-primary dark:hover:text-primary-light group-hover:text-primary group-hover:dark:text-primary-light">Powered by Lucidworks Agent Studio</Link>
      </Card>
    </div>;
};

[localhost link]: http://localhost:3000/docs/4/fusion-server/reference/api/scheduler-api

[mintlify link]: https://doc.lucidworks.com/docs/4/fusion-server/reference/api/scheduler-api

[old doc.lw link]: https://doc.lucidworks.com/fusion/5.9/330

The scheduler REST API is used to define a schedule for system activities and manage the jobs that result from the schedule.

<Note>
  This API is deprecated in favor of the [Jobs API](/docs/4/fusion-server/reference/api/jobs-api).
</Note>

All of the Fusion services are available for scheduling, as are any Solr activities and any other HTTP-based URI.

See [Jobs and Schedules](/docs/4/fusion-server/concepts/jobs/overview) for more information about all of the options available for scheduling, and instructions for configuring scheduler jobs using the Fusion UI.

<LwTemplate />

## Schedule Definition Properties

| Parameter                    | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| id<br /> *Required*          | The ID of the schedule. This is required when creating a schedule with a POST request.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| creatorType<br /> *Optional* | The type of user that created the schedule. If you have resources creating schedules programmatically, you could define a type that helps distinguish those schedules from others created by people.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| creatorId<br /> *Optional*   | An ID for the user that created the schedule.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| startTime<br /> *Optional*   | A time when the schedule should be started. If this is not set, it will be set to the date/time when the schedule was created.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| endTime<br /> *Optional*     | A time when the schedule should be terminated, i.e., when it will not run any more in the future. If not set, the schedule will run until it is disabled (i.e., "active" is set to false) or deleted.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| repeatUnit<br /> *Optional*  | A unit of time that when combined with the interval property defines how often the schedule will run. Allowed values are: <br />• "millisecond" or "ms"<br />• "second" or "sec"<br />• "minute" or "min"<br />• "hour" or "hr"<br />• "day"<br />• "week"<br />• "month"<br /> These time units are not case sensitive.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| interval<br /> *Optional*    | An integer that when combined with the repeatUnit property defines how often the schedule will run. If this is not set, or set to a number lower than '1' (i.e., '0'), the schedule will only be run once.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| active<br /> *Optional*      | If **true**, the schedule will be executed according to the defined interval. If **false**, the schedule will be disabled and will not run at the defined time.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| callParams<br /> *Required*  | The callParams define the API call to execute at the defined time intervals. It allows several properties: <br />• **uri.** A fully-qualified service URI. This can be an HTTP call, a Solr request, or a Fusion service call. Supported URI schemas are: <br />• `http://` or `https://`<br />• `solr://\{collection\}/…​` A SolrCloud request. <br />• `service://\{serviceName\}/\{path\}` A load-balanced Fusion service request. <br /> <br />• **method.** The method to use, as in GET, POST, PUT, or DELETE.<br />• **queryParams.** Query parameters to be passed with the request. For Solr calls, this could be parameters such as "q", "fq", "commit", etc.<br />• **headers.** Any additional protocol headers, such as "Content-type".<br />• **entity.** An optional payload to be sent with the request. |

## Examples

*Run a crawl of the datasource "LocalDocs2" every day:*

**REQUEST**

```bash wrap  theme={"dark"}
curl -u USERNAME:PASSWORD -X POST -H 'Content-Type: application/json' -d '{"id":"1", "creatorType":"human", "creatorId":"admin1", "repeatUnit":"DAY", "interval":1, "active":true, "callParams":{"uri":"service://connectors/jobs/LocalDocs2", "method":"POST"}}' https://FUSION_HOST:8764/api/scheduler/schedules
```

**RESPONSE**

```json wrap  theme={"dark"}
{
  "id" : "1",
  "trigger" : "1_1400007488512_-9223372036854775808",
  "schedule" : {
    "id" : "1",
    "creatorType" : "human",
    "creatorId" : "admin1",
    "createTime" : "2014-05-13T18:58:08.512Z",
    "startTime" : "2014-05-13T18:58:08.512Z",
    "endTime" : null,
    "repeatUnit" : "DAY",
    "interval" : 1,
    "active" : true,
    "callParams" : {
      "uri" : "service://connectors/jobs/LocalDocs2",
      "method" : "POST",
      "queryParams" : { },
      "headers" : { },
      "entity" : null
    }
  }
}
```

*Issue a commit to the SolrCloud collection "demo" every hour:*

**REQUEST**

```bash wrap  theme={"dark"}
curl-u USERNAME:PASSWORD -X POST -H 'Content-Type: application/json' -d '{"id":"2", "creatorType":"human", "creatorId":"admin1", "repeatUnit":"HOUR", "interval":1, "active":true, "callParams":{"uri":"solr://demo/update", "method":"GET", "queryParams":{"stream.body":"<commit/>"}}}' https://FUSION_HOST:8764/api/scheduler/schedules
```

**RESPONSE**

```json wrap  theme={"dark"}
{
  "id" : "2",
  "trigger" : "2_1400011854443_-9223372036854775807",
  "schedule" : {
    "id" : "2",
    "creatorType" : "human",
    "creatorId" : "admin1",
    "createTime" : "2014-05-13T20:10:54.443Z",
    "startTime" : "2014-05-13T20:10:54.443Z",
    "endTime" : null,
    "repeatUnit" : "HOUR",
    "interval" : 1,
    "active" : true,
    "callParams" : {
      "uri" : "solr://demo/update",
      "method" : "GET",
      "queryParams" : {
        "stream.body" : "<commit/>"
      },
      "headers" : { },
      "entity" : null
    }
  }
}
```

*Set schedule "2" to inactive:*

**REQUEST**

```bash wrap  theme={"dark"}
curl -u USERNAME:PASSWORD -X PUT -H 'Content-Type: application/json' -d '{"creatorType":"human", "creatorId":"admin1", "repeatUnit":"HOUR", "interval":1, "active":false, "callParams":{"uri":"solr://demo/update", "method":"GET", "queryParams":{"stream.body":"<commit/>"}}}' https://FUSION_HOST:8764/api/scheduler/schedules/2
```

There will be no response if the PUT request was successful.

*List all scheduled jobs:*

**REQUEST**

```bash wrap  theme={"dark"}
 curl -u USERNAME:PASSWORD https://FUSION_HOST:8764/api/scheduler/jobs
```

**RESPONSE**

```json wrap  expandable  theme={"dark"}
[ {
  "id" : "2",
  "trigger" : "2_1400011854443_-9223372036854775807",
  "schedule" : {
    "id" : "2",
    "creatorType" : "human",
    "creatorId" : "admin1",
    "createTime" : "2014-05-13T20:10:54.443Z",
    "startTime" : "2014-05-13T20:10:54.443Z",
    "endTime" : null,
    "repeatUnit" : "HOUR",
    "interval" : 1,
    "active" : true,
    "callParams" : {
      "uri" : "solr://demo/update",
      "method" : "GET",
      "queryParams" : {
        "stream.body" : "<commit/>"
      },
      "headers" : { },
      "entity" : null
    }
  }
}, {
  "id" : "1",
  "trigger" : "1_1400007488512_-9223372036854775808",
  "schedule" : {
    "id" : "1",
    "creatorType" : "human",
    "creatorId" : "admin1",
    "createTime" : "2014-05-13T18:58:08.512Z",
    "startTime" : "2014-05-13T18:58:08.512Z",
    "endTime" : null,
    "repeatUnit" : "DAY",
    "interval" : 1,
    "active" : true,
    "callParams" : {
      "uri" : "service://connectors/jobs/LocalDocs2",
      "method" : "POST",
      "queryParams" : { },
      "headers" : { },
      "entity" : null
    }
  }
} ]
```

*List the history of job ID '1':*

**REQUEST**

```bash wrap  theme={"dark"}
curl -u USERNAME:PASSWORD https://FUSION_HOST:8764/api/history/scheduler/items/1
```

**RESPONSE**

```json wrap  theme={"dark"}
{
  "events" : [ 
    {
      "start" : "2014-05-16T15:34:49.008Z",
      "end" : "2014-05-16T15:34:49.435Z",
      "source" : "scheduler",
      "type" : "execute",
      "status" : "ok",
      "details" : {
        "status" : 200,
        "entity" : "{\n \"id\" : \"TwitterSearch\",\n \"dataSourceId\" : \"TwitterSearch\",\n \"state\" : \"RUNNING\",\n \"message\" : null,\n \"startTime\" : 1400254489000,\n \"endTime\" : -1,\n \"finished\" : false,\n \"counters\" : { },\n \"exception\" : null,\n \"running\" : true\n}"
      },
      "error" : null
    },
    {
      "start" : "2014-05-16T15:38:32.536Z",
      "end" : "2014-05-16T15:38:32.559Z",
      "source" : "scheduler",
      "type" : "execute",
      "status" : "ok",
      "details" : {
        "status" : 200,
        "entity" : "{\n \"id\" : \"TwitterSearch\",\n \"dataSourceId\" : \"TwitterSearch\",\n \"state\" : \"RUNNING\",\n \"message\" : null,\n \"startTime\" : 1400254712000,\n \"endTime\" : -1,\n \"finished\" : false,\n \"counters\" : { },\n \"exception\" : null,\n \"running\" : true\n}"
      } 
    }
  ]
}
```
