# Schedule

This endpoint is used to create, update, search or delete schedules for a particular workspace inside an organization, this is useful when you need to create schedule task or running jobs in a particular time.

### Entity fields:

| Path                              | Type   | Description                                                                                                                                                                                                   |
| --------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| data.type                         | string | Should be "template"                                                                                                                                                                                          |
| data.attributes.cron              | string | Cron expression to schedule a job inside a workspace. For more information please visit [Quartz documentation](http://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/tutorial-lesson-06.html). |
| data.attributes.tcl               | string | Terrakube configuration language in base64                                                                                                                                                                    |
| data.attributes.templateReference | string | Terrakube template id                                                                                                                                                                                         |

{% hint style="info" %}
To better understand Terrakube Configuration Language job templates please refer to the following [GitHub repository.](https://github.com/AzBuilder/terrakube-extensions)
{% endhint %}

### Example:

```
{
  "data": {
    "type": "schedule",
    "attributes": {
      "cron": "0 0/1 * * * ?",
      "tcl": "{{templateSample}}"
    }
  }
}
```

### Supported Operations

{% openapi src="<https://raw.githubusercontent.com/AzBuilder/terrakube-server/main/openapi-spec/v1_6.yml>" path="/workspace/{workspaceId}/schedule/{scheduleId}" method="get" %}
<https://raw.githubusercontent.com/AzBuilder/terrakube-server/main/openapi-spec/v1_6.yml>
{% endopenapi %}

{% openapi src="<https://raw.githubusercontent.com/AzBuilder/terrakube-server/main/openapi-spec/v1_6.yml>" path="/workspace/{workspaceId}/schedule" method="post" %}
<https://raw.githubusercontent.com/AzBuilder/terrakube-server/main/openapi-spec/v1_6.yml>
{% endopenapi %}

{% openapi src="<https://raw.githubusercontent.com/AzBuilder/terrakube-server/main/openapi-spec/v1_6.yml>" path="/workspace/{workspaceId}/schedule/{scheduleId}" method="delete" %}
<https://raw.githubusercontent.com/AzBuilder/terrakube-server/main/openapi-spec/v1_6.yml>
{% endopenapi %}

{% openapi src="<https://raw.githubusercontent.com/AzBuilder/terrakube-server/main/openapi-spec/v1_6.yml>" path="/workspace/{workspaceId}/schedule/{scheduleId}" method="patch" %}
<https://raw.githubusercontent.com/AzBuilder/terrakube-server/main/openapi-spec/v1_6.yml>
{% endopenapi %}

{% hint style="info" %}
For a complete list of organization operation please visit the [OpenAPI specification](https://github.com/AzBuilder/terrakube-server/tree/main/openapi-spec)
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.terrakube.io/2.20.0/api/methods/schedule.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
