Leases

Expose Typst template data

Retrieves all data needed to generate a Typst document for a given lease. The data is converted from TypstDict format to JSON and exposed with metadata.

This endpoint also allows passing custom variables via query parameters. These variables will be integrated into the template data before JSON conversion.

Use cases:

  • Custom PDF document generation
  • Data preview before generation
  • Integration with external systems
  • Debug and validation of template data
get/leases/{lease_id}/template-data

Request

  • Base URL: https://api.faireplace.com/api
  • URL: https://api.faireplace.com/api/leases/{lease_id}/template-data
  • Auth: HTTP bearer

Path parameters

lease_idstring uuid required
Example:550e8400-e29b-41d4-a716-446655440000

Lease ID for which to expose template data

Query parameters

customVariablesobject

Any query parameter you pass is added to the generated template data as a custom variable, under its own name.

Each value is parsed as JSON when it can be, and kept as a string otherwise, so the type of the variable follows the value:

  • custom_field=value → {"custom_field": "value"} (string)
  • amount=123.45 → {"amount": 123.45} (number)
  • is_active=true → {"is_active": true} (boolean)
  • tags=["a","b"] → {"tags": ["a", "b"]} (array)

Send no query parameters and no custom variables are added; the response then reports has_custom_variables: false.

Response

Template data exposed successfully.

The response contains:

  • lease_id: Lease ID
  • template_data: Complete data in JSON format (lease, property, owner, tenants, charges, etc.)
  • metadata: Metadata about the generation (processing time, data size, etc.)
lease_idstring uuid required

Unique identifier of the lease

template_dataobject required

Complete template data in JSON format.

This structure contains all the information needed to generate a Typst document, organized hierarchically:

Typical structure:

{
  "lease": {
    "id": "uuid",
    "rent_amount": 1200.00,
    "status": "ACTIVE",
    "start_date": "2024-01-01",
    "end_date": "2024-12-31"
  },
  "estate": {
    "name": "Appartement T3",
    "area": 75.5,
    "address": "123 Rue de la Paix"
  },
  "owner": {
    "name": "Jean Dupont",
    "email": "jean@example.com"
  },
  "lessees": [
    {
      "name": "Marie Martin",
      "email": "marie@example.com"
    }
  ],
  "charges": [
    {
      "name": "Common charges",
      "amount": 150.00
    }
  ],
  "custom_variables": {
    "custom_field": "value",
    "amount": 123.45
  }
}

Note: The exact structure may vary depending on the lease type and available data. Custom variables are added at the root level of template_data.

Example response

{
  "lease_id": "550e8400-e29b-41d4-a716-446655440000",
  "template_data": {
    "lease": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "rent_amount": 1200,
      "status": "ACTIVE",
      "start_date": "2024-01-01",
      "end_date": "2024-12-31"
    },
    "estate": {
      "name": "Appartement T3 - Rue de la Paix",
      "area": 75.5,
      "address": "123 Rue de la Paix, 75001 Paris"
    },
    "owner": {
      "name": "Jean Dupont",
      "email": "jean.dupont@example.com",
      "phone": "+33 1 23 45 67 89"
    },
    "lessees": [
      {
        "name": "Marie Martin",
        "email": "marie.martin@example.com",
        "phone": "+33 1 98 76 54 32",
        "role": "PRIMARY"
      }
    ],
    "charges": [
      {
        "name": "Common charges",
        "amount": 150,
        "calculation_method": "PROVISION"
      },
      {
        "name": "Heating",
        "amount": 80,
        "calculation_method": "RELEVE_DIRECT"
      }
    ],
    "custom_field": "custom_value",
    "amount": 123.45,
    "is_active": true
  },
  "metadata": {
    "generated_at": "2024-01-15T10:30:00Z",
    "generation_time_ms": 45,
    "has_custom_variables": true,
    "data_schema_version": "1.0",
    "data_source": "database",
    "data_size_bytes": 15420
  }
}

Changes

No recorded changes to this operation across all 1 revision of this API.