For AI agents: markdown of this page — /docs-content-en/entities/sites/delete.md documentation index — /llms.txt
Delete a site
DELETE /v1/sites/:id
Deletes a site by identifier. Only an empty site can be deleted — one without pages (including pages in the trash). If the site has at least one page, the request returns an error.
Parameters
| Parameter | Type | Req. | Description |
|---|---|---|---|
id (path) |
number | yes | Site identifier |
scope |
string | no | For a site in the knowledge base section, pass scope: "KNOWLEDGE" (the same value as on creation) — otherwise the server returns 403 BITRIX_ACCESS_DENIED. Can be passed as the ?scope=KNOWLEDGE query parameter or a body field. Not required for regular sites |
Examples
curl — personal key
curl -X DELETE "https://vibecode.bitrix24.com/v1/sites/173" \
-H "X-Api-Key: YOUR_API_KEY"
curl — OAuth application
curl -X DELETE "https://vibecode.bitrix24.com/v1/sites/173" \
-H "X-Api-Key: YOUR_APP_KEY" \
-H "Authorization: Bearer USER_SESSION_TOKEN"
JavaScript — personal key
const res = await fetch('https://vibecode.bitrix24.com/v1/sites/173', {
method: 'DELETE',
headers: {
'X-Api-Key': 'YOUR_API_KEY',
},
})
if (res.status === 204) {
console.log('Site deleted')
}
JavaScript — OAuth application
const res = await fetch('https://vibecode.bitrix24.com/v1/sites/173', {
method: 'DELETE',
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
},
})
if (res.status === 204) {
console.log('Site deleted')
}
Response
On successful deletion, HTTP status 204 No Content with an empty body is returned — success is checked by the status.
Response example
HTTP/1.1 204 No Content
Error response example
422 — the site has pages:
{
"success": false,
"error": {
"code": "BITRIX_ERROR",
"message": "Site contains pages."
}
}
Errors
| HTTP | error.code |
Marker in error.message |
Description |
|---|---|---|---|
| 422 | BITRIX_ERROR |
SITE_IS_NOT_EMPTY |
The site has pages (including pages in the trash) |
| 422 | BITRIX_ERROR |
SITE_IS_LOCK |
The site is locked against deletion |
| 403 | BITRIX_ACCESS_DENIED |
— | The user does not have permission to delete this site, or a site with this ID does not exist or is unavailable — Bitrix24 answers "Access denied". For deletion, 404 is not returned, unlike GET /v1/sites/:id |
| 403 | BITRIX_ACCESS_DENIED |
ACCESS_DENIED_DELETED |
A domain provider is connected on the portal — site deletion via the API is not available, delete it through the portal interface |
| 403 | SCOPE_DENIED |
— | The API key does not have the landing scope |
| 401 | TOKEN_MISSING |
— | The API key has no configured tokens |
The full list of common API errors — Errors.
Known specifics
The trash does not free up the site. A site cannot be deleted while it still has pages in the trash — first empty the page trash.
See also
- List site pages —
GET /v1/pages?filter[siteId]=:idbefore deleting a site - List sites — find the ID of the site you need
- Batch — bulk deletion
- Limits and optimization — rate limits