> ## Documentation Index
> Fetch the complete documentation index at: https://docs.enterspeed.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Dynamic sitemap.xml or llms.txt files

Here are two examples of how you could handle dynamic page list files such as `sitemap.xml` or `llms.txt`, using either the [Routes API](https://docs.enterspeed.com/api-reference/routes/get-routes-v2.md) or [Index schemas](https://docs.enterspeed.com/enterspeed/reference/js/index-schema/intro.md).

Enterspeed doesn't build these files (just like it doesn't build any of your frontend code); it just exposes the data. The examples here show you two ways of accessing the data you need to build the files.

These examples are based on the following dataset:

> [accordion] Page source entities
>
> ```json theme={null}
>   {
>     "type": "page",
>     "originId": "1",
>     "originParentId": null,
>     "url": "/",
>     "updatedAt": "2026-07-28T10:24:22.8283418Z",
>     "properties": {
>       "title": "Home",
>       "description": "Home page"
>     }
>   }
> ```
>
> ```json theme={null}
>   {
>     "type": "page",
>     "originId": "2",
>     "originParentId": "1",
>     "url": "/about-us",
>     "updatedAt": "2026-07-25T12:36:05.8283418Z",
>     "properties": {
>       "title": "About us",
>       "description": "About us page"
>     }
>   }
> ```
>
> ```json theme={null}
>   {
>     "type": "page",
>     "originId": "3",
>     "originParentId": "1",
>     "url": "/contact",
>     "updatedAt": "2026-07-26T14:06:37.8283418Z",
>     "properties": {
>       "title": "Contact",
>       "description": "Contact page"
>     }
>   }
> ```

> [!NOTE]
>
> The examples below only show how to get data from Enterspeed. You will need to implement the logic for building the `sitemap.xml` or `llms.txt` file in your own application as this is not Enterspeed-specific but depends on your own application and framework.

## Using the Routes API

