Contract End Date (Contracts)

v2.7.0 · CRUD · Contracts & Subscriptions

Contracts

Read, create, update, and delete contracts and subscriptions with attributes, domains, status history, and linked invoices. A separate sub-endpoint changes the status.

GET    /Export/JSON/contracts
GET    /Export/JSON/contract/{id}
POST   /Import/JSON/contracts
PUT    /Import/JSON/contracts
PUT    /Import/JSON/contracts/{id}/status
DELETE /Delete/JSON/contract/{id}

Endpoints

MethodEndpointScopeDescription
GET/Export/JSON/contractscontracts:readAll contracts, in ascending order of ID (with filters)
GET/Export/JSON/contract/{id}contracts:readA single contract; without a match, HTTP 200 with an empty data
GET/Export/JSON/contracts/{von}:{bis}, /contracts/{von}:contracts:readID range or open range
GET/Export/JSON/contracts/{id}contracts:read⚠️ Plural: all contracts from this ID onward, not just one
POST/Import/JSON/contractscontracts:writeCreate new contracts
PUT/Import/JSON/contractscontracts:writeUpdate existing contracts
PUT/Import/JSON/contracts/{id}/statuscontracts:writeChange only the status, with an entry in the status history
DELETE/Delete/JSON/contract/{id}contracts:deleteDelete a contract, including its attributes, domains, and status history
DELETE/Delete/JSON/contractscontracts:deleteMultiple contracts via JSON body {"data": [{"contracts_id": …}]}
Changed in v2.122.12: A range is written as /contracts/{von}:{bis}. Up to v2.122.11, /contracts/10/20 silently returned the contracts from 10 onward without an upper bound; it now returns HTTP 400 INVALID_RANGE, as does any other segment that is neither an integer nor a range (/contract/10x, /contract/10.0). Leading/trailing whitespace around the ID is ignored. Rules: Export API, section “Path segment”.

Query filter (GET)

ParameterDescriptionExample
?status=ID of a contract status; the shop’s statuses are listed in contracts_statuses[] of every response?status=1
?customer_id=Customer ID?customer_id=42
?product_id=Product ID?product_id=100
?interval=Billings per year: 1 annually, 2 semi-annually, 3 three times a year, 4 quarterly, 6 six times a year, 12 monthly?interval=12
?date_from=, ?date_to=Contract date (contracts_date) from or to?date_from=2025-01-01
?active=1only contracts without a recorded cancellation date (contracts_cancellation_date_effective empty); a future cancellation date also excludes the contract?active=1

Multiple filters are combined. An unusable value returns HTTP 400 INVALID_FILTER_VALUE, for example ?interval=5 (since v2.122.10). Since v2.122.12, leading/trailing whitespace is ignored, and an empty value means “not set”.


Data Structure

Every contract carries these fields. Status and item names are returned in German.

GroupFields
Identifier and statuscontracts_id, contracts_status_id, contracts_status_name
Customercontracts_customers_id, customer_name, customer_email, contracts_customers_address_book_id, contracts_shipping_address_book_id
Item and pricecontracts_products_id, product_name, product_model, contracts_products_quantity, contracts_products_tax, contracts_price, contracts_final_price, contracts_discount, contracts_use_current_price
Billingcontracts_interval and contracts_period_interval (values as for ?interval=, each with an additional field …_text containing the label), contracts_months, contracts_next_order_date, contracts_payment_class
Periodscontracts_date; term contracts_current_term_date_begin/_end, billing period contracts_current_period_date_begin/_end, last billed contracts_last_billed_term_date_begin/_end and contracts_last_billed_period_date_begin/_end
Cancellationcontracts_cancellation_date_received, contracts_cancellation_date_effective
Domain and licensecontracts_domain_id, contracts_domain_name, contracts_overwrite_domain, contracts_xolic_id
Miscellaneouscontracts_comment, contracts_template, contracts_error_flag, contracts_is_standalone

Nested data

