# JobSchedule

> Tracon documentation. Tracon is a .NET package family that adds a control
> plane on Microsoft Agent Framework, published as NuGet packages that run
> inside your own ASP.NET Core application.
>
> Page: https://tracon.dev/api/tracon.jobschedule/
> Summary: JobSchedule: The schedule record defining when and how a job runs.

<div class="api-provenance">Namespace Tracon · Assembly <code>Tracon.Abstractions.dll</code></div>

The schedule record defining when and how a job runs.

```csharp
public sealed record JobSchedule : IEquatable<JobSchedule>
```

<dl class="api-relations"><dt>Inheritance</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object">object</a> ← <a href="/api/tracon.jobschedule/">JobSchedule</a></dd><dt>Implements</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.iequatable-1">IEquatable&lt;JobSchedule&gt;</a></dd><dt>Inherited Members</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object.gettype">object.GetType()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.tostring">object.ToString()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)">object.Equals(object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)">object.Equals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.referenceequals">object.ReferenceEquals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode">object.GetHashCode()</a></dd></dl>

## Remarks

If `Cron` is left empty, the schedule is triggered only
manually (`POST .../trigger`); no automatic next-run time is computed.

## Constructors

### <a id="Tracon_JobSchedule__ctor"></a> JobSchedule\(\)

```csharp
public JobSchedule()
```

## Properties

### <a id="Tracon_JobSchedule_CreatedAt"></a> CreatedAt

The creation time (UTC).

```csharp
public required DateTimeOffset CreatedAt { get; init; }
```

#### Property Value

 [DateTimeOffset](https://learn.microsoft.com/dotnet/api/system.datetimeoffset)

### <a id="Tracon_JobSchedule_CreatedBy"></a> CreatedBy

The identifier of the user/service that created the schedule.

```csharp
public string? CreatedBy { get; init; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)?

### <a id="Tracon_JobSchedule_Cron"></a> Cron

The five-field cron expression (`minute hour day-of-month month
day-of-week`). If [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null), the schedule is triggered only manually.

```csharp
public string? Cron { get; init; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)?

### <a id="Tracon_JobSchedule_Enabled"></a> Enabled

Whether the schedule is enabled. If disabled, it is not triggered automatically.

```csharp
public bool Enabled { get; init; }
```

#### Property Value

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### <a id="Tracon_JobSchedule_HandlerKey"></a> HandlerKey

The key of the [IJobHandler](/api/tracon.ijobhandler/) the jobs this schedule
produces are dispatched to. See [JobHandlerKeys](/api/tracon.jobhandlerkeys/).

```csharp
public required string HandlerKey { get; init; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

### <a id="Tracon_JobSchedule_Id"></a> Id

The schedule identifier.

```csharp
public Guid Id { get; init; }
```

#### Property Value

 [Guid](https://learn.microsoft.com/dotnet/api/system.guid)

### <a id="Tracon_JobSchedule_Lane"></a> Lane

The lane the jobs this schedule produces run in. See
[JobLanes](/api/tracon.joblanes/). Both a cron-dispatched run and a manual
`POST .../trigger` inherit this value.

```csharp
public string Lane { get; init; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

### <a id="Tracon_JobSchedule_LastRunAt"></a> LastRunAt

The last run time (UTC). [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) if it never ran.

```csharp
public DateTimeOffset? LastRunAt { get; init; }
```

#### Property Value

 [DateTimeOffset](https://learn.microsoft.com/dotnet/api/system.datetimeoffset)?

### <a id="Tracon_JobSchedule_Name"></a> Name

The schedule name, unique within the tenant.

```csharp
public required string Name { get; init; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

### <a id="Tracon_JobSchedule_NextRunAt"></a> NextRunAt

The next automatic run time (UTC). [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) if there is no cron.

```csharp
public DateTimeOffset? NextRunAt { get; init; }
```

#### Property Value

 [DateTimeOffset](https://learn.microsoft.com/dotnet/api/system.datetimeoffset)?

#### Remarks

The worker picks a due schedule by this value and computes every later
one itself. A schedule written straight to [IJobScheduleStore](/api/tracon.ijobschedulestore/)
with a cron expression must therefore carry its first run time here: saved
with [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null), it never runs. A time at or before now runs it on
the worker's next pass. The scheduling API sets it for you.

### <a id="Tracon_JobSchedule_Payload"></a> Payload

The input set or parameters. Interpreted by the job's handler.

```csharp
public JsonElement Payload { get; init; }
```

#### Property Value

 [JsonElement](https://learn.microsoft.com/dotnet/api/system.text.json.jsonelement)

#### Remarks

An unset payload is stored as the empty JSON array, never as
`JsonValueKind.Undefined` or JSON `null`: an undefined
value cannot be written as JSON, and SQL Server rejects a `null`
literal in a JSON column. Every reader treats the empty array as "no payload".

### <a id="Tracon_JobSchedule_TargetName"></a> TargetName

The agent or workflow name to run.

```csharp
public required string TargetName { get; init; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

### <a id="Tracon_JobSchedule_TenantId"></a> TenantId

The tenant the schedule belongs to.

```csharp
public required string TenantId { get; init; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

### <a id="Tracon_JobSchedule_TimeZone"></a> TimeZone

The time zone the `Cron` expression is interpreted in.

```csharp
public string TimeZone { get; init; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

### <a id="Tracon_JobSchedule_UpdatedAt"></a> UpdatedAt

The last-updated time (UTC).

```csharp
public required DateTimeOffset UpdatedAt { get; init; }
```

#### Property Value

 [DateTimeOffset](https://learn.microsoft.com/dotnet/api/system.datetimeoffset)

## Methods

### <a id="Tracon_JobSchedule_Equals_System_Object_"></a> Equals\(object?\)

```csharp
public override bool Equals(object? obj)
```

#### Parameters

`obj` [object](https://learn.microsoft.com/dotnet/api/system.object)?

#### Returns

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### <a id="Tracon_JobSchedule_Equals_Tracon_JobSchedule_"></a> Equals\(JobSchedule?\)

```csharp
public bool Equals(JobSchedule? other)
```

#### Parameters

`other` [JobSchedule](/api/tracon.jobschedule/)?

#### Returns

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### <a id="Tracon_JobSchedule_GetHashCode"></a> GetHashCode\(\)

```csharp
public override int GetHashCode()
```

#### Returns

 [int](https://learn.microsoft.com/dotnet/api/system.int32)

### <a id="Tracon_JobSchedule_ToString"></a> ToString\(\)

```csharp
public override string ToString()
```

#### Returns

 [string](https://learn.microsoft.com/dotnet/api/system.string)

## Operators

### <a id="Tracon_JobSchedule_op_Equality_Tracon_JobSchedule_Tracon_JobSchedule_"></a> operator ==\(JobSchedule?, JobSchedule?\)

```csharp
public static bool operator ==(JobSchedule? left, JobSchedule? right)
```

#### Parameters

`left` [JobSchedule](/api/tracon.jobschedule/)?

`right` [JobSchedule](/api/tracon.jobschedule/)?

#### Returns

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### <a id="Tracon_JobSchedule_op_Inequality_Tracon_JobSchedule_Tracon_JobSchedule_"></a> operator \!=\(JobSchedule?, JobSchedule?\)

```csharp
public static bool operator !=(JobSchedule? left, JobSchedule? right)
```

#### Parameters

`left` [JobSchedule](/api/tracon.jobschedule/)?

`right` [JobSchedule](/api/tracon.jobschedule/)?

#### Returns

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)
