# Dokumente

## Dokumente lesen

<mark style="color:blue;">`GET`</mark> `https://api.propstack.de/v1/documents`

Die Dokumente werden paginiert.

#### Query Parameters

| Name             | Type    | Description                                                                                                                |
| ---------------- | ------- | -------------------------------------------------------------------------------------------------------------------------- |
| order\_by        | string  | Sortierung der Ergebnismenge. Standard `position,asc`. Um nach Erstellungsdatum absteigend zu sortieren: `created_at,desc` |
| tag              | string  | ein Schlagwort, welches das Dokument haben muss                                                                            |
| is\_private      | boolean | mögliche Werte:  `true` oder `false`                                                                                       |
| client           | integer | ID des verknüpften Kontaktes                                                                                               |
| property         | integer | ID des verknüpften Objektes                                                                                                |
| project          | integer | ID des verknüpften Projektes                                                                                               |
| client\_property | integer | ID des verknüpften Deal                                                                                                    |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    "documents": [
        {
            "id": 11,
            "token": "1hw4mBZRnFrnitGUbj5jL4Rt",
            "title": "grundriss.pdf",
            "name": "grundriss.pdf",
            "url": "...",
            "position": 1,
            "broker_id": 1,
            "is_private": true,
            "on_landing_page": true,
            "is_exposee": false,
            "second_document": null,
            "is_floorplan": true,
            "tags": [],
            "created_at": "2019-11-12T14:56:25.140+01:00",
            "updated_at": "2019-11-12T15:16:28.348+01:00"
        }
    ],
    "meta": {
        "total_count": 1
    }
}
```

{% endtab %}
{% endtabs %}

## Dokument erstellen

<mark style="color:green;">`POST`</mark> `https://api.propstack.de/v1/documents`

Alle Parameter in einem `document` Objekt umschlossen werden.\
Ein Dokument sollte mit entweder einem Objekt, einem Projekt, oder einem Kontakt verknüpft werden, und keine Kombination der 3.

#### Request Body

| Name              | Type    | Description                                                                                                            |
| ----------------- | ------- | ---------------------------------------------------------------------------------------------------------------------- |
| tags              | array   | Nicht bereits vorhandene Tags werden automatisch neu angelegt                                                          |
| on\_landing\_page | boolean | Soll das Dokument als Landing Pages angezeigt werden? Nur bei Projekten/Objekten sinnvoll                              |
| is\_floorplan     | boolean | Handelt es sich bei dem Dokument um ein Grundriss?                                                                     |
| is\_exposee       | boolean | Soll das Dokument als das PDF-Exposé benutzt werden? Nur sinnvoll, wenn Dokument mit Projekt oder Objekt verknüpft ist |
| client\_id        | integer | ID des Kontaktes, womit es verknüpft werden soll                                                                       |
| project\_id       | integer | ID des Projektes, womit es verknüpft werden soll                                                                       |
| property\_id      | integer | ID des Objektes, womit es verknüpft werden soll                                                                        |
| doc               | string  | die eigentliche Datei, Base64 kodiert                                                                                  |
| title             | string  | eigener Name für das Dokument, falls nicht der Dateiname benutzt werden soll                                           |
| is\_private       | boolean |                                                                                                                        |

{% tabs %}
{% tab title="200 " %}

```
```

{% endtab %}
{% endtabs %}

### Body einer Beispiel-Anfrage

Es wird ein Dokument für das Objekt mit der ID 123 angelegt, was nur ein oranger Pixel ist:

```javascript
{
	"document": {
		"property_id": 123,
		"title": "orange-pixel.png",
		"doc": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8v5vhPwAHNgK7sbW2nQAAAABJRU5ErkJggg=="
	}
}
```

## Dokument lesen

<mark style="color:blue;">`GET`</mark> `https://api.propstack.de/v1/documents/:id`

{% tabs %}
{% tab title="200 " %}

```javascript
{
  "id": 11,
  "token": "1hw4mBZRnFrnitGUbj5jL4Rt",
  "title": "grundriss.pdf",
  "name": "grundriss.pdf",
  "url": "...",
  "position": 1,
  "broker_id": 1,
  "is_private": true,
  "on_landing_page": true,
  "is_exposee": false,
  "second_document": null,
  "is_floorplan": true,
  "tags": [],
  "created_at": "2019-11-12T14:56:25.140+01:00",
  "updated_at": "2019-11-12T15:16:28.348+01:00"
}
```

{% endtab %}
{% endtabs %}

## Dokument aktualisieren

<mark style="color:orange;">`PUT`</mark> `https://api.propstack.de/v1/documents/:id`

Die gleichen Parameter im POST können auch im PUT verändert werden

{% tabs %}
{% tab title="200 " %}

```javascript
{
    "id": 12,
    "token": "zxydpZE62eZ3GcEQSCN84bwT",
    "title": "Exposé.pdf",
    "name": "Exposé.pdf",
    "url": "...",
    "position": 1,
    "broker_id": 1,
    "is_private": true,
    "on_landing_page": true,
    "is_exposee": false,
    "second_document": null,
    "is_floorplan": false,
    "tags": []
}
```

{% endtab %}
{% endtabs %}

## Dokument löschen

<mark style="color:red;">`DELETE`</mark> `https://api.propstack.de/v1/documents/:id`

{% tabs %}
{% tab title="200: OK " %}

```javascript
```

{% endtab %}
{% endtabs %}

## Tags auslesen

<mark style="color:blue;">`GET`</mark> `https://api.propstack.de/v1/documents/tags`

Alle möglichen Tags auslesen, die ein Dokument haben kann.

{% tabs %}
{% tab title="200 " %}

```javascript
{
    "data": [
        "Energieausweis"
    ],
    "meta": {
        "total_count": 1
    }
}
```

{% endtab %}
{% endtabs %}


---

# 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.propstack.de/reference/dokumente.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.
