Bulk create or upsert tenants
/tenant/bulk
Create or upsert up to 1000 tenants in a single request. Use this for migrations from another platform, seeding staging with a known list of customers, or onboarding a batch of new tenants at once.
Each item may only include id (required), name, and metadata. Extra fields are rejected.
Set mode to control what happens when an id already exists in the environment:
-
insert(default) — skips ids that already exist and reports them inskippedwith reasonalready_exists. Re-running the same request is idempotent. -
upsert— updates thenameandmetadataof ids that already exist; omitted fields keep their current values. The response splits tenants intocreatedandupdated(skippedis empty).
All tenants in a request are written together: if any tenant fails to write, none of the request's tenants are written. Up to 1000 tenants per request.
Request Body
Environment to create the tenants in. Required for session auth; ignored for API tokens. Applied to every row in the batch — the endpoint does not let you mix environments in one request.
8a2b104d-74a6-47f2-b93e-c6b611e82391Collision behaviour. insert skips existing ids; upsert updates name/metadata on existing ids.
insertupsert
The list of tenants to create or upsert. Max 1000 per request — split larger inputs client-side. Only id, name, and metadata are allowed per item.
Tenant id. Free-form up to 255 characters, excluding control characters, leading or trailing whitespace, and the dot segments . and ...
acme-corpFree-form JSON object. Defaults to {} when omitted on insert; kept unchanged when omitted on upsert of an existing row.
{"tier":"gold"}Display name. Defaults to id when omitted on insert; kept unchanged when omitted on upsert of an existing row.
Acme CorpResponse Body
The tenants that were newly inserted.
The date and time when the tenant was created.
2026-07-02T09:14:03.117ZThe environment this tenant belongs to.
8a2b104d-74a6-47f2-b93e-c6b611e82391The tenant identifier — caller-chosen and immutable once created. Unique within its environment, so the same value can exist independently in each environment (for example development, staging and production). Free-form up to 255 characters: whatever you already use to identify a customer, including /, spaces and non-ASCII. The only values rejected are the ones no URL path segment can carry — control characters, leading or trailing whitespace, and the dot segments . and ...
acme-corpFree-form JSON object stored verbatim. Truto does not interpret this field — use it for tier, region, billing plan, or any other customer attribute your app cares about.
{"tier":"gold","region":"wnam"}Display name shown in the dashboard. Defaults to the tenant id on create if not supplied; can be edited later via PATCH /tenant/{id}.
Acme CorpThe date and time when the tenant was last updated.
2026-07-02T09:14:03.117ZTenants that were not created because a tenant with the same id already exists in the environment. Only populated when mode is insert (the default). Empty when mode is upsert.
The tenant id that was skipped.
acme-corpWhy the tenant was skipped.
already_existsalready_exists
Tenants that already existed and were updated. Only populated when mode is upsert; always empty for insert.
The date and time when the tenant was created.
2026-07-02T09:14:03.117ZThe environment this tenant belongs to.
8a2b104d-74a6-47f2-b93e-c6b611e82391The tenant identifier — caller-chosen and immutable once created. Unique within its environment, so the same value can exist independently in each environment (for example development, staging and production). Free-form up to 255 characters: whatever you already use to identify a customer, including /, spaces and non-ASCII. The only values rejected are the ones no URL path segment can carry — control characters, leading or trailing whitespace, and the dot segments . and ...
acme-corpFree-form JSON object stored verbatim. Truto does not interpret this field — use it for tier, region, billing plan, or any other customer attribute your app cares about.
{"tier":"gold","region":"wnam"}Display name shown in the dashboard. Defaults to the tenant id on create if not supplied; can be edited later via PATCH /tenant/{id}.
Acme CorpThe date and time when the tenant was last updated.
2026-07-02T09:14:03.117ZErrors
| Status | Description |
|---|---|
400 | Request body violates the schema (missing tenants, more than 1000 items, invalid tenant id, unknown fields, invalid mode, missing environment_id on session auth). |
curl -X POST 'https://api.truto.one/tenant/bulk' \
-H 'Authorization: Bearer <your_api_token>' \
-H 'Content-Type: application/json' \
-d '{
"mode": "insert",
"tenants": [],
"environment_id": "8a2b104d-74a6-47f2-b93e-c6b611e82391"
}'const body = {
"mode": "insert",
"tenants": [],
"environment_id": "8a2b104d-74a6-47f2-b93e-c6b611e82391"
};
const response = await fetch('https://api.truto.one/tenant/bulk', {
method: 'POST',
headers: {
'Authorization': 'Bearer <your_api_token>',
'Content-Type': 'application/json',
},
body: JSON.stringify(body),
});
const data = await response.json();
console.log(data);import requests
url = "https://api.truto.one/tenant/bulk"
headers = {
"Authorization": "Bearer <your_api_token>",
"Content-Type": "application/json",
}
params = {
}
payload = {
"mode": "insert",
"tenants": [],
"environment_id": "8a2b104d-74a6-47f2-b93e-c6b611e82391"
}
response = requests.post(url, headers=headers, params=params, json=payload)
print(response.json())