Skip to content
Get started

Cancel a worker schedule

client.Workers.Schedules.Cancel(ctx, scheduleID, body) (*WorkerScheduleCancelResponse, error)
DELETE/api/workers/{workerId}/schedules/{scheduleId}

Cancel a scheduled task for a worker.

ParametersExpand Collapse
scheduleID string
body WorkerScheduleCancelParams
WorkerID param.Field[string]

Worker id returned by the create worker endpoint.

ReturnsExpand Collapse
type WorkerScheduleCancelResponse struct{…}
Cancelled bool

Cancel a worker schedule

package main

import (
  "context"
  "fmt"

  "github.com/stainless-sdks/handinger-go"
  "github.com/stainless-sdks/handinger-go/option"
)

func main() {
  client := handinger.NewClient(
    option.WithAPIKey("My API Key"),
  )
  response, err := client.Workers.Schedules.Cancel(
    context.TODO(),
    "sch_01HZY31W2SZJ8MJ2FQTR3M1K9D",
    handinger.WorkerScheduleCancelParams{
      WorkerID: "t_org_123_w_01HZY2ZJQ8G7K42W2D7WF6V4GM",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.Cancelled)
}
{
  "cancelled": true
}
Returns Examples
{
  "cancelled": true
}