> Full index: https://docs.buchungapp.com/llms.txt
> Early access. Use the API base, channel key and allowed origins supplied by Buchung before running examples.

# Delete a document

Delete the document and its current file with expectedRevision in the body. Refused with 409 document_referenced, whose details carry referenceCount and references [{ activityId, handle, archived, definitionId, key, locale, revision }] (individual value slots), while any custom fact value or event attachment references it, including on archived activities. A 409 body is a diagnostic, not a listing API. referenceCount is the total number of references that block deletion: custom fact values plus event attachments. references lists only custom fact value slots (first 50, ordered by activity id, key then locale (null last)), because those are deletable through the management API. Event attachments are counted but not listed and are detached in the dashboard. When references is empty and referenceCount is still above zero, the remaining blockers are event attachments. Use each reference's revision as expectedRevision when deleting its value, including on archived activities; locale is null for invariant values and must be omitted from their DELETE query. Repeat document deletion until no references remain; unpublish is the way to hide a document now, delete is housekeeping. A stale expectedRevision returns 409 revision_conflict with the document's currentRevision in the required details. Requires media:write. Machine integration bearer credentials only; storefront channel keys never authorize these operations. Buchung-Locale is not used; translations are addressed explicitly. Host enforces a 64 KiB request-body cap before parsing for every method with a body, including DELETE. Per-machine limits: 600 reads/minute, 300 writes/minute; over limit returns 429 rate_limited. Limiter store outage falls back to per-instance memory for reads; writes return 503 service_unavailable with Retry-After: 30.

