> For the complete documentation index, see [llms.txt](https://docs.api.intratool.de/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.api.intratool.de/api-reference/forms/default-value-sources.md).

# DefaultValueSources

## Introduction

`DefaultValueSources` define how a [FormField](/api-reference/forms/form-fields.md) receives a prefilled value when a form is rendered.

For forms, there are administration endpoints to create, update, and delete default value sources. Additionally, forms expose a runtime endpoint to resolve and return effective default values:

* `GET /api/forms/{form}/default-values`

## Get resolved default values for a form

Return the resolved default values for all form fields of a form.

**Definition**

<mark style="color:green;">`GET`</mark> `/api/forms/{form}/default-values`

**Authorization**

* Requires access to the form (`show` permission on the form).
* Available for authenticated API users and permalink context.

**Behavior**

* The endpoint resolves default values by processing the configured default value sources per field.
* Sources are evaluated in `sort_number` order per field.
* The first source that can be resolved for a field is returned.
* If a source cannot be resolved (e.g. missing context data), it is skipped and the next source is tried.
* Response data is keyed by `form_field_id`.

**Example Request**

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

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('GET', '/api/forms/7/default-values', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "11": {
    "value": "max.mustermann@example.com"
  },
  "12": {
    "value": "42",
    "request_value": "42",
    "additional_information": null
  }
}
```

## Model Definition

**Alias**

`defaultValueSource`

**Relations**

| Relation                                         | Key            | Type       | Relation Field(s) |
| ------------------------------------------------ | -------------- | ---------- | ----------------- |
| [FormField](/api-reference/forms/form-fields.md) | `formField`    | Belongs to | `form_field_id`   |
| [FormField](/api-reference/forms/form-fields.md) | `sourceEntity` | Morph to   | `source_entity_*` |

## \[Adm.] Create

Create a new `DefaultValueSource`.

**Definition**

<mark style="color:yellow;">`POST`</mark> `/api/administration/forms/fields/default-value-sources`

**Request Keys**

| Key                  | Type            | Default | Description                                                                                         |
| -------------------- | --------------- | ------- | --------------------------------------------------------------------------------------------------- |
| `source_type`\*      | string          | -       | Source type. Allowed values: `formFieldValue`, `systemVariable`.                                    |
| `form_field_id`\*    | integer         | -       | Related [FormField](/api-reference/forms/form-fields.md) ID.                                        |
| `config`             | object          | `{}`    | Source-specific configuration.                                                                      |
| `source_entity_type` | string \| null  | `null`  | Morph alias for source entity. For forms this can be `formField`. Required with `source_entity_id`. |
| `source_entity_id`   | integer \| null | `null`  | Source entity ID. Required with `source_entity_type`.                                               |
| `sort_number`        | integer         | auto    | Sort order within the same `form_field_id`.                                                         |

Keys with `*` are required.

### Source-specific `config`

* `formFieldValue`
  * No required config keys.
  * Typical usage: combine with `source_entity_type = formField` and `source_entity_id = {formFieldId}`.
* `systemVariable`
  * `variable_key` (required, string), see [system variables](/introduction/system-variables.md) for more information on available variables and their keys.
  * `variable_filter` (optional, string|null, expects a formatter key from [System variable formatters](/introduction/system-variables/formatters.md))

**Example Request**

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

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('POST', '/api/administration/forms/fields/default-value-sources', [
    'headers' => ['Authorization' => "Bearer {accessToken}"],
    'json' => [
        'form_field_id' => 7,
        'source_type' => 'systemVariable',
        'config' => [
            'variable_key' => 'system.user',
            'variable_filter' => 'format_user_name'
        ]
    ]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "status": "success",
  "data": {
    "id": 12,
    "form_field_id": 7,
    "source_type": "systemVariable",
    "config": {
      "variable_key": "system.user.email",
      "variable_filter": null
    },
    "source_entity_type": null,
    "source_entity_id": null,
    "sort_number": 1,
    "created_at": "2026-04-30 10:00:00",
    "updated_at": "2026-04-30 10:00:00"
  }
}
```

## \[Adm.] Update

Update an existing `DefaultValueSource` by `id`.

**Definition**

<mark style="color:blue;">`PUT`</mark> `/api/administration/forms/fields/default-value-sources/{id}`

**Request Keys**

| Key                  | Type            | Description                                                      |
| -------------------- | --------------- | ---------------------------------------------------------------- |
| `source_type`        | string          | New source type (`formFieldValue`, `systemVariable`).            |
| `form_field_id`      | integer         | New related [FormField](/api-reference/forms/form-fields.md) ID. |
| `config`             | object          | Source-specific configuration.                                   |
| `source_entity_type` | string \| null  | Morph alias for source entity (`formField` for forms).           |
| `source_entity_id`   | integer \| null | Source entity ID.                                                |
| `sort_number`        | integer         | Sort order within the same `form_field_id`.                      |

**Behavior notes**

* If `source_type` is not provided, the existing type is used for validation.
* If `source_type` changes and `config` is omitted, default config for the new type is applied before validation.
* If `form_field_id` is changed, create-authorization is checked for the new target field.

**Example Request**

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

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('PUT', '/api/administration/forms/fields/default-value-sources/12', [
    'headers' => ['Authorization' => "Bearer {accessToken}"],
    'json' => [
        'source_type' => 'formFieldValue',
        'source_entity_type' => 'formField',
        'source_entity_id' => 9
    ]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "status": "success",
  "data": {
    "id": 12,
    "form_field_id": 7,
    "source_type": "formFieldValue",
    "config": {},
    "source_entity_type": "formField",
    "source_entity_id": 9,
    "sort_number": 1,
    "created_at": "2026-04-30 10:00:00",
    "updated_at": "2026-04-30 10:05:00"
  }
}
```

## \[Adm.] Delete

Delete an existing `DefaultValueSource` by `id`.

**Definition**

<mark style="color:red;">`DELETE`</mark> `/api/administration/forms/fields/default-value-sources/{id}`

**Example Request**

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

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('DELETE', '/api/administration/forms/fields/default-value-sources/12', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "status": "success",
  "data": null
}
```
