Update a tag
Rename a tag, set how it displays, or both. slug renames the tag across the site, and title and description set how it displays.
A rename retags every page carrying the tag and moves the tag’s title and description to the new slug, all in one request. Page content is never touched.
PATCH https://sitepaste.com/api/v1/public/sites/{siteId}/tags/{slug}
Requires the content scope.
Usage
Rename a tag and give it display casing in the same request:
curl -X PATCH "https://sitepaste.com/api/v1/public/sites/default/tags/guides" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{ "slug": "tutorials", "title": "Tutorials" }'
Authorizations
| Header | Type | Required | Description |
|---|---|---|---|
| Authorization | string | Yes | Bearer token (Authorization: Bearer sp_...). Created in the dashboard under Account > Tokens. See authentication. |
Path parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| slug | string | Yes | The tag’s current slug: lowercased, with spaces as hyphens. |
Body
| Field | Type | Required | Description |
|---|---|---|---|
| slug | string | No | The new tag. Renames it on every page that carries it. Sending the current slug is accepted and renames nothing, so you can send back the whole record you read. |
| title | string | No | Display title, which is how the tag is written on the site (max 30 chars). An empty string clears it. A title equal to the slug reads back as empty, and the site shows the slug. |
| description | string | No | Description shown on the tag’s page (max 200 chars). An empty string clears it. |
Send at least one of the three. When a request carries both slug and metadata, the rename runs first and the metadata lands on the new slug.
Clearing both the title and the description removes the tag’s display title without removing the tag from any page.
Response
200 OK with the tag as it now stands. That is the same record GET /sites/{siteId}/tags/{slug} and the collection answer with, plus renamed.
{ "slug": "tutorials", "title": "Tutorials", "description": "", "pageCount": 12, "renamed": 12 }
| Field | Type | Description |
|---|---|---|
| slug | string | The tag’s slug after the update. |
| title | string | Display title, empty when the tag has none. |
| description | string | Description, empty when the tag has none. |
| pageCount | number | How many pages carry the tag. |
| renamed | number | Only on a rename. The number of pages retagged, which is 0 when no page carried the tag. |
Errors
| Code | Meaning |
|---|---|
| 400 | The slug in the path is not a valid tag |
| 409 | The site already has a title or description set on 500 tags; clear another tag’s first |
| 422 | No field was sent, the slug in the body is not a valid tag (fields.slug carries the reason), or the title or description is too long |