> For the complete documentation index, see [llms.txt](https://docs.opensoutheners.com/oss/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.opensoutheners.com/oss/flex-url/building-urls/includes-fields-appends.md).

# Includes, Fields & Appends

Build include=, fields\[type]=, and appends\[type]= query parameters for compound documents and sparse fieldsets.

## Includes

`include(...relationships)` eager-loads and embeds related resources as a JSON:API compound document. Dot notation reaches nested relationships. Calls accumulate.

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

```ts
flexUrl('/posts').include('project', 'assignee.team');
// /posts?include=project,assignee.team

flexUrl('/posts').include('project').include('tags');
// /posts?include=project,tags
```

{% endtab %}

{% tab title="PHP" %}

```php
FlexUrl::make('/posts')->include('project', 'assignee.team');
// /posts?include=project,assignee.team

FlexUrl::make('/posts')->include('project')->include('tags');
// /posts?include=project,tags
```

{% endtab %}
{% endtabs %}

## Sparse fieldsets

`fields(type, ...columns)` requests a subset of attributes for a given resource type (`fields[type]=col1,col2`). Multiple calls for the same type accumulate.

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

```ts
flexUrl('/posts').fields('post', 'title', 'body');
// /posts?fields[post]=title,body

flexUrl('/posts').fields('post', 'title').fields('author', 'name');
// /posts?fields[post]=title&fields[author]=name
```

{% endtab %}

{% tab title="PHP" %}

```php
FlexUrl::make('/posts')->fields('post', 'title', 'body');
// /posts?fields[post]=title,body

FlexUrl::make('/posts')->fields('post', 'title')->fields('author', 'name');
// /posts?fields[post]=title&fields[author]=name
```

{% endtab %}
{% endtabs %}

## Appends

`append(type, ...accessors)` exposes computed model accessors on demand, using apiable's plural `appends[type]=` wire key.

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

```ts
flexUrl('/posts').append('post', 'is_overdue');
// /posts?appends[post]=is_overdue
```

{% endtab %}

{% tab title="PHP" %}

```php
FlexUrl::make('/posts')->append('post', 'is_overdue');
// /posts?appends[post]=is_overdue
```

{% endtab %}
{% endtabs %}

## Reading back

```
GET /posts?include=project,tags&fields[post]=title,body&appends[post]=is_overdue
```

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

```ts
const parsed = flexUrl('/posts?include=project,tags&fields[post]=title,body&appends[post]=is_overdue');

parsed.getIncludes();     // ["project", "tags"]
parsed.getFields('post'); // ["title", "body"]
parsed.getFields();       // {post: ["title", "body"]}
parsed.getAppends('post'); // ["is_overdue"]
```

{% endtab %}

{% tab title="PHP" %}

```php
$parsed = FlexUrl::from('/posts?include=project,tags&fields[post]=title,body&appends[post]=is_overdue');

$parsed->getIncludes();     // ["project", "tags"]
$parsed->getFields('post'); // ["title", "body"]
$parsed->getFields();       // ['post' => ['title', 'body']]
$parsed->getAppends('post'); // ["is_overdue"]
```

{% endtab %}
{% endtabs %}

Removing an include/fields/appends entry works the same way as any bucket — see [Raw Params & Clearing](/oss/flex-url/building-urls/raw-params-and-clearing.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.opensoutheners.com/oss/flex-url/building-urls/includes-fields-appends.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
