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

# Update Snippet

> Rename a snippet, change its text, or move it to the other kind

## Update Snippet

Updates a saved snippet or hashtag group. Send only the fields you want to change; fields you leave out stay as they are.

### Request

**id** `integer` *required*

The ID of the snippet to update

**kind** `string`

`snippet` or `hashtags`

**name** `string`

New name, 1 to 80 characters after spaces at the start and end are removed

**body** `string`

New text, up to 5,000 characters

```json theme={null}
{
  "name": "Launch week tags"
}
```

### Response

The updated [snippet object](https://docs.postsyncer.com/api-reference/snippets/overview.md#the-snippet-object).

```json theme={null}
{
  "id": 31,
  "workspace_id": 12,
  "kind": "hashtags",
  "name": "Launch week tags",
  "body": "#launch #buildinpublic #saas",
  "created_by": 7,
  "created_at": "2026-11-17T09:12:44+00:00",
  "updated_at": "2026-11-17T10:03:19+00:00"
}
```

### Code Examples

```bash cURL theme={null}
curl -X PUT "https://postsyncer.com/api/v1/snippets/31" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Launch week tags"
  }'
```

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

const updateSnippet = async (snippetId) => {
  try {
    const response = await axios.put(`https://postsyncer.com/api/v1/snippets/${snippetId}`, {
      name: 'Launch week tags'
    }, {
      headers: {
        'Authorization': 'Bearer YOUR_API_TOKEN',
        'Content-Type': 'application/json'
      }
    });

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

updateSnippet(31);
```

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

$snippetId = 31;
$data = [
    'name' => 'Launch week tags'
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://postsyncer.com/api/v1/snippets/{$snippetId}");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer YOUR_API_TOKEN',
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

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

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

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

snippet_id = 31
data = {
    'name': 'Launch week tags'
}

headers = {
    'Authorization': 'Bearer YOUR_API_TOKEN',
    'Content-Type': 'application/json'
}

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

if response.status_code == 200:
    snippet = response.json()
    print(f"Snippet updated: {snippet['name']}")
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:update` permission, or the key's person's role in the workspace does not allow editing snippets

**404** `Not Found`

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

**422** `Unprocessable Entity`

Validation errors: a `kind` other than `snippet` or `hashtags`, an empty or over-80-character `name`, an empty or over-5,000-character `body`


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