API · v1 · stable
CODEMETA OSDeveloper Center
EN
Open console

POST /v1/contracts/{id}/cancel

POST/v1/contracts/{id}/cancel

Cancels a contract — immediately or on a specific date. Both fields in the body are optional: effectiveDate (YYYY-MM-DD) is the last valid contract day, reason is free text of up to 500 characters.

Without effectiveDate (or with today’s date in the tenant’s time zone), the contract ends immediately: status becomes CANCELLED, and cancelledAt is set. With a date in the future, the contract stays ACTIVE or EXPIRING — billing, task series and ticket rules continue to run until the effective date. On the day after, a daily background job sets the status to CANCELLED. Billing periods that begin only after the effective date are no longer invoiced; a period that begins on or before the effective date is billed in full (no pro-rata billing).

The cancellation is recorded in cancellation.cancellationRequestedAt, cancellationRequestedBy, cancellationReason and cancellationEffectiveDate and is traceable via the audit history. Drafts (DRAFT, PENDING_APPROVAL) have no term and are always discarded immediately — a future date there results in a 422.

Response codes: 422 cancellation-deadline-passed (notice period expired), 422 cancellation-pending (a cancellation is already scheduled — first withdraw it via withdraw-cancellation), 422 cancellation-date-in-past, 422 cancellation-date-after-end, 422 cancellation-date-not-allowed-for-draft, 400 for a date that is not YYYY-MM-DD.

Data model

This operation works on the entity Contract (contract). All 57 fields — type, validation, required status, relationships — are listed in the schema reference.

Path parameters

NameTypeDescription
idrequiredstring

Example

curl -X POST https://api.codemeta-os.de/v1/contracts/{id}/cancel \
  -H "X-Tenant-Id: $TENANT" \
  -H "Content-Type: application/json" \
  -b cookies.txt \
  -d '{
  "effectiveDate": "2026-12-31",
  "reason": "Wechsel zum Wettbewerber"
}'
const result = await cm.contracts.post({
  "effectiveDate": "2026-12-31",
  "reason": "Wechsel zum Wettbewerber"
});

Best practice

For an immediate cancellation, do not send an effectiveDate. The server determines “today” in the tenant’s time zone; a client-computed date can be off by one day around midnight and turn an immediate cancellation into a scheduled one.

Evaluate cancellation.cancellationEffectiveDate in the response, not just status: for a cancellation on a specific date, the contract is still ACTIVE after the call. You do not change a scheduled cancellation with a second call; instead, withdraw it via POST /v1/contracts/\{id\}/withdraw-cancellation and then cancel again; renew is also blocked until then.

Response codes

HTTP Meaning
200 Default Response

Search