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

# Delete Post

> Delete one or more scheduled posts

<Info>
  Only posts with a status of `generated` or `pending_render` can be deleted. Posts that have already been posted cannot be deleted.
</Info>

## Request Body

<ParamField body="postIds" type="array" required>
  Array of post IDs to delete. You can delete a single post or multiple posts in one request.
</ParamField>

## Response

<ResponseField name="deleted" type="array">
  Array of post IDs that were successfully deleted.
</ResponseField>

<ResponseField name="failed" type="array">
  Array of objects for any post IDs that could not be deleted, with a reason for each.

  <Expandable title="properties">
    <ResponseField name="postId" type="string">
      The post ID that failed to delete.
    </ResponseField>

    <ResponseField name="reason" type="string">
      Why the deletion failed: `not_found`, `already_posted`, or `permission_denied`.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="deletedAt" type="string">
  ISO 8601 timestamp of when the deletion was processed.
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X DELETE "https://api.infinipost.co/v1/posts" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "postIds": ["post_abc123", "post_def456"]
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.infinipost.co/v1/posts', {
    method: 'DELETE',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      postIds: ['post_abc123', 'post_def456']
    })
  });

  const data = await response.json();
  ```
</RequestExample>

<ResponseExample>
  ```json All Successful theme={null}
  {
    "deleted": ["post_abc123", "post_def456"],
    "failed": [],
    "deletedAt": "2024-04-21T20:20:00Z"
  }
  ```

  ```json Partial Success theme={null}
  {
    "deleted": ["post_abc123"],
    "failed": [
      {
        "postId": "post_def456",
        "reason": "already_posted"
      }
    ],
    "deletedAt": "2024-04-21T20:20:00Z"
  }
  ```
</ResponseExample>

## Error Responses

```json Unauthorized theme={null}
{
  "error": {
    "code": "unauthenticated",
    "message": "Invalid or missing API key"
  }
}
```

```json Missing Required Fields theme={null}
{
  "error": {
    "code": "missing_required_fields",
    "message": "postIds is required and must be a non-empty array"
  }
}
```

```json Server Error theme={null}
{
  "error": {
    "code": "internal",
    "message": "An unexpected error occurred"
  }
}
```
