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

# Cancel Schedule

> Cancel a scheduled post before it's published

<Note>
  **Try it out!** Use the API playground on the right to test the Cancel Schedule endpoint directly.
</Note>

## Overview

Cancel a scheduled post to prevent it from being published. This permanently removes the scheduled post from the queue.

<Warning>
  **This action is permanent.** Once cancelled, the scheduled post cannot be recovered. You'll need to create a new schedule if you want to publish the video.
</Warning>

<Info>
  You can only cancel posts with `pending` status. Posts that have already been published cannot be deleted through this API - you'll need to delete them directly on the platform.
</Info>

***

## Endpoint

```
DELETE /v1/schedule/{scheduleId}
```

***

## Path Parameters

<ParamField path="scheduleId" type="string" required>
  The unique ID of the scheduled post to cancel
</ParamField>

***

## Headers

<ParamField header="x-api-key" type="string" required>
  Your API key from [API Settings](https://hooked.so/settings/api)
</ParamField>

***

## Request Examples

```javascript theme={null}
const scheduleId = 'post_abc123xyz';

const response = await fetch(`https://api.hooked.so/v1/schedule/${scheduleId}`, {
  method: 'DELETE',
  headers: {
    'x-api-key': process.env.HOOKED_API_KEY
  }
});

const data = await response.json();

if (data.success) {
  console.log('Schedule cancelled successfully');
} else {
  console.error('Failed to cancel:', data.message);
}
```

### Bulk Cancel Example

```javascript theme={null}
async function cancelMultipleSchedules(scheduleIds) {
  const results = await Promise.allSettled(
    scheduleIds.map(async (id) => {
      const response = await fetch(`https://api.hooked.so/v1/schedule/${id}`, {
        method: 'DELETE',
        headers: { 'x-api-key': process.env.HOOKED_API_KEY }
      });
      return { id, result: await response.json() };
    })
  );

  const cancelled = results
    .filter(r => r.status === 'fulfilled' && r.value.result.success)
    .map(r => r.value.id);

  const failed = results
    .filter(r => r.status === 'rejected' || !r.value.result.success)
    .map(r => r.value?.id || 'unknown');

  return { cancelled, failed };
}

// Usage
const { cancelled, failed } = await cancelMultipleSchedules([
  'post_abc123',
  'post_def456',
  'post_ghi789'
]);

console.log(`Cancelled: ${cancelled.length}, Failed: ${failed.length}`);
```

<RequestExample>
  ```bash cURL theme={null}
  curl -X DELETE "https://api.hooked.so/v1/schedule/post_abc123xyz" \
    -H "x-api-key: your_api_key_here"
  ```

  ```python Python theme={null}
  import requests

  schedule_id = 'post_abc123xyz'

  response = requests.delete(
      f'https://api.hooked.so/v1/schedule/{schedule_id}',
      headers={'x-api-key': 'your_api_key_here'}
  )

  data = response.json()

  if data['success']:
      print('Schedule cancelled successfully')
  else:
      print('Failed:', data['message'])
  ```

  ```php PHP theme={null}
  $scheduleId = 'post_abc123xyz';

  $ch = curl_init();
  curl_setopt_array($ch, [
      CURLOPT_URL => "https://api.hooked.so/v1/schedule/{$scheduleId}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_CUSTOMREQUEST => 'DELETE',
      CURLOPT_HTTPHEADER => [
          'x-api-key: your_api_key_here'
      ]
  ]);

  $response = curl_exec($ch);
  curl_close($ch);

  $data = json_decode($response, true);

  if ($data['success']) {
      echo 'Schedule cancelled successfully';
  } else {
      echo 'Failed: ' . $data['message'];
  }
  ```

  ```go Go theme={null}
  package main

  import (
      "fmt"
      "io"
      "net/http"
  )

  func main() {
      scheduleId := "post_abc123xyz"
      url := fmt.Sprintf("https://api.hooked.so/v1/schedule/%s", scheduleId)

      req, _ := http.NewRequest("DELETE", url, nil)
      req.Header.Set("x-api-key", "your_api_key_here")

      client := &http.Client{}
      resp, _ := client.Do(req)
      defer resp.Body.Close()

      body, _ := io.ReadAll(resp.Body)
      fmt.Println(string(body))
  }
  ```
</RequestExample>

***

## Response

<ResponseExample>
  ```json Success Response theme={null}
  {
    "success": true,
    "message": "Schedule cancelled successfully",
    "data": {
      "id": "post_abc123xyz",
      "deleted": true
    }
  }
  ```

  ```json Error - Already Published theme={null}
  {
    "code": "bad_request",
    "message": "Cannot delete a published post",
    "details": {}
  }
  ```

  ```json Error - Not Found theme={null}
  {
    "code": "not_found",
    "message": "Schedule not found",
    "details": {
      "resource_id": "post_invalid",
      "resource_type": "Schedule"
    }
  }
  ```

  ```json Error - Forbidden theme={null}
  {
    "code": "forbidden",
    "message": "Schedule does not belong to your team",
    "details": {}
  }
  ```
</ResponseExample>

***

## Important Notes

### What Happens After Cancellation

* The scheduled post is permanently deleted
* The video itself is NOT deleted - only the schedule
* You can schedule the same video again with a new schedule
* Webhooks for this schedule will not be triggered

### Published Posts

If a post has already been published (`status: published`), you cannot delete it through this API. To remove published content:

1. **YouTube**: Go to YouTube Studio and delete the video
2. **TikTok**: Open TikTok app and delete the post
3. **Instagram**: Use Instagram app to delete the reel/post

***

## Error Handling

| Error                                   | Description         | Solution                         |
| --------------------------------------- | ------------------- | -------------------------------- |
| `Schedule not found`                    | Invalid schedule ID | Check the schedule ID is correct |
| `Cannot delete a published post`        | Already published   | Delete directly on the platform  |
| `Schedule does not belong to your team` | Wrong ownership     | Use correct API key              |

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Create Schedule" icon="plus" href="/api-reference/schedule/create">
    Schedule a new video
  </Card>

  <Card title="List Scheduled" icon="list" href="/api-reference/schedule/list">
    View all scheduled posts
  </Card>

  <Card title="List Videos" icon="video" href="/api-reference/video/list">
    View all your videos
  </Card>

  <Card title="List Integrations" icon="plug" href="/api-reference/integration/list">
    View connected platforms
  </Card>
</CardGroup>


## OpenAPI

````yaml DELETE /v1/schedule/{scheduleId}
openapi: 3.0.0
info:
  title: Hooked API
  version: 1.0.0
  description: AI Video Generation API
servers:
  - url: https://api.hooked.so
security:
  - ApiKeyAuth: []
paths:
  /v1/schedule/{scheduleId}:
    delete:
      tags:
        - Scheduling
      summary: Cancel Schedule
      description: Cancel a scheduled post before it's published
      operationId: deleteSchedule
      parameters:
        - name: scheduleId
          in: path
          description: Schedule ID
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Schedule cancelled successfully
      security:
        - ApiKeyAuth: []
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````