Skip to content
Back to Documentation

API reference

The HTTP contract between a D365 environment and the portal. You only need this page if you write your own integration; the SIMSTSizeBase model already speaks it.

Overview

Base URL

https://tsize.sims-service.com/api

Authentication

Your project's API key, in the apiKey field of the JSON body. There is no session and no header.

Format

Content-Type: application/json, UTF-8.

Keys

sk_ plus 32 characters. Create them in your project; a project can have several active keys.

Sending it from D365? The model does all of this for you — see the D365 setup page.

POST /api/statistics

Uploads one snapshot of table sizes — or one chunk of it. Sending the same snapshot again is safe: rows are replaced, not duplicated.

Request body
{
  "apiKey": "sk_your_project_api_key",
  "snapshotLabel": "periodic",
  "collectedAt": "2026-09-24T02:00:00Z",
  "chunkIndex": 1,
  "chunkCount": 1,
  "tables": [
    {
      "tableName": "BatchJobHistory",
      "recordCount": 1500000,
      "dataSizeMB": 245.5,
      "indexSizeMB": 89.2,
      "totalSizeMB": 334.7,
      "dataAgeMonths": 36
    },
    {
      "tableName": "custom.MyStagingTable",
      "recordCount": 41000,
      "dataSizeMB": 12.75,
      "indexSizeMB": 1.5,
      "totalSizeMB": 14.25
    }
  ]
}
Top-level fields of the statistics request
FieldTypeRequiredDescription
apiKeystringRequiredThe project API key.
snapshotLabelstringRequiredbefore, after or periodic.
collectedAtISO 8601 UTCOptionalWhen the snapshot was measured. Required when chunkCount is greater than 1; defaults to the time of the request otherwise.
chunkIndexinteger ≥ 1OptionalPosition of this request in the snapshot. Defaults to 1.
chunkCountinteger ≥ 1OptionalTotal requests in the snapshot. Defaults to 1. chunkIndex must not exceed it.
tablesarray, at most 2000RequiredThe measured tables (below).

Table object

Fields of one table in the tables array
FieldTypeRequiredDescription
tableNamestring, 1–256RequiredTable name. A table outside the dbo schema is sent as schema.Table, so equal names in different schemas stay distinct.
recordCountinteger ≥ 0RequiredNumber of rows.
dataSizeMBnumber ≥ 0RequiredData size in megabytes. Decimals are meaningful — send 0.6, not 0.
indexSizeMBnumber ≥ 0RequiredIndex size in megabytes.
totalSizeMBnumber ≥ 0RequiredTotal size in megabytes.
dataAgeMonthsinteger ≥ 0OptionalAge of the oldest row in months. Send it only for tables that have a creation date.

Chunked uploads

A real D365 database has thousands of tables, and one request takes at most 2000. A snapshot is therefore sent as several requests:

  • Every request of one snapshot carries the same collectedAt. It is the identity of the snapshot.
  • chunkIndex runs from 1 to chunkCount. The request with chunkIndex equal to chunkCount closes the snapshot.
  • Rows are stored on (project, tableName, collectedAt), so retrying a chunk — or the whole snapshot — is idempotent.
  • Before/after comparison and cleanup detection run only on the closing chunk, over the whole snapshot read back from storage.

Send the closing chunk last

A snapshot is complete only when its last chunk arrives. If chunk 3 of 3 is lost, the snapshot stays open and no comparison happens.

Responses

A chunk before the last (200)

{
  "success": true,
  "message": "Received chunk 1 of 3 (2000 tables)",
  "snapshotLabel": "periodic",
  "collectedAt": "2026-09-24T02:00:00.000Z",
  "chunkIndex": 1,
  "chunkCount": 3,
  "snapshotComplete": false
}

The closing chunk (200)

{
  "success": true,
  "message": "Snapshot complete: 5321 tables",
  "snapshotLabel": "after",
  "collectedAt": "2026-09-24T09:00:00.000Z",
  "chunkIndex": 3,
  "chunkCount": 3,
  "snapshotComplete": true,
  "snapshot": {
    "tableCount": 5321,
    "totalRecords": 812345678,
    "totalSizeMB": 431220.5
  },
  "cleanupSession": {
    "id": "abc123xyz",
    "status": "COMPLETED"
  }
}
  • cleanupSession is present when this snapshot opened or closed a cleanup session (PENDING after a before, COMPLETED after an after). An automatically detected cleanup adds "autoDetected": true.
  • cleanupSessionSkipped is a string, present when a comparison was refused — for example Snapshot covers 4800 tables, the before snapshot covered 5300 — not comparable. The response is still HTTP 200: the data was stored.

