# Assets and documents

This guide explains how to work with static assets and generated documents inside the KASKO webapp framework, including how to access them in JsonLogic and content strings.

## Overview

* **Assets** are static files (images, PDFs, etc.) that are attached to items, quotes, policies, offers, or claims.
* **Documents** are generated files produced by backend requests (for example, policy certificates) and may require polling before they are ready.

## Item Assets

Static assets defined at the item/product level:

```typescript
{
  ref: string,    // Reference name (e.g., "logo", "terms_pdf")
  url: string     // Asset URL
}
```

### Accessing Item Assets in JsonLogic

```json
{ "var": "asset.logo" }
```

### Accessing Item Assets in Content

```
{asset.logo}
```

## Generated Documents

Documents are generated after API requests (quote, policy, offer, lead) and may require polling.

### Document Structure

```typescript
{
  name: string,        // Document filename
  extension: string,   // File extension (pdf, etc.)
  url: string,         // Download URL
  designation: string, // Document type identifier
  status: "pending" | "ready"
}
```

### Document Tokens in Content

You can render document links in content using:

```
[{document.policy.certificate.name}]({document.policy.certificate.url})
[{document.lead.offer.name}]({document.lead.offer.url})
```

**Format:**

```
document.{request_type}.{designation}.{property}
```

Examples:

* `document.policy.certificate.url`
* `document.offer.terms.url`
* `document.lead.offer.name`

## Document Polling

For async document generation, use the `poll-documents` component:

```json
{
  "type": "poll-documents",
  "config": {
    "request_type": "policy"  // or "offer"
  }
}
```

The component polls for document status and updates state when documents are ready.

## Policy and Offer Assets

Assets attached to policies or offers after creation:

```typescript
{
  name: string,
  extension: string,
  url: string,
  designation: string,
  attachment_date: string
}
```

### Accessing Policy/Offer Assets in JsonLogic

```json
{ "var": "policy.assets" }
{ "var": "offer.assets" }
```

## Tips

* Use content tokens for links so URLs can be surfaced in translations.
* If documents are not immediately available, include `poll-documents` in your flow and render links after the status is `ready`.
* Prefer `asset.*` for static item assets and `document.*` for generated files.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kasko.io/kasko-frontend-documentation/core-concepts/assets-and-documents.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
