TenanciTenanci

Help centerAPI referenceTenant context

Tenant context

Who the customer behind each domain is, sent signed to your origin.

Generate/rotate the signing secret

POST/projects/{id}/tenant-secretdomains:write

Secret used to sign the X-Tenanci-Tenant header. It's only shown in this response: store it in your app's backend.

Parameters

  • idpath · stringrequired

    Resource id (prj_…, dom_…)

Request

cURL
curl -X POST "https://api.tenanci.com/v2/projects/prj_8f3k2m/tenant-secret" \
  -H "Authorization: Bearer tnc_live_xxxxxxxx_xxxxxxxxxxxx"

Response 200

{
  "secret": "tsk_Q2xv…"
}

Get the domain's tenant

GET/domains/{id}/tenantdomains:read

Parameters

  • idpath · stringrequired

    Resource id (prj_…, dom_…)

Request

cURL
curl "https://api.tenanci.com/v2/domains/dom_4h7n1q/tenant" \
  -H "Authorization: Bearer tnc_live_xxxxxxxx_xxxxxxxxxxxx"

Response 200

{
  "id": "barbearia-123",
  "data": {
    "name": "Barbearia do Zé",
    "plan": "pro"
  },
  "expose": false,
  "projectHasSecret": true
}

Set the domain's tenant

PUT/domains/{id}/tenantdomains:write

The origin starts receiving X-Tenanci-Tenant (signed) on every request to this domain.

Parameters

  • idpath · stringrequired

    Resource id (prj_…, dom_…)

Body

  • idstring | null

    Customer id in your system (null removes it).

  • dataRecord<string, string | number | boolean | null>

    Customer data sent to the origin (name, plan…).

  • exposeboolean

    Also expose as window.TENANCI in the browser.

Request

cURL
curl -X PUT "https://api.tenanci.com/v2/domains/dom_4h7n1q/tenant" \
  -H "Authorization: Bearer tnc_live_xxxxxxxx_xxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{"id":"barbearia-123","data":{"name":"Barbearia do Zé","plan":"pro"},"expose":true}'

Response 200

{
  "id": "barbearia-123",
  "data": {
    "name": "Barbearia do Zé",
    "plan": "pro"
  },
  "expose": true
}