> ## 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 Snippet

> Delete a saved snippet or hashtag group

## Delete Snippet

Deletes a saved snippet or hashtag group. Posts that already used its text keep it. This cannot be undone.

### Request

**id** `integer` *required*

The ID of the snippet to delete

```bash theme={null}
curl -X DELETE "https://postsyncer.com/api/v1/snippets/31" \
  -H "Authorization: Bearer YOUR_API_TOKEN"
```

### Response

**message** `string`

Confirms the snippet was deleted

```json theme={null}
{
  "message": "Snippet deleted successfully"
}
```

### Code Examples

```bash cURL theme={null}
curl -X DELETE "https://postsyncer.com/api/v1/snippets/31" \
  -H "Authorization: Bearer YOUR_API_TOKEN"
```

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

const deleteSnippet = async (snippetId) => {
  try {
    const response = await axios.delete(`https://postsyncer.com/api/v1/snippets/${snippetId}`, {
      headers: {
        'Authorization': 'Bearer YOUR_API_TOKEN'
      }
    });

    console.log(response.data.message);
  } catch (error) {
    console.error('Error deleting snippet:', error.response?.data || error.message);
  }
};

deleteSnippet(31);
```

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

$snippetId = 31;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://postsyncer.com/api/v1/snippets/{$snippetId}");
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

snippet_id = 31
headers = {
    'Authorization': 'Bearer YOUR_API_TOKEN'
}

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

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

### Error Codes

**401** `Unauthorized`

Missing or invalid API token

**403** `Forbidden`

The key does not have the `snippets:delete` permission, or the key's person's role in the workspace does not allow deleting snippets

**404** `Not Found`

Snippet not found, or it belongs to a workspace the key's person is not in


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.