In this example we will be using the [Routes API](https://docs.enterspeed.com/api-reference/routes/get-routes-v2.md) to get a list of all the active URL routes in your Enterspeed environment. The Routes API returns the URL and the last updated date for each route. So if that's all you need for your `sitemap.xml`, this is a simple solution that doesn't require any extra schema or configuration in Enterspeed.

Below is a very simple page schema example, a schema you most likely already have in order to serve content to your frontend application.

The important part here is the URL route created in the `routes` method. This is the active route for the page and the route we will be fetching from the Routes API.

```js Page schema icon="square-js" highlight={7} theme={null}
/** @type {Enterspeed.FullSchema} */
export default {
  triggers: function(context) {
    context.triggers("cms", ["page"]);
  },
  routes: function (sourceEntity, context) {
    context.url(sourceEntity.url);
  },
  properties: function (sourceEntity, context) {
    return {
      title: sourceEntity.properties.title
    };
  }
}
```

With a schema like the one above creating views and routes, we can now call the Routes API and have it return the routes.

```bash Routes API request theme={null}
curl -L 'https://api.enterspeed.com/routes/v2' \
-H 'X-Api-Key: <your_environment_key>'
```

```json Response theme={null}
{
    "continuationToken": null,
    "results": [
        {
            "url": "/",
            "redirect": null,
            "updatedAt": "2026-07-28T10:26:22.8283418Z"
        },
        {
            "url": "/about-us",
            "redirect": null,
            "updatedAt": "2026-07-25T12:38:05.8283418Z"
        },
        {
            "url": "/contact",
            "redirect": null,
            "updatedAt": "2026-07-26T14:08:37.8283418Z"
        }
    ]
}
```

> [!NOTE]
>
> Be aware that the `updatedAt` value returned from the Routes API is the last time the route was updated, not the last time the source entity was updated. If you need the last updated date for the source entity, you will need to use an index schema instead.

Looking at the response above, you now have all the `url` and `updatedAt` values to build your `sitemap.xml`.

The first request is made without a continuation token. Remember to keep fetching the next pages by passing the `continuationToken` from the response back in the `X-Continuation-Token` header, until `continuationToken` is `null` and you have retrieved all content.

> [!NOTE]
>
> The Routes API returns all active URL routes in your Enterspeed environment, so if you have other schemas creating URL routes, they will also be returned.
>
> Redirects are returned as routes too. These have the `redirect` property set instead of `null`, so filter them out if you only want the canonical page URLs.

```xml sitemap.xml example theme={null}
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://mysite.com/</loc>
    <lastmod>2026-07-28T10:24:22.8283418Z</lastmod>
  </url>
  <url>
    <loc>https://mysite.com/about-us</loc>
    <lastmod>2026-07-25T12:36:05.8283418Z</lastmod>
  </url>
  <url>
    <loc>https://mysite.com/contact</loc>
    <lastmod>2026-07-26T14:06:37.8283418Z</lastmod>
  </url>
</urlset>
```

## Using index schemas

If you need more than just the URL and last updated date that are returned by the Routes API, you can use an index schema to index the exact properties you need.

> [!NOTE]
>
> Note: Index schemas are a paid add-on.

In this example we will be creating an index schema called `pageIndex` that contains the URL, the page title and the page description for each page source entity.

```js Index schema for pages icon="square-js" theme={null}
/** @type {Enterspeed.IndexSchema} */
export default {
  triggers: function(context) {
    context.triggers('cms', ['page'])
  },
  index: {
    fields: {
        url: { type: "keyword" }, 
        title: { type: "keyword" },
        description: { type: "keyword" }
      }
  },
  properties: function (sourceEntity) {
    return {
        url: sourceEntity.url, 
        title: sourceEntity.properties.title,
        description: sourceEntity.properties.description
      }
  }
}
```

Once the index is created, you can call the [Query API](https://docs.enterspeed.com/api-reference/query) to get the needed data for all pages.

```bash Query API request theme={null}
curl -L -X POST 'https://query.enterspeed.com/v1/pageIndex' \
-H 'X-Api-Key: <your_environment_key>' \
-H 'Content-Type: application/json' \
-d '{
    "pagination": {
      "pageSize": 1000
    }
  }'
```

```json Response theme={null}
{
  "totalResults": 3,
  "results": [
      {
        "_sourceGuid": "6f544251-40ca-474b-9c00-5d44bc891799",
        "_updatedAt": "2026-07-28T10:26:22.8283418Z",
        "_originId": "1",
        "url": "/",
        "title": "Home",
        "description": "Home page"
      },
      {
        "_sourceGuid": "6f544251-40ca-474b-9c00-5d44bc891799",
        "_updatedAt": "2026-07-25T12:38:05.8283418Z",
        "_originId": "2",
        "url": "/about-us",
        "title": "About us",
        "description": "About us page"
      },
      {
        "_sourceGuid": "6f544251-40ca-474b-9c00-5d44bc891799",
        "_updatedAt": "2026-07-26T14:08:37.8283418Z",
        "_originId": "3",
        "url": "/contact",
        "title": "Contact",
        "description": "Contact page"
      }
  ],
  "facets": [],
  "nextPageToken": null,
  "status": 0
}
```

> [!NOTE]
>
> Be aware that the `_updatedAt` value returned from the Query API is the last time the item in the index was updated, not the last time the source entity was updated. If you need the last updated date for the source entity, you will need to index the `updatedAt` field from the source entity or a custom date property from your source entity.

Looking at the response above, you now have all the `url`, `title` and `description` values to build your `llms.txt` file.

If you have more than 1000 pages, remember to keep fetching the next pages of the index until you have retrieved all content.

```md llms.txt example theme={null}
# My Site

## Content

- [Home](https://mysite.com/): Home page
- [About us](https://mysite.com/about-us): About us page
- [Contact](https://mysite.com/contact): Contact page
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.