# `ApifyClient.API.Schedules`
[🔗](https://github.com/social-growth-studio/apify-client-ex/blob/v1.0.0/lib/apify_client/api/schedules.ex#L1)

Provides API endpoints related to api/schedules

# `create`

```elixir
@spec create(
  body :: map() | ApifyClient.Schemas.CreateOrUpdateScheduleRequest.t(),
  opts :: keyword()
) ::
  {:ok, ApifyClient.Schemas.Schedule.t()} | {:error, ApifyClient.Error.t()}
```

Create schedule

Creates a new schedule with settings provided by the schedule object passed
as JSON in the payload. The response is the created schedule object.

The request needs to specify the `Content-Type: application/json` HTTP header!

When providing your API authentication token, we recommend using the
request's `Authorization` header, rather than the URL.
For details, see [Authentication](https://docs.apify.com/api/v2#authentication).

## Request Body

**Content Types**: `application/json`

# `delete`

```elixir
@spec delete(schedule_id :: String.t(), opts :: keyword()) ::
  :ok | {:error, ApifyClient.Error.t()}
```

Delete schedule

Deletes a schedule.

# `get`

```elixir
@spec get(schedule_id :: String.t(), opts :: keyword()) ::
  {:ok, ApifyClient.Schemas.Schedule.t()} | {:error, ApifyClient.Error.t()}
```

Get schedule

Gets the schedule object with all details.

# `invoke`

```elixir
@spec invoke(schedule_id :: String.t(), opts :: keyword()) ::
  {:ok, map() | nil} | {:error, ApifyClient.Error.t()}
```

Invoke schedule

Immediately runs all actions of the schedule, the same way as the **Run now** button in Apify Console.

The invocation is recorded in the [schedule log](https://docs.apify.com/api/v2/schedule-log-get). It doesn't change the schedule's
`lastRunAt` or `nextRunAt`. The response doesn't contain the started runs.

# `list`

```elixir
@spec list(opts :: keyword()) ::
  {:ok, ApifyClient.Schemas.ListOfSchedules.t()}
  | {:error, ApifyClient.Error.t()}
```

Get list of schedules

Gets the list of schedules that the user created.

The endpoint supports pagination using the `limit` and `offset` parameters.
It will not return more than 1000 records.

By default, the records are sorted by the `createdAt` field in ascending
order. To sort the records in descending order, use the `desc=1` parameter.

## Options

  * `offset`: Number of items that should be skipped at the start. The default value is `0`.
    
  * `limit`: Maximum number of items to return. The default value as well as the maximum is `1000`.
    
  * `desc`: If `true` or `1` then the objects are sorted by the `createdAt` field in
    descending order. By default, they are sorted in ascending order.
    

# `log`

```elixir
@spec log(schedule_id :: String.t(), opts :: keyword()) ::
  {:ok, [ApifyClient.Schemas.ScheduleLogEntry.t()]}
  | {:error, ApifyClient.Error.t()}
```

Get schedule log

Gets the schedule log as a JSON array containing information about up to a
1000 invocations of the schedule.

# `update`

```elixir
@spec update(
  schedule_id :: String.t(),
  body :: map() | ApifyClient.Schemas.CreateOrUpdateScheduleRequest.t(),
  opts :: keyword()
) :: {:ok, ApifyClient.Schemas.Schedule.t()} | {:error, ApifyClient.Error.t()}
```

Update schedule

Updates a schedule using values specified by a schedule object passed as
JSON in the POST payload. If the object does not define a specific property,
its value will not be updated.

The response is the full schedule object as returned by the
[Get schedule](https://docs.apify.com/api/v2/schedule-get) endpoint.

**The request needs to specify the `Content-Type: application/json` HTTP
header!**

When providing your API authentication token, we recommend using the
request's `Authorization` header, rather than the URL.
For details, see [Authentication](https://docs.apify.com/api/v2#authentication).

## Request Body

**Content Types**: `application/json`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
