TenanciTenanci

Help centerDevelopers

Migrating from API v1

v1 keeps working. Here's the v1 → v2 mapping, the new fields and before/after examples so you can migrate at your own pace.

If your integration uses the old API (/projects/:projectId/domains, request-config, Portuguese field names such as dominio and usa_config_personalizada), it keeps working: nobody is forced to migrate. But everything new (tenant context, SEO, marketing, analytics, extra domain packs, pagination) only exists in the v2 API. This page shows the equivalent of each call so you can migrate at your own pace, one route at a time.

What stays the same in v1

  • Same addresses (https://api.tenanci.com/projects/...), same Portuguese fields and same responses, down to loca_da_injecao (the local_da_injecao spelling is accepted too).
  • The same key. The token from the old dashboard shows up under API keys as Token da API (migrado do painel antigo), restricted to its project, and it works on v2 as well.
  • Old project and domain ids are still accepted, on v2 too.

A few security and consistency fixes already apply to v1:

  • the domain in the path must belong to the project in the path (otherwise 404);
  • PATCH only changes what you send, and status only turns the domain on or off (it never activates a domain without DNS and a certificate);
  • errors come with the right HTTP status (404, 409, 422…) in the { "mensagem", "codigo", "detalhes" } shape;
  • messages are still in Portuguese. Only when you ask for English (Accept-Language: en or ?lang=en) do the texts (mensagem, DNS instructions) come in English; field names and codigo don't change.

Base URL and authentication

v1 v2
Address https://api.tenanci.com https://api.tenanci.com/v2
Key X-API-Key or Authorization: Bearer the same
Scopes — per key (domains:read, domains:write…), see
Error { "mensagem", "codigo", "detalhes" } { "error": { "code", "message", "details" } }

v1's codigo values and v2's code values are the same (not_found, domain_exists, domain_limit_reached…).

Endpoint mapping

In v1 the config types were paths, headers and scripts; in v2 they're routes, headers and injections.

v1 v2
GET /projects/:projectId/domains GET /domains?projectId= (paginated)
GET /projects/:projectId/domains/:domainId GET /domains/:id (an object, not a 1-item list)
POST /projects/:projectId/domains POST /domains + rules via POST /domains/:id/rules/:kind
PATCH /projects/:projectId/domains/:domainId PATCH /domains/:id
DELETE /projects/:projectId/domains/:domainId DELETE /domains/:id (answers 204)
GET /projects/:projectId/request-config/:type GET /projects/:id/rules/:kind
POST /projects/:projectId/request-config/:type POST /projects/:id/rules/:kind
DELETE /projects/:projectId/request-config/:type/:configId DELETE /rules/:kind/:ruleId
GET /projects/:projectId/domains/:domainId/request-config/:type GET /domains/:id/rules/:kind (effective rules; ?effective=false for the domain's own only)
POST /projects/:projectId/domains/:domainId/request-config/:type POST /domains/:id/rules/:kind
DELETE /projects/:projectId/domains/:domainId/request-config/:type/:configId DELETE /rules/:kind/:ruleId
— PATCH /rules/:kind/:ruleId: edit, enable/disable and reorder a rule

Fields

v1 v2
cliente.dominio hostname
cliente.nome name
cliente.favicon + cliente.favicon_url faviconUrl (null removes the favicon)
cliente.usa_config_personalizada overrides: ["routes", "headers", "injections"] (or just the sections you want)
status: "Ativo" / "Inativo" (on PATCH) enabled: true / false
origem, destino source, destination and, new, mode: rewrite (default) or redirect
nome, valor name, value and, new, direction: response (default) or request
conteudo, loca_da_injecao content, injectAt: head (default) or body
id / id_cliente id (the old id stays in legacyId)

v1's status maps to these v2 statuses:

v1 v2
Aguardando Registro DNS pending_dns, verifying or issuing_cert
Ativo active
Inativo suspended (with enabled: false when you turned it off)
ERRO_VALIDACAO error (the reason is in statusReason)
REMOVIDO removed

Before and after: a domain with its own config

Before, on v1:

v1
curl -X POST https://api.tenanci.com/projects/prj_8f3k2m/domains \
  -H "X-API-Key: tnc_live_xxxxxxxx_xxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "cliente": { "dominio": "sunrealty.com", "nome": "Sun Realty", "usa_config_personalizada": true },
    "request_config": {
      "proxy_paths": [{ "origem": "/", "destino": "/agency/123" }], "custom_path_ativo": true,
      "custom_headers": [{ "nome": "X-Agency", "valor": "123" }], "custom_headers_ativo": true
    }
  }'

After, on v2:

# 1) the domain, with its own routes and headers (not inherited from the project)
curl -X POST https://api.tenanci.com/v2/domains \
  -H "Authorization: Bearer tnc_live_xxxxxxxx_xxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: agency-123" \
  -d '{"projectId":"prj_8f3k2m","hostname":"sunrealty.com","name":"Sun Realty","overrides":["routes","headers"],"tenant":{"id":"123"}}'
# → { "id": "dom_...", "status": "pending_dns", "dns": { "type": "A", ... }, ... }

# 2) and 3) the domain's rules
curl -X POST https://api.tenanci.com/v2/domains/dom_4h7n1q/rules/routes \
  -H "Authorization: Bearer tnc_live_xxxxxxxx_xxxxxxxxxxxx" -H "Content-Type: application/json" \
  -d '{"source":"/","destination":"/agency/123"}'
curl -X POST https://api.tenanci.com/v2/domains/dom_4h7n1q/rules/headers \
  -H "Authorization: Bearer tnc_live_xxxxxxxx_xxxxxxxxxxxx" -H "Content-Type: application/json" \
  -d '{"name":"X-Agency","value":"123"}'

The v2 response already carries the DNS record in dns (v1 returned it as text under certificado_ssl). See routes, headers and scripts.

Migration checklist

  1. Create a v2 key under API keys, restricted to the project.
  2. Point to https://api.tenanci.com/v2 and switch error handling to error.code.
  3. Replace the Portuguese fields using the Fields table, and the paths/scripts types with routes/injections.
  4. When listing, follow nextCursor (v2 is paginated; see).
  5. When getting a domain, read the object directly (v1 returned a 1-item list).
  6. Send an Idempotency-Key when creating domains (how it works).
  7. Replace repeated status polling with webhooks.
  8. When nothing calls v1 anymore, revoke the old token.