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/apiAuthentication
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.
{
"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
}
]
}| Field | Type | Required | Description |
|---|---|---|---|
apiKey | string | Required | The project API key. |
snapshotLabel | string | Required | before, after or periodic. |
collectedAt | ISO 8601 UTC | Optional | When the snapshot was measured. Required when chunkCount is greater than 1; defaults to the time of the request otherwise. |
chunkIndex | integer ≥ 1 | Optional | Position of this request in the snapshot. Defaults to 1. |
chunkCount | integer ≥ 1 | Optional | Total requests in the snapshot. Defaults to 1. chunkIndex must not exceed it. |
tables | array, at most 2000 | Required | The measured tables (below). |
Table object
| Field | Type | Required | Description |
|---|---|---|---|
tableName | string, 1–256 | Required | Table name. A table outside the dbo schema is sent as schema.Table, so equal names in different schemas stay distinct. |
recordCount | integer ≥ 0 | Required | Number of rows. |
dataSizeMB | number ≥ 0 | Required | Data size in megabytes. Decimals are meaningful — send 0.6, not 0. |
indexSizeMB | number ≥ 0 | Required | Index size in megabytes. |
totalSizeMB | number ≥ 0 | Required | Total size in megabytes. |
dataAgeMonths | integer ≥ 0 | Optional | Age 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. chunkIndexruns from 1 tochunkCount. The request withchunkIndexequal tochunkCountcloses 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
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"
}
}cleanupSessionis present when this snapshot opened or closed a cleanup session (PENDINGafter abefore,COMPLETEDafter anafter). An automatically detected cleanup adds"autoDetected": true.cleanupSessionSkippedis a string, present when a comparison was refused — for exampleSnapshot covers 4800 tables, the before snapshot covered 5300 — not comparable. The response is still HTTP 200: the data was stored.
Errors and rate limits
| Status | Body | Meaning |
|---|---|---|
| 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. |
| 429 | Rate limited | Too 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).
{
"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"
}
]
}| Field | Type | Description |
|---|---|---|
tableName | string | Table name, spelled as in the snapshot upload. |
calendarDate | YYYY-MM-DD | The calendar day, in the time zone of the company. |
recordCount | integer ≥ 0 | Rows on that day. |
dataSizeMB, indexSizeMB, totalSizeMB | number ≥ 0 | Sizes in megabytes. |
recordSource | string | measured for a real measurement, interpolated for an estimate. The portal draws estimates dashed. |
interpolationMethod | string or null | How 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
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.
| Mode | How 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. |
| Auto | Send 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
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.