```json
{
  "operations": [
    {
      "method": "delete",
      "path": "/v1/management/documents/{documentId}",
      "tags": [
        "management"
      ]
    }
  ],
  "schema": {
    "openapi": "3.2.0",
    "info": {
      "title": "Buchung Storefront API",
      "version": "1.0.0",
      "description": "Public catalogue reads and hosted-checkout handoff scoped to a booking channel, plus bearer-only machine management. Storefront channel keys never authorize management operations; machine credentials never authorize storefront checkout handoffs. Storefront reads enforce a 4 MiB per-page custom-fact budget; result_too_large maps to the 400 validation_failed envelope without truncation. Use GET for simple catalogue queries with the raw request target strictly below 8 KiB (414 validation_failed otherwise); use the corresponding POST /query form when conditions or selections outgrow a URL. POST accepts the decoded GET fields as JSON, including the same defaults, errors and response schemas, uses the same read limiter bucket and returns Cache-Control: private, no-store. There are no per-parameter where/facets character caps. Management caps every method with a body at 64 KiB before parsing; storefront POST bodies are capped at 16 KiB before parsing (413 payload_too_large)."
    },
    "paths": {
      "/v1/management/documents/{documentId}": {
        "delete": {
          "tags": [
            "management"
          ],
          "operationId": "management.deleteDocument",
          "parameters": [
            {
              "name": "documentId",
              "in": "path",
              "schema": {
                "$ref": "#/components/schemas/Id"
              },
              "required": true,
              "description": "Document UUID scoped to the integration operator; see Id."
            }
          ],
          "security": [
            {
              "integrationBearer": []
            }
          ],
          "responses": {
            "204": {
              "description": "<No Content>"
            },
            "400": {
              "description": "ValidationFailed",
              "content": {
                "application/json": {
                  "schema": {
                    "$ref": "#/components/schemas/ValidationFailedEncoded"
                  }
                }
              }
            },
            "401": {
              "description": "Unauthorized",
              "content": {
                "application/json": {
                  "schema": {
                    "$ref": "#/components/schemas/UnauthorizedEncoded"
                  }
                }
              }
            },
            "403": {
              "description": "Forbidden",
              "content": {
                "application/json": {
                  "schema": {
                    "$ref": "#/components/schemas/ForbiddenEncoded"
                  }
                }
              }
            },
            "404": {
              "description": "NotFound",
              "content": {
                "application/json": {
                  "schema": {
                    "$ref": "#/components/schemas/NotFoundEncoded"
                  }
                }
              }
            },
            "409": {
              "description": "The expected revision is stale; required object details contain the current revision (null when the value is currently absent; retry with expectedRevision: null) and optionally the stored value. Deleting a value on an archived activity returns currentRevision only; reads there return not_found. | The document cannot be deleted while custom fact values or event attachments reference it; required object details carry referenceCount and references (value slots with activityId, handle, archived, definitionId, key, locale and revision). referenceCount is the total number of references that block deletion: custom fact values plus event attachments. references lists only custom fact value slots (first 50, ordered by activity id, key then locale (null last)), because those are deletable through the management API. Event attachments are counted but not listed and are detached in the dashboard. When references is empty and referenceCount is still above zero, the remaining blockers are event attachments. Archived activities still count to prevent dangling PDF facts after unarchive. The 409 body is a diagnostic, not a listing API. Delete each referenced value at /activities/{activityId}/custom-values/{definitionId} with expectedRevision = revision and the locale query for localized values; invariant locales are null and omitted from DELETE. This also addresses retired definitions without includeRetired, including on archived activities. Remove all references before retrying, or unpublish to hide the document now.",
              "content": {
                "application/json": {
                  "schema": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/RevisionConflictEncoded"
                      },
                      {
                        "$ref": "#/components/schemas/DocumentReferencedEncoded"
                      }
                    ]
                  }
                }
              }
            },
            "413": {
              "description": "PayloadTooLarge",
              "content": {
                "application/json": {
                  "schema": {
                    "$ref": "#/components/schemas/PayloadTooLargeEncoded"
                  }
                }
              }
            },
            "429": {
              "description": "RateLimited",
              "content": {
                "application/json": {
                  "schema": {
                    "$ref": "#/components/schemas/RateLimitedEncoded"
                  }
                }
              }
            },
            "500": {
              "description": "Unexpected runtime failure. Configuration errors close the API mount with 404 not_found in the shared error envelope and an api_misconfigured log line (R23), never 500 internal_error.",
              "content": {
                "application/json": {
                  "schema": {
                    "$ref": "#/components/schemas/InternalErrorEncoded"
                  }
                }
              }
            },
            "503": {
              "description": "ServiceUnavailable",
              "content": {
                "application/json": {
                  "schema": {
                    "$ref": "#/components/schemas/ServiceUnavailableEncoded"
                  }
                }
              }
            }
          },
          "description": "Delete the document and its current file with expectedRevision in the body. Refused with 409 document_referenced, whose details carry referenceCount and references [{ activityId, handle, archived, definitionId, key, locale, revision }] (individual value slots), while any custom fact value or event attachment references it, including on archived activities. A 409 body is a diagnostic, not a listing API. referenceCount is the total number of references that block deletion: custom fact values plus event attachments. references lists only custom fact value slots (first 50, ordered by activity id, key then locale (null last)), because those are deletable through the management API. Event attachments are counted but not listed and are detached in the dashboard. When references is empty and referenceCount is still above zero, the remaining blockers are event attachments. Use each reference's revision as expectedRevision when deleting its value, including on archived activities; locale is null for invariant values and must be omitted from their DELETE query. Repeat document deletion until no references remain; unpublish is the way to hide a document now, delete is housekeeping. A stale expectedRevision returns 409 revision_conflict with the document's currentRevision in the required details. Requires media:write. Machine integration bearer credentials only; storefront channel keys never authorize these operations. Buchung-Locale is not used; translations are addressed explicitly. Host enforces a 64 KiB request-body cap before parsing for every method with a body, including DELETE. Per-machine limits: 600 reads/minute, 300 writes/minute; over limit returns 429 rate_limited. Limiter store outage falls back to per-instance memory for reads; writes return 503 service_unavailable with Retry-After: 30.",
          "summary": "Delete a document",
          "requestBody": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExpectedRevision"
                }
              }
            },
            "required": true
          }
        }
      }
    },
    "security": [],
    "tags": [
      {
        "name": "activities"
      },
      {
        "name": "availabilities"
      },
      {
        "name": "bookingOptions"
      },
      {
        "name": "site"
      },
      {
        "name": "checkout"
      },
      {
        "name": "management"
      }
    ],
    "servers": [
      {
        "url": "https://api.buchungapp.com"
      }
    ],
    "components": {
      "schemas": {
        "UnauthorizedEncoded": {
          "type": "object",
          "properties": {
            "error": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string",
                  "enum": [
                    "unauthorized"
                  ],
                  "description": "Closed error discriminator for this HTTP error variant."
                },
                "message": {
                  "type": "string"
                },
                "doc_url": {
                  "type": "string",
                  "enum": [
                    "https://api.buchungapp.com/v1/docs#errors/unauthorized"
                  ],
                  "description": "Closed documentation URL corresponding to this error code."
                },
                "request_id": {
                  "type": "string"
                },
                "details": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ErrorDetail"
                  }
                }
              },
              "required": [
                "code",
                "message",
                "doc_url",
                "request_id"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "error"
          ],
          "additionalProperties": false
        },
        "ErrorDetail": {
          "type": "object",
          "properties": {
            "path": {
              "type": "string"
            },
            "message": {
              "type": "string"
            }
          },
          "required": [
            "path",
            "message"
          ],
          "additionalProperties": false,
          "description": "A validation issue at a request field path."
        },
        "DocumentReferencedEncoded": {
          "type": "object",
          "properties": {
            "error": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string",
                  "enum": [
                    "document_referenced"
                  ],
                  "description": "Closed error discriminator for this HTTP error variant."
                },
                "message": {
                  "type": "string"
                },
                "doc_url": {
                  "type": "string",
                  "enum": [
                    "https://api.buchungapp.com/v1/docs#errors/document_referenced"
                  ],
                  "description": "Closed documentation URL corresponding to this error code."
                },
                "request_id": {
                  "type": "string"
                },
                "details": {
                  "type": "object",
                  "properties": {
                    "referenceCount": {
                      "type": "integer",
                      "minimum": 1,
                      "maximum": 9007199254740991
                    },
                    "references": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "activityId": {
                            "$ref": "#/components/schemas/Id"
                          },
                          "handle": {
                            "type": "string"
                          },
                          "archived": {
                            "type": "boolean"
                          },
                          "definitionId": {
                            "$ref": "#/components/schemas/Id"
                          },
                          "key": {
                            "$ref": "#/components/schemas/CustomDefinitionKey"
                          },
                          "locale": {
                            "anyOf": [
                              {
                                "$ref": "#/components/schemas/Language"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "revision": {
                            "$ref": "#/components/schemas/Revision"
                          }
                        },
                        "required": [
                          "activityId",
                          "handle",
                          "archived",
                          "definitionId",
                          "key",
                          "locale",
                          "revision"
                        ],
                        "additionalProperties": false
                      },
                      "maxItems": 50
                    }
                  },
                  "required": [
                    "referenceCount",
                    "references"
                  ],
                  "additionalProperties": false
                }
              },
              "required": [
                "code",
                "message",
                "doc_url",
                "request_id",
                "details"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "error"
          ],
          "additionalProperties": false
        },
        "Revision": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991,
          "description": "Monotonic integer optimistic-concurrency revision assigned from a database sequence, starting at 1. Not dense: gaps are normal. Clients compare equality only. A value slot never reuses a revision across delete/recreate, so a stale expectedRevision always conflicts."
        },
        "Language": {
          "type": "string",
          "pattern": "^[A-Za-z]{2,3}(-[A-Za-z0-9]{1,8}){0,3}$",
          "maxLength": 35,
          "description": "Matched case-insensitively against the operator's supported locale codes and normalized to the stored code. On every storefront read, Buchung-Locale is optional: omission or a well-formed but unsupported value applies the operator's default locale; a supported explicit value selects that exact locale, Content-Language always reports the applied locale, and Buchung-Locale-Fallback reports the requested value only when unsupported; malformed values return 400 validation_failed. Only checkout.createHandoff requires a supported Buchung-Locale: absence or malformed values return 400 validation_failed, and well-formed unsupported values return 400 locale_not_supported with details naming the requested and supported locales. Start with site.get to discover the operator's locales. Accepted locale codes form a closed set per operator, discovered from Site.locales; syntactically valid codes do not imply support. Management uses explicit locales without fallback; unsupported locales return 400 validation_failed."
        },
        "CustomDefinitionKey": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9-]{1,63}$",
          "description": "Stable operator-scoped key, 2..64 characters matching ^[a-z][a-z0-9-]{1,63}$; never reused after retirement."
        },
        "Id": {
          "type": "string",
          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|[fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})$",
          "format": "uuid",
          "description": "Stable UUID of a public resource."
        },
        "RevisionConflictEncoded": {
          "type": "object",
          "properties": {
            "error": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string",
                  "enum": [
                    "revision_conflict"
                  ],
                  "description": "Closed error discriminator for this HTTP error variant."
                },
                "message": {
                  "type": "string"
                },
                "doc_url": {
                  "type": "string",
                  "enum": [
                    "https://api.buchungapp.com/v1/docs#errors/revision_conflict"
                  ],
                  "description": "Closed documentation URL corresponding to this error code."
                },
                "request_id": {
                  "type": "string"
                },
                "details": {
                  "type": "object",
                  "properties": {
                    "currentRevision": {
                      "anyOf": [
                        {
                          "$ref": "#/components/schemas/Revision"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "currentValue": {
                      "$ref": "#/components/schemas/CustomValuePayloadEncoded"
                    }
                  },
                  "required": [
                    "currentRevision"
                  ],
                  "additionalProperties": false
                }
              },
              "required": [
                "code",
                "message",
                "doc_url",
                "request_id",
                "details"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "error"
          ],
          "additionalProperties": false
        },
        "CustomValuePayloadEncoded": {
          "description": "Server validates the definition codec: text trimmed plain text, maxLength 1..4000 (default 1000), no control characters except newline/tab; text_list maxItems 1..50 (default 20), each item <= 500 characters, whole-list replacement; boolean strict; number finite with |value| <= 1e15, integer/min/max and precision 0..6, no rounding; choice one declared option key; json <= 16 KiB serialized UTF-8, depth <= 16, <= 5000 nodes, keys <= 128 characters, strings <= 8 KiB, rejects __proto__/constructor/prototype; pdf { documentId } must name a live document of the same operator whose current file is a validated catalogue PDF, never an upload candidate's mediaId; public projection additionally requires the document to be published, so a reference to an unpublished document is stored but stays absent from the storefront. For json definitions only, explicit JSON null is a stored value distinct from deletion. Cumulative serialized custom values per activity are capped at 64 KiB at write time; exceeding the budget returns 400 validation_failed with a budget detail. Retired definitions block new value writes and public projection but allow deleting stored values. Host caps management request bodies at 64 KiB before parsing."
        },
        "ForbiddenEncoded": {
          "type": "object",
          "properties": {
            "error": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string",
                  "enum": [
                    "forbidden"
                  ],
                  "description": "Closed error discriminator for this HTTP error variant."
                },
                "message": {
                  "type": "string"
                },
                "doc_url": {
                  "type": "string",
                  "enum": [
                    "https://api.buchungapp.com/v1/docs#errors/forbidden"
                  ],
                  "description": "Closed documentation URL corresponding to this error code."
                },
                "request_id": {
                  "type": "string"
                },
                "details": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ErrorDetail"
                  }
                }
              },
              "required": [
                "code",
                "message",
                "doc_url",
                "request_id"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "error"
          ],
          "additionalProperties": false
        },
        "PayloadTooLargeEncoded": {
          "type": "object",
          "properties": {
            "error": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string",
                  "enum": [
                    "payload_too_large"
                  ],
                  "description": "Closed error discriminator for this HTTP error variant."
                },
                "message": {
                  "type": "string"
                },
                "doc_url": {
                  "type": "string",
                  "enum": [
                    "https://api.buchungapp.com/v1/docs#errors/payload_too_large"
                  ],
                  "description": "Closed documentation URL corresponding to this error code."
                },
                "request_id": {
                  "type": "string"
                },
                "details": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ErrorDetail"
                  }
                }
              },
              "required": [
                "code",
                "message",
                "doc_url",
                "request_id"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "error"
          ],
          "additionalProperties": false
        },
        "NotFoundEncoded": {
          "type": "object",
          "properties": {
            "error": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string",
                  "enum": [
                    "not_found"
                  ],
                  "description": "Closed error discriminator for this HTTP error variant."
                },
                "message": {
                  "type": "string"
                },
                "doc_url": {
                  "type": "string",
                  "enum": [
                    "https://api.buchungapp.com/v1/docs#errors/not_found"
                  ],
                  "description": "Closed documentation URL corresponding to this error code."
                },
                "request_id": {
                  "type": "string"
                },
                "details": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ErrorDetail"
                  }
                }
              },
              "required": [
                "code",
                "message",
                "doc_url",
                "request_id"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "error"
          ],
          "additionalProperties": false
        },
        "InternalErrorEncoded": {
          "type": "object",
          "properties": {
            "error": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string",
                  "enum": [
                    "internal_error"
                  ],
                  "description": "Closed error discriminator for this HTTP error variant."
                },
                "message": {
                  "type": "string"
                },
                "doc_url": {
                  "type": "string",
                  "enum": [
                    "https://api.buchungapp.com/v1/docs#errors/internal_error"
                  ],
                  "description": "Closed documentation URL corresponding to this error code."
                },
                "request_id": {
                  "type": "string"
                },
                "details": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ErrorDetail"
                  }
                }
              },
              "required": [
                "code",
                "message",
                "doc_url",
                "request_id"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "error"
          ],
          "additionalProperties": false
        },
        "ServiceUnavailableEncoded": {
          "type": "object",
          "properties": {
            "error": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string",
                  "enum": [
                    "service_unavailable"
                  ],
                  "description": "Closed error discriminator for this HTTP error variant."
                },
                "message": {
                  "type": "string"
                },
                "doc_url": {
                  "type": "string",
                  "enum": [
                    "https://api.buchungapp.com/v1/docs#errors/service_unavailable"
                  ],
                  "description": "Closed documentation URL corresponding to this error code."
                },
                "request_id": {
                  "type": "string"
                },
                "details": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ErrorDetail"
                  }
                }
              },
              "required": [
                "code",
                "message",
                "doc_url",
                "request_id"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "error"
          ],
          "additionalProperties": false
        },
        "RateLimitedEncoded": {
          "type": "object",
          "properties": {
            "error": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string",
                  "enum": [
                    "rate_limited"
                  ],
                  "description": "Closed error discriminator for this HTTP error variant."
                },
                "message": {
                  "type": "string"
                },
                "doc_url": {
                  "type": "string",
                  "enum": [
                    "https://api.buchungapp.com/v1/docs#errors/rate_limited"
                  ],
                  "description": "Closed documentation URL corresponding to this error code."
                },
                "request_id": {
                  "type": "string"
                },
                "details": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ErrorDetail"
                  }
                }
              },
              "required": [
                "code",
                "message",
                "doc_url",
                "request_id"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "error"
          ],
          "additionalProperties": false
        },
        "ValidationFailedEncoded": {
          "type": "object",
          "properties": {
            "error": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string",
                  "enum": [
                    "validation_failed"
                  ],
                  "description": "Closed error discriminator for this HTTP error variant."
                },
                "message": {
                  "type": "string"
                },
                "doc_url": {
                  "type": "string",
                  "enum": [
                    "https://api.buchungapp.com/v1/docs#errors/validation_failed"
                  ],
                  "description": "Closed documentation URL corresponding to this error code."
                },
                "request_id": {
                  "type": "string"
                },
                "details": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ErrorDetail"
                  }
                }
              },
              "required": [
                "code",
                "message",
                "doc_url",
                "request_id"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "error"
          ],
          "additionalProperties": false
        },
        "ExpectedRevision": {
          "type": "object",
          "properties": {
            "expectedRevision": {
              "$ref": "#/components/schemas/Revision"
            }
          },
          "required": [
            "expectedRevision"
          ],
          "additionalProperties": false
        }
      },
      "securitySchemes": {
        "integrationBearer": {
          "description": "Machine integration credential: Authorization: Bearer bg_it_<32 lowercase hex characters> (^bg_it_[0-9a-f]{32}$). Resolved uncached on each request. Middleware binds the resolved principal once; handlers run under it and never re-derive authority. The request context includes credentialId for per-request logging alongside machineId, operatorId, organizationId and capabilities; the principal is opaque and server-owned. Storefront channel keys never authorize management operations; machine credentials never authorize storefront checkout handoffs. Invalid, expired, revoked, disabled or ungranted credentials return 401 unauthorized.",
          "type": "http",
          "scheme": "Bearer"
        }
      }
    }
  }
}
```
