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
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 ID for which to expose template data
Query parameters
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.)
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.