Semaphor

Get domain template

Returns the full template for a semantic domain: its datasets and fields, relationships, metrics, composed dimensions, and context.

The template is always returned in the 2.1 shape (schemaVersion: "2.1"), even when the domain was last saved in the 2.0 shape. The stored copy is upgraded the next time the domain is saved.

This endpoint requires write access to the domain (Author role or above), since templates are typically read in the context of editing.

If the stored template is corrupted or uses an unrecognized format, the endpoint returns 400 so you can replace it with a valid template.

GET
/api/v1/domains/{domainId}/template

Authorization

BearerAuth
AuthorizationBearer <token>

A project-scoped access token. Generate one via the Token API with your projectId and projectSecret.

In: header

Path Parameters

domainId*string

The unique identifier of the semantic domain.

Response Body

application/json

application/json

application/json

application/json

application/json

curl -X get "https://semaphor.cloud/api/v1/domains/domain_abc123/template"
{
  "template": {
    "schemaVersion": "2.1",
    "id": "domain_abc123",
    "name": "sales_metrics",
    "label": "Sales Metrics",
    "description": "Revenue and order tracking",
    "aiContext": "Revenue is net of refunds. Use order_date for time questions.",
    "datasets": [
      {
        "name": "orders",
        "label": "Orders",
        "description": "string",
        "aiContext": "Revenue is net of refunds. Use order_date for time questions.",
        "analyticsRole": "fact",
        "source": {
          "kind": "table",
          "connectionId": "conn_1",
          "connectionType": "PostgreSQL",
          "database": "analytics",
          "schema": "public",
          "table": "orders"
        },
        "primaryKey": [
          "order_id"
        ],
        "uniqueKeys": [
          [
            "order_number"
          ]
        ],
        "primaryDateField": "order_date",
        "fields": {
          "identifiers": [
            {
              "name": "amount",
              "label": "Amount",
              "description": "string",
              "aiContext": "Revenue is net of refunds. Use order_date for time questions.",
              "dataType": "number",
              "nativeDataType": "numeric(12,2)",
              "sourceField": "amount",
              "hidden": true,
              "tags": [
                "string"
              ],
              "type": "primary"
            }
          ],
          "facts": [
            {
              "name": "amount",
              "label": "Amount",
              "description": "string",
              "aiContext": "Revenue is net of refunds. Use order_date for time questions.",
              "dataType": "number",
              "nativeDataType": "numeric(12,2)",
              "sourceField": "amount",
              "hidden": true,
              "tags": [
                "string"
              ],
              "expression": "amount_cents / 100",
              "defaultAggregate": "SUM",
              "filters": [
                {
                  "field": "string",
                  "operator": "string",
                  "value": null
                }
              ],
              "format": null,
              "unit": "USD",
              "comparisonPolarity": "higher_is_better",
              "isDefault": true
            }
          ],
          "dimensions": [
            {
              "name": "amount",
              "label": "Amount",
              "description": "string",
              "aiContext": "Revenue is net of refunds. Use order_date for time questions.",
              "dataType": "number",
              "nativeDataType": "numeric(12,2)",
              "sourceField": "amount",
              "hidden": true,
              "tags": [
                "string"
              ],
              "expression": "string",
              "isDisplayField": true,
              "granularity": "second",
              "format": {
                "type": "temporal_bucket",
                "presentation": {
                  "mode": "auto"
                }
              }
            }
          ]
        }
      }
    ],
    "relationships": [
      {
        "id": "string",
        "name": "orders_to_customers",
        "description": "string",
        "aiContext": "Revenue is net of refunds. Use order_date for time questions.",
        "from": {
          "dataset": "orders",
          "fields": [
            "customer_id"
          ]
        },
        "to": {
          "dataset": "orders",
          "fields": [
            "customer_id"
          ]
        },
        "cardinality": "many_to_one",
        "defaultJoinType": "LEFT",
        "isAutoJoin": true,
        "joinPriority": 10,
        "isActive": true,
        "discoveredBy": "user",
        "confidence": "high"
      }
    ],
    "metrics": [
      {
        "name": "revenue",
        "dataset": "orders",
        "expression": "SUM(amount)",
        "label": "Revenue",
        "description": "string",
        "aiContext": "Revenue is net of refunds. Use order_date for time questions.",
        "dataType": "number",
        "nativeDataType": "string",
        "format": null,
        "unit": "string",
        "comparisonPolarity": "higher_is_better",
        "isDefault": true,
        "hidden": true,
        "tags": [
          "string"
        ]
      }
    ],
    "composedDimensions": [
      {
        "name": "order_month",
        "label": "Order Month",
        "description": "string",
        "aiContext": "Revenue is net of refunds. Use order_date for time questions.",
        "expression": "DATE_TRUNC('month', {order_date})",
        "inputs": {
          "order_date": {
            "dataset": "orders",
            "field": "order_date"
          }
        },
        "dataType": "string",
        "granularity": "second",
        "format": {
          "type": "temporal_bucket",
          "presentation": {
            "mode": "auto"
          }
        },
        "grainMapping": {
          "property1": "string",
          "property2": "string"
        }
      }
    ],
    "grainMappings": [
      {
        "sourceDimension": "order_month",
        "targetDataset": "returns",
        "targetColumn": "return_date"
      }
    ]
  }
}
{
  "error": "string",
  "details": {},
  "errors": [
    {
      "code": "row_expression_in_dataset_metric",
      "message": "margin works row by row. Add it as a fact (to aggregate) or a dimension (to group by).",
      "severity": "error",
      "hint": "string",
      "context": {}
    }
  ],
  "warnings": [
    {
      "code": "row_expression_in_dataset_metric",
      "message": "margin works row by row. Add it as a fact (to aggregate) or a dimension (to group by).",
      "severity": "error",
      "hint": "string",
      "context": {}
    }
  ]
}
{
  "error": "string",
  "details": {},
  "errors": [
    {
      "code": "row_expression_in_dataset_metric",
      "message": "margin works row by row. Add it as a fact (to aggregate) or a dimension (to group by).",
      "severity": "error",
      "hint": "string",
      "context": {}
    }
  ],
  "warnings": [
    {
      "code": "row_expression_in_dataset_metric",
      "message": "margin works row by row. Add it as a fact (to aggregate) or a dimension (to group by).",
      "severity": "error",
      "hint": "string",
      "context": {}
    }
  ]
}
{
  "error": "string",
  "details": {},
  "errors": [
    {
      "code": "row_expression_in_dataset_metric",
      "message": "margin works row by row. Add it as a fact (to aggregate) or a dimension (to group by).",
      "severity": "error",
      "hint": "string",
      "context": {}
    }
  ],
  "warnings": [
    {
      "code": "row_expression_in_dataset_metric",
      "message": "margin works row by row. Add it as a fact (to aggregate) or a dimension (to group by).",
      "severity": "error",
      "hint": "string",
      "context": {}
    }
  ]
}
{
  "error": "string",
  "details": {},
  "errors": [
    {
      "code": "row_expression_in_dataset_metric",
      "message": "margin works row by row. Add it as a fact (to aggregate) or a dimension (to group by).",
      "severity": "error",
      "hint": "string",
      "context": {}
    }
  ],
  "warnings": [
    {
      "code": "row_expression_in_dataset_metric",
      "message": "margin works row by row. Add it as a fact (to aggregate) or a dimension (to group by).",
      "severity": "error",
      "hint": "string",
      "context": {}
    }
  ]
}