# Map parameters

Every field of a Map request, the three sources, and everything that comes back.

```text
POST https://api.millionshort.com/v1/map
```

Lists the URLs of a site in one answer. The call is synchronous.

## Request

| Field | Type | Default | Notes |
|---|---|---|---|
| `url` | string | | Required. A page of the site: `http` or `https`, default ports, a host name (not an address), no credentials in the URL. Up to 2,048 characters. It is in scope whatever the patterns say: it is listed when the `links` source read it (as the address it ended on, when it redirects) or another source names it |
| `search` | string, up to 200 characters | | Keep only the URLs that match these words. See [Search inside the site](#search-inside-the-site) |
| `limit` | integer, 1 to 5,000 | `500` | The most URLs returned. Credits are held for this many |
| `include_subdomains` | boolean | `false` | Also list URLs on other hosts of the same site. By default only the host you named, with or without `www.` |
| `include` | array of up to 20 patterns | | Keep only URLs whose path matches one of these. See [Patterns](#patterns) |
| `exclude` | array of up to 20 patterns | | Leave out URLs whose path matches one of these. Wins over `include` |
| `sources` | array of `sitemap`, `index`, `links` | all three | Where to look. See [Sources](#sources) |

Any other field is a `400 INVALID_PARAM`. A caller cannot send cookies or headers to the site, and there is no option to ignore robots.txt.

## Example

```bash
curl https://api.millionshort.com/v1/map \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.org/docs",
    "search": "webhooks",
    "limit": 50,
    "include": ["^/docs/"],
    "sources": ["sitemap", "index", "links"]
  }'
```

```python
import os

import requests

r = requests.post(
    "https://api.millionshort.com/v1/map",
    headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
    json={
        "url": "https://example.org/docs",
        "search": "webhooks",
        "limit": 50,
        "include": [
            "^/docs/"
        ],
        "sources": [
            "sitemap",
            "index",
            "links"
        ]
    },
    timeout=30,
)
r.raise_for_status()
print(r.json()["data"])
```

```ts
const res = await fetch('https://api.millionshort.com/v1/map', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "url": "https://example.org/docs",
    "search": "webhooks",
    "limit": 50,
    "include": [
      "^/docs/"
    ],
    "sources": [
      "sitemap",
      "index",
      "links"
    ]
  }),
});
if (!res.ok) throw new Error(`POST /v1/map failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);
```

## Sources

| Source | Where the URLs come from | What it adds to a URL | Requests to the site |
|---|---|---|---|
| `links` | The page at `url`, and every link on it | `title`: the page's own title, or the text of the link | One fetch of the page, as [Extract](https://millionshort.com/docs/extract) `live` makes it |
| `sitemap` | The `Sitemap:` lines of the site's robots.txt, and `/sitemap.xml`. Index files are followed and gzipped files are read | `last_modified`, when the sitemap gives one | robots.txt and up to 12 sitemap files |
| `index` | The pages of the site that our own index holds: up to 50, the ones that match `search` when you send it | `title`, `topic` and `page_type` | No page. When `index` is the only source, the site's robots.txt is read, and nothing else |

- A URL found by more than one source is listed once. `from` is the first source that named it, in the order `links`, `sitemap`, `index`, and what the later sources know is added to it.
- Only sitemap files on the site you asked about are read, whatever its robots.txt points at.
- A sitemap file that robots.txt closes to our bot is not read.
- With `index` alone, a site whose robots.txt closes `url` to our bot is refused (`403 ROBOTS_DISALLOWED`). With other sources too, a site that robots.txt closes to us entirely is refused, and its index rows are not listed.
- Sitemap reading stops at 12 files, 50,000 URLs or 15 seconds. When it stops early, `summary.truncated` is `true`.
- A URL is listed because the site or our index names it. Map does not fetch the URLs it lists, so a listed URL can still be one that robots.txt does not let us read.

## Patterns

`include` and `exclude` are regular expressions matched against the path of a URL, and only the path: not the host and not the query string. They are not anchored.

| Pattern | Matches |
|---|---|
| `/docs/` | Any path that contains `/docs/` |
| `^/docs/` | Paths that start with `/docs/` |
| `\.pdf$` | Paths that end in `.pdf` |
| `^/blog/2026/` | The 2026 posts of a blog |

Each pattern is up to 200 characters. One that is not a valid regular expression is a `400 INVALID_PARAM` that names it. The page at `url` is in scope whatever the patterns say.

## Search inside the site

With `search`, the answer keeps only matching URLs, best first:

1. The pages our index finds for your words in the text of the page, in the order our index ranks them. This is a real search of the page text, restricted to the site.
2. Then the URLs from the sitemap and the links whose address or title contains every word. A word in the path counts for more than one in the title.

Everything else is left out. `summary.found` counts what matched.

## Response

```json
{
  "data": {
    "url": "https://example.org/docs",
    "urls": [
      { "url": "https://example.org/docs/webhooks/signing", "title": "Signing webhooks", "from": "index", "topic": "programming", "page_type": "documentation" },
      { "url": "https://example.org/docs/webhooks", "title": "Webhooks", "last_modified": "2026-11-02", "from": "links" },
      { "url": "https://example.org/docs/webhooks/retries", "last_modified": "2026-09-30", "from": "sitemap" }
    ],
    "summary": {
      "found": 3,
      "returned": 3,
      "truncated": false,
      "by_source": { "links": 1, "sitemap": 1, "index": 1 }
    }
  },
  "usage": { "credits": 1, "cost_usd": 0.001, "breakdown": { "map": 1 } },
  "warnings": [],
  "request_id": "req_..."
}
```

| Field | Type | Notes |
|---|---|---|
| `data.url` | string | The page you named, as we read it |
| `data.urls[].url` | string | Without its fragment. `http` and `https`, and a path with and without its last slash, are one URL |
| `data.urls[].from` | `sitemap`, `index` or `links` | The first source that named the URL |
| `data.urls[].title` | string | When known: the page's title or the text of a link |
| `data.urls[].last_modified` | string | When the sitemap gives a date, as the site wrote it |
| `data.urls[].topic`, `page_type` | string | For URLs our index holds: the same [labels](https://millionshort.com/docs/extract/labels) Extract returns |
| `data.summary.found` | integer | URLs in scope, after `search` and before `limit` |
| `data.summary.returned` | integer | URLs in this answer |
| `data.summary.truncated` | boolean | `true` when the site has more than was returned |
| `data.summary.by_source` | object | How many URLs each source named first |

A field that is not known is left out of the entry.

## Warnings

A source that could not be read does not fail the call. The answer carries a `source_unavailable` warning with the `source` and a `reason`, and the URLs of that source are missing. The whole call answers within about 25 seconds: when a slow site uses that time up, the sources left are skipped with `reason: TIMEOUT`. The call fails only when no source answered. See [Errors](https://millionshort.com/docs/map/errors).

## Credits

1 credit for every 10 URLs returned, or part of 10, and never less than 1. A call that fails, or that finds no URL, costs nothing. [Pricing and limits](https://millionshort.com/docs/map/pricing) has examples.
