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

# Delete Post

> Delete a post and cancel any scheduled publishing

## Delete Post

Deletes a post and cancels any scheduled publishing. This action cannot be undone.

### Request

<ParamField path="id" type="integer" required>
  The ID of the post to delete
</ParamField>

<RequestExample>
  ```bash theme={null}
  curl -X DELETE "https://postsyncer.com/api/v1/posts/123" \
    -H "Authorization: Bearer YOUR_API_TOKEN"
  ```
</RequestExample>

### Response

<ResponseField name="message" type="string">
  Success message confirming the post was deleted
</ResponseField>

<ResponseExample>
  ```json theme={null}
  {
    "message": "Post deleted successfully"
  }
  ```
</ResponseExample>

### Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X DELETE "https://postsyncer.com/api/v1/posts/123" \
    -H "Authorization: Bearer YOUR_API_TOKEN"
  ```

  ```javascript Node.js theme={null}
  const axios = require('axios');

  const deletePost = async (postId) => {
    try {
      const response = await axios.delete(`https://postsyncer.com/api/v1/posts/${postId}`, {
        headers: {
          'Authorization': 'Bearer YOUR_API_TOKEN'
        }
      });
      
      console.log('Post deleted:', response.data.message);
    } catch (error) {
      console.error('Error deleting post:', error.response?.data || error.message);
    }
  };

  deletePost(123);
  ```

  ```php PHP theme={null}
  <?php

  $postId = 123;

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, "https://postsyncer.com/api/v1/posts/{$postId}");
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
      'Authorization: Bearer YOUR_API_TOKEN'
  ]);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

  $response = curl_exec($ch);
  $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  curl_close($ch);

  if ($httpCode === 200) {
      $result = json_decode($response, true);
      echo $result['message'];
  } else {
      echo "Error: " . $response;
  }
  ?>
  ```

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

  post_id = 123
  headers = {
      'Authorization': 'Bearer YOUR_API_TOKEN'
  }

  response = requests.delete(
      f'https://postsyncer.com/api/v1/posts/{post_id}',
      headers=headers
  )

  if response.status_code == 200:
      result = response.json()
      print(result['message'])
  else:
      print(f"Error: {response.status_code}")
      print(response.text)
  ```
</CodeGroup>

### Error Codes

<ResponseField name="401" type="Unauthorized">
  Missing or invalid API token
</ResponseField>

<ResponseField name="403" type="Forbidden">
  Token does not have 'posts' permission
</ResponseField>

<ResponseField name="404" type="Not Found">
  Post not found or user does not have access to the post's workspace
</ResponseField>

<ResponseField name="422" type="Unprocessable Entity">
  Invalid post ID provided
</ResponseField>