Errors and rate limits

Error responses of the statistics endpoints
StatusBodyMeaning
400{ "error": "Invalid payload", "details": [{ "path", "message" }] }The body failed validation; details names each field.
401{ "error": "Invalid API key" }No such key.
401{ "error": "Key revoked" }The key existed and has been revoked.
403{ "error": "Project is inactive" }The project is paused by its owner.
429Rate limitedToo many requests. The Retry-After header holds the seconds to wait.
500{ "error": "Internal server error" }A fault on our side. Retrying is safe.

Rate limit: 120 requests per minute per source address, and the same again per project. A snapshot of a large database is a burst of requests and can meet the ceiling; answer 429 by waiting the time in Retry-After and sending the same request again. The D365 model waits 15, 30, 45 and 60 seconds and gives up after five attempts.

POST /api/statistics/daily

Uploads the day-by-day series: one row per table per calendar day, either measured or estimated between two measurements. At most 5000 rows per request; rows are replaced on (project, tableName, calendarDate).

Request body
{
  "apiKey": "sk_your_project_api_key",
  "series": [
    {
      "tableName": "BatchJobHistory",
      "calendarDate": "2026-05-01",
      "recordCount": 1500000,
      "dataSizeMB": 245,
      "indexSizeMB": 89,
      "totalSizeMB": 334,
      "recordSource": "measured",
      "interpolationMethod": null
    },
    {
      "tableName": "BatchJobHistory",
      "calendarDate": "2026-05-02",
      "recordCount": 1500100,
      "dataSizeMB": 246,
      "indexSizeMB": 89,
      "totalSizeMB": 335,
      "recordSource": "interpolated",
      "interpolationMethod": "linear_between_facts"
    }
  ]
}
Fields of one row in the series array
FieldTypeDescription
tableNamestringTable name, spelled as in the snapshot upload.
calendarDateYYYY-MM-DDThe calendar day, in the time zone of the company.
recordCountinteger ≥ 0Rows on that day.
dataSizeMB, indexSizeMB, totalSizeMBnumber ≥ 0Sizes in megabytes.
recordSourcestringmeasured for a real measurement, interpolated for an estimate. The portal draws estimates dashed.
interpolationMethodstring or nullHow an estimate was derived, for example linear_between_facts. Null for measured rows.

Success is { "success": true, "rowsUpserted": 2, "projectId": "…" }. The errors are the ones above.

cURL example

Send a one-request snapshot
curl -X POST https://tsize.sims-service.com/api/statistics \
  -H "Content-Type: application/json" \
  -d '{
    "apiKey": "sk_your_project_api_key",
    "snapshotLabel": "before",
    "tables": [
      {
        "tableName": "BatchJobHistory",
        "recordCount": 5000000,
        "dataSizeMB": 1200.5,
        "indexSizeMB": 450.2,
        "totalSizeMB": 1650.7
      }
    ]
  }'

A GET on either endpoint returns a short description of it, handy as a reachability check that does not need a key.

Cleanup sessions

How a cleanup is measured depends on the mode chosen in your dashboard settings.

The two cleanup measurement modes
ModeHow it works
Manual (default)Send before — a session opens as PENDING. Clean. Send after — the session completes and the recovered records and size are calculated. In D365 the labels are Before cleanup and After cleanup.
AutoSend periodic snapshots regularly. When one is clearly smaller than the previous — at least 1000 records and 10 MB less, or at least 1 % less of both — the portal records a cleanup on its own.

Two snapshots are compared only if they are comparable

If the number of tables differs by more than 10 % between the two, the comparison is refused and reported in cleanupSessionSkipped. Otherwise a moved threshold or a lost chunk would be counted as freed space.

Good practice

  • Keep the key out of source control; keep one key per integration so you can revoke one.
  • Send every snapshot with a stable collectedAt — derive it from the measurement, not from the time of sending.
  • Retry on 429 and 5xx; never on 400 or 401.