ListContent per entry
attributes[]Attributes of the contract item: contracts_products_attributes_id, contracts_products_id, products_options, products_options_values, options_values_price, detail_id
domains[]contracts_domains_id, contracts_domains_domain_name, contracts_domains_date_paid, contracts_domains_date_termination, contracts_domains_provider, contracts_domains_exclusive, contracts_domains_cost
status_history[]newest first: status_history_id, status_id, status_name, date_added, customer_notified, comments, user_id
orders[]linked invoices, most recent link first: orders_id, date_created, date_purchased, orders_status

Alongside data, every response contains contracts_statuses[] with the shop’s contract statuses that have a German name (status_id, status_name, status_label, status_active, status_is_default).


Import (POST/PUT)

  • POST creates and requires contracts_customers_id and contracts_products_id of an existing customer or item. A contracts_id sent along that already exists makes the record fail.
  • PUT updates and requires the contracts_id of an existing contract. Only the fields sent are written.
  • The fields of the data structure are writable except the names and texts (contracts_status_name, customer_name, customer_email, product_name, product_model, contracts_domain_name, …_text). If you send an export back, the import reports these as unknown fields (UNKNOWN_FIELD), as well as the lists status_history[] and orders[] and the identifiers contracts_products_attributes_id and contracts_products_id in attributes[] and contracts_domains_id in domains[]. The import skips them and writes the remaining fields; remove these fields before sending the data back, and the response contains no warnings. Date fields as YYYY-MM-DD, the billing period fields (…_period_date_…) as YYYY-MM-DD HH:MM:SS; null or empty clears them.
  • contracts_interval accepts only 1, 2, 3, 4, 6, or 12; otherwise, the record fails.
  • attributes[] accepts products_options, products_options_values, options_values_price, and detail_id, domains[] the keys contracts_domains_… without contracts_domains_id. With PUT, a list sent along replaces all previous entries.
  • status as an object {"status_id": …, "comments": "…", "customer_notified": 0} sets the status and writes an entry to the status history. v2.122.13 If status_id is not a contract status of the shop (section “Contract status” below), not an integer, or missing, the import writes the record without the status and reports the warning CONTRACT_STATUS_UNKNOWN; the record counts as created or updated.
  • contracts_status_id directly on the contract sets the status without an entry in the status history. v2.122.13 A value that is not a contract status is not written, but the other fields are, with the same warning. For a status change with history, use status or the sub-endpoint /status.
  • ⚠️ A set contracts_cancellation_date_effective can take effect at the next run of the automatic contract termination.

Example

curl -s -X POST "https://shop.de/xpanel/xoport/Import/JSON/contracts" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "contracts",
    "data": [{
      "contracts_customers_id": 42,
      "contracts_products_id": 100,
      "contracts_interval": 12,
      "contracts_price": "29.90",
      "contracts_date": "2026-11-01",
      "attributes": [
        {"products_options": "Lizenztyp", "products_options_values": "Enterprise"}
      ],
      "domains": [
        {"contracts_domains_domain_name": "kunde.de"}
      ],
      "status": {"status_id": 1, "comments": "Angelegt per API"}
    }]
  }'

Change status (PUT)

PUT /Import/JSON/contracts/{id}/status with the scope contracts:write. status_id is required, comments and customer_notified are optional. Without status_id the response is HTTP 400 MISSING_FIELD, for a status_id that is not a contract status of the shop or not an integer HTTP 400 INVALID_STATUS with the valid IDs in error.valid_status_ids (since v2.122.13, section “Contract status”), and for an unknown contract HTTP 404 NOT_FOUND. In all three cases, the contract remains unchanged.

curl -s -X PUT "https://shop.de/xpanel/xoport/Import/JSON/contracts/1/status" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"status_id": 3, "comments": "Kündigung per API", "customer_notified": 0}'

# Response
{
  "success": true,
  "type": "contracts_status",
  "contracts_id": 1,
  "previous_status_id": 1,
  "new_status_id": 3,
  …
}

If the contract has an effective cancellation date, the response also contains warning: the automatic contract termination can overwrite the status later.


Contract status v2.122.13

Every contract status of the shop is valid for status_id, status.status_id and contracts_status_id: the statuses of the table status with type = 'contracts', which the backend also reads, in every language, including deactivated ones (status_active = 0); these are only hidden from the selection in the backend. Order statuses (/order_statuses) are not contract statuses. Which IDs apply differs from shop to shop: read them from contracts_statuses[] of GET /Export/JSON/contracts or from error.valid_status_ids. contracts_statuses[] lists only the statuses with a German name; a status without a German name is still valid.

The ID is an integer, as a number or as a string of digits (54, "54"; leading or trailing whitespace does not count). true, [65], "54abc", "1e3", 54.9 or 54.0 are not IDs.

Write pathNo valid contract status
PUT /Import/JSON/contracts/{id}/statusHTTP 400 INVALID_STATUS, error.valid_status_ids lists the valid IDs; the contract remains unchanged
Contract import, status.status_id (also status without status_id, such as "status": 54 or "status": {})Record written, status and status history unchanged, warning CONTRACT_STATUS_UNKNOWN with field = status.status_id or status; "status": null counts as not sent
Contract import, contracts_status_idField not written (stays empty on creation), other fields written, warning CONTRACT_STATUS_UNKNOWN with field = contracts_status_id
HTTP 400
{
  "success": false,
  "api_version": "2.122.13",
  "error": {
    "code": "INVALID_STATUS",
    "message": "status_id 1 is not a contract status. Valid: 7, 3, 12 (…)",
    "valid_status_ids": [7, 3, 12]
  }
}

In the contract import, the record still counts as inserted or updated. The warning appears in warnings[] of the response and on the record’s entry in records[]:

"warnings": [
  {
    "type": "CONTRACT_STATUS_UNKNOWN",
    "field": "status.status_id",
    "entity": "contracts",
    "contracts_id": 42,
    "message": "Contract 42: status.status_id ignored — status.status_id 1 is not a contract status. Valid: 7, 3, 12 (…)",
    "first_occurrence": "record 1"
  }
]
Changed in v2.122.13: Up to v2.122.12, the sub-endpoint /status and the object status checked against the order statuses (orders_status). A contract status that did not also exist as an order status resulted in HTTP 400 at the sub-endpoint and was silently skipped in the import; an ID that existed only as an order status was written as a contract status, at the sub-endpoint with the name of the order status in new_status_name. contracts_status_id was written unchecked ("abc" as 0, true as 1), and values such as "1e3" or 54.9 counted as 1000 and 54 respectively. ⚠️ If you send order status IDs as contract statuses, you now get HTTP 400 or the warning: use the IDs from contracts_statuses[]. new_status_name now contains the name of the contract status.

Delete (DELETE)

This deletes the contract, its attributes and domains, its status history, and its links to invoices and projects. The invoices and projects themselves are kept.

No lock for open invoices: The contract is deleted even if invoices are linked to it or still open, as when deleting in the backend. Afterwards the link is gone, and a direct debit via SEPA mandate no longer reaches these invoices. Check the invoices beforehand: the linked ones are listed in orders[] of GET /Export/JSON/contract/{id}, each with its order status orders_status. Whether a status counts as paid is shown by is_paid in GET /Export/JSON/order_statuses (Orders, section “Order Status Master Data”).
# One contract
curl -s -X DELETE "https://shop.de/xpanel/xoport/Delete/JSON/contract/1" \
  -H "Authorization: Bearer $TOKEN"

# Multiple contracts
curl -s -X DELETE "https://shop.de/xpanel/xoport/Delete/JSON/contracts" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"data": [{"contracts_id": 1}, {"contracts_id": 2}]}'
  • For a single-record call, an unknown contract returns HTTP 404 NOT_FOUND. In a batch, deleted IDs are listed in deleted_ids, IDs not found in errors[].
  • A body without data[].contracts_id, for example {"ids": [1, 2]}, deletes nothing and returns HTTP 400 MISSING_DATA.

OAuth2 scopes

ScopePermission
contracts:readRead contracts
contracts:writeCreate and update contracts, including the status
contracts:deleteDelete contracts