> 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](https://docs.opensoutheners.com/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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
