TenanciTenanci

Help centerDevelopers

Getting started with the API

Base URL, API key authentication, scopes, errors, pagination, idempotency and rate limits of the Tenanci v2 API.

Everything you do in the dashboard can also be done through the API: create projects, connect a new customer's domain the moment they sign up, publish their branding, read analytics. That's how a SaaS puts every customer on their own domain without anyone opening the dashboard.

Base URL

Every call goes to:

https://api.tenanci.com/v2

The API speaks JSON (Content-Type: application/json) and uses standard HTTP status codes: 200/201 means it worked, 4xx is something about the request, 5xx is on us.

Authentication

Create a key under API keys and send it with every request, in either of these ways:

curl https://api.tenanci.com/v2/me -H "Authorization: Bearer tnc_live_xxxxxxxx_xxxxxxxxxxxx"

Scopes and project

Each key has scopes and can be locked to a single project:

Scope Allows
domains:read read projects, domains, DNS, events, analytics and each domain's settings
domains:write create, change and delete projects, domains, rules and each domain's settings
projects:read read the status page, the customer portal and the Scale plan APIs (AuthMesh and Gateway)
projects:write change the status page, the customer portal and the Scale plan APIs

The scope each operation needs is shown in the API reference.

A key restricted to a project only sees that project and its domains; anything else returns 403. That's the recommended setup for integrations: if the key leaks, the damage stays contained.

Errors

Every error has the same shape:

{
  "error": {
    "code": "validation_error",
    "message": "Invalid data",
    "details": [{ "path": "hostname", "message": "Invalid input: expected string, received undefined" }]
  }
}

Branch on code (stable); message is for humans and comes in the language you ask for:

  • Accept-Language: en (or ?lang=en in the URL) for English, Accept-Language: pt-BR (or ?lang=pt) for Portuguese;
  • without one (no header, or just *), the language of the organization that owns the key applies (its Email language, see), then Portuguese;
  • the validation messages in details follow the same language. code never changes with the language.
cURL
curl https://api.tenanci.com/v2/domains/dom_nope -H "Authorization: Bearer tnc_live_xxxxxxxx_xxxxxxxxxxxx" -H "Accept-Language: en"
# → { "error": { "code": "not_found", "message": "Domain not found" } }

The most common ones:

HTTP code When
400 validation_error, invalid_json invalid body or parameter (details says which field)
401 unauthorized missing, invalid or revoked key
402 subscription_required the organization has no active subscription
403 forbidden missing scope, or the key belongs to another project
403 feature_not_in_plan the feature needs a higher plan (details.requiredPlan says which; see plans)
404 not_found doesn't exist (or isn't in your organization)
409 domain_exists, hostname_taken, domain_limit_reached the domain is already registered, belongs to another account, or the plan can't fit more domains
422 idempotency_key_reused the same Idempotency-Key was sent with a different body
429 rate_limited too many requests this minute

Lists and pagination

Lists return items and nextCursor. While nextCursor isn't null, ask for the next page with ?cursor=:

curl "https://api.tenanci.com/v2/domains?projectId=prj_8f3k2m&limit=100" -H "Authorization: Bearer tnc_live_xxxxxxxx_xxxxxxxxxxxx"
# → { "items": [ ... ], "nextCursor": "dom_9x2..." }
curl "https://api.tenanci.com/v2/domains?projectId=prj_8f3k2m&limit=100&cursor=dom_9x2..." -H "Authorization: Bearer tnc_live_xxxxxxxx_xxxxxxxxxxxx"

Retry without duplicates (Idempotency-Key)

Networks drop and timeouts happen. To create something safely, send a unique Idempotency-Key per operation (your own order id, for example). Retrying with the same key returns the same response instead of creating another domain.

cURL
curl -X POST https://api.tenanci.com/v2/domains \
  -H "Authorization: Bearer tnc_live_xxxxxxxx_xxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-48213" \
  -d '{"projectId":"prj_8f3k2m","hostname":"joesbarbershop.com"}'

Rate limits

Each key can make up to 600 requests per minute. Every response carries X-RateLimit-Limit and X-RateLimit-Remaining; over the limit you get 429 with Retry-After (seconds until you can try again).

Next steps