# Spaces API

Create, list, change, delete and import Spaces: the saved scopes a search uses with one parameter.

A Space is a saved, named scope for [`POST /v1/search`](https://millionshort.com/docs/search/parameters): a list of sites, a popularity cut, page types and topics to keep or leave out, what to boost, bury or block, site filters, default sources and safe search. Name it once, then pass `space` on any search. [Spaces, under Search](https://millionshort.com/docs/search/spaces), says when one is worth making.

**Spaces are free.** Creating, keeping, reading, changing and deleting a Space costs 0 credits. A search that uses a Space costs what that search costs without it.

## Endpoints

| Endpoint | What it does |
|---|---|
| `POST /v1/spaces` | Create a Space. Answers `201` with the Space |
| `GET /v1/spaces` | List Spaces: your team's, the curated ones, or both |
| `GET /v1/spaces/{id}` | Read one |
| `PATCH /v1/spaces/{id}` | Change the fields you send. The others stay |
| `DELETE /v1/spaces/{id}` | Delete it |
| `POST /v1/spaces/import` | Load Spaces exported from the MillionShort search site |
| `POST /v1/search` with `space` | [Search with a Space](#using-a-space-on-a-search) |

All of them are free. The two reads do not count against your requests a minute.

`{id}` is any of three things, here and in `space` on a search:

| Form | Example | Means |
|---|---|---|
| An id | `spc_01jd3v9k2m8q4r6s0t1u2v3w4x` | `spc_` and 26 characters. Ours, and it never changes |
| A slug | `baking` | A Space of your team, by the slug you gave it |
| `curated:` and a slug | `curated:home-cooking` | One of [our curated Spaces](#curated-spaces) |

## Create a Space

Only `name` is required.

```bash
curl https://api.millionshort.com/v1/spaces \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Baking",
    "sites": ["example.org", "example.com/blog", "docs.example.net"],
    "remove_top_sites": 1000
  }'
```

```python
import os

from millionshort import MillionShort

client = MillionShort(api_key=os.environ["MILLIONSHORT_API_KEY"])

baking = client.create_space(
    "Baking",
    sites=["example.org", "example.com/blog", "docs.example.net"],
    remove_top_sites=1000,
)
print(baking.id, baking.slug)
```

```ts
import { MillionShort } from 'millionshort';

const client = new MillionShort({ apiKey: process.env.MILLIONSHORT_API_KEY });

const baking = await client.createSpace('Baking', {
  sites: ['example.org', 'example.com/blog', 'docs.example.net'],
  removeTopSites: 1000,
});
console.log(baking.id, baking.slug);
```

The answer is the Space:

```json
{
  "data": {
    "id": "spc_01jd3v9k2m8q4r6s0t1u2v3w4x",
    "slug": "baking",
    "name": "Baking",
    "description": null,
    "emoji": null,
    "curated": false,
    "mode": "only",
    "sites": ["example.org", "example.com/blog", "docs.example.net"],
    "exclude_sites": [],
    "remove_top_sites": 1000,
    "only_top_sites": 0,
    "page_types": [],
    "topics": [],
    "exclude_page_types": [],
    "exclude_topics": [],
    "lens": { "boost": [], "bury": [], "block": [] },
    "sources": null,
    "safe_search": null,
    "popularity_buckets": [],
    "traffic_trend": [],
    "popular_in": [],
    "site_tech": [],
    "exclude_risky": false,
    "created_at": "2026-11-18T10:00:00Z",
    "updated_at": "2026-11-18T10:00:00Z"
  },
  "usage": null,
  "warnings": [],
  "request_id": "req_..."
}
```

The values are an illustration; the fields are exact. `usage` is `null` on the Space endpoints: nothing is metered.

A Space that prefers some sites instead of searching inside them, with a lens and a site filter:

```bash
curl https://api.millionshort.com/v1/spaces \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Primary sources",
    "mode": "boost",
    "sites": ["example.org", "example.edu"],
    "lens": {
      "boost": ["type:research"],
      "bury": ["type:listicles"],
      "block": ["topic:adult", "site:example.net"]
    },
    "exclude_risky": true
  }'
```

```python
import os

import requests

r = requests.post(
    "https://api.millionshort.com/v1/spaces",
    headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
    json={
        "name": "Primary sources",
        "mode": "boost",
        "sites": [
            "example.org",
            "example.edu"
        ],
        "lens": {
            "boost": [
                "type:research"
            ],
            "bury": [
                "type:listicles"
            ],
            "block": [
                "topic:adult",
                "site:example.net"
            ]
        },
        "exclude_risky": True
    },
    timeout=30,
)
r.raise_for_status()
print(r.json()["data"])
```

```ts
const res = await fetch('https://api.millionshort.com/v1/spaces', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "name": "Primary sources",
    "mode": "boost",
    "sites": [
      "example.org",
      "example.edu"
    ],
    "lens": {
      "boost": [
        "type:research"
      ],
      "bury": [
        "type:listicles"
      ],
      "block": [
        "topic:adult",
        "site:example.net"
      ]
    },
    "exclude_risky": true
  }),
});
if (!res.ok) throw new Error(`POST /v1/spaces failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);
```

## The Space object

| Field | Type | Default | Notes |
|---|---|---|---|
| `id` | string | | `spc_` and 26 characters. Set by us; it never changes |
| `slug` | string, 1 to 40 characters | made from `name` | Lower-case letters, digits and hyphens, starting with a letter or a digit. Unique in your team. Made from `name` when not sent; if that one is taken it gets `-2`, `-3` and so on |
| `name` | string, 1 to 60 characters | | Required when creating |
| `description` | string or null, up to 200 characters | `null` | |
| `emoji` | string or null, up to 16 characters | `null` | |
| `curated` | boolean | | `true` for a Space of ours: readable by everyone, and read-only. Set by us |
| `mode` | `only` or `boost` | `"only"` | What `sites` means: search **inside** these sites, or **prefer** them |
| `sites` | array of strings, up to 200 | `[]` | A host (`example.com`, `docs.example.com`) or a host with a path prefix (`example.com/blog`). May be empty |
| `exclude_sites` | array of strings, up to 150 | `[]` | Hosts. Never return results from these. The limit of 150 is shared with the `site:` targets of `lens.block` |
| `remove_top_sites` | integer, 0 to 1,000,000 | `0` | Remove results from the N most popular sites. 0 is off |
| `only_top_sites` | integer, 0 to 1,000,000 | `0` | Keep only the N most popular sites. Cannot be set together with `remove_top_sites` |
| `page_types` | array of strings | `[]` | Keep only these page types. Slugs from [`GET /v1/sources`](https://millionshort.com/docs/api-reference/sources) |
| `topics` | array of strings | `[]` | Keep only these topics |
| `exclude_page_types` | array of strings | `[]` | Leave these page types out |
| `exclude_topics` | array of strings | `[]` | Leave these topics out |
| `lens` | object | | `boost`, `bury` and `block`: three lists of targets. See below |
| `sources` | array of strings, 1 to 5 items, or null | `null` | Default sources for a search with this Space. `null`: the search's own `sources`, or `web` |
| `safe_search` | `off`, `moderate`, `strict` or null | `null` | `null`: the search's own, or `moderate` |
| `popularity_buckets` | array of strings | `[]` | As on a search |
| `traffic_trend` | array of strings | `[]` | As on a search |
| `popular_in` | array of strings, up to 10 | `[]` | Two-letter country codes, as on a search |
| `site_tech` | array of strings, up to 10 | `[]` | As on a search |
| `exclude_risky` | boolean | `false` | As on a search |
| `created_at`, `updated_at` | date and time | | UTC |

`id`, `curated`, `created_at` and `updated_at` are ours: sending one is a `400 INVALID_PARAM`, like any field this table does not list.

### The lens

`lens` holds three lists, `boost`, `bury` and `block`, of up to 100 targets each. A target is one of:

| Target | Example | Acts on |
|---|---|---|
| `site:` and a host | `site:example.org` | Results from that site |
| `type:` and a page type slug | `type:forums` | Results of that kind of page |
| `topic:` and a topic slug | `topic:science` | Results on that topic |

A target can be in one of the three lists only. Boost moves results ahead, bury moves them to the end, block removes them: the same verbs as the [lenses](https://millionshort.com/docs/search/lenses) of a search.

Blocking through the lens and through the plain fields is the same thing. `lens.block` with a `site:` target does what `exclude_sites` does, and with a `type:` or `topic:` target what `exclude_page_types` or `exclude_topics` does. Both spellings are stored as you sent them and applied together.

### Rules

Each of these is a `400 INVALID_PARAM`:

- a field the table does not list;
- a site that is not a host name;
- a page type, topic or source that does not exist;
- a `lens` target that does not start with `site:`, `type:` or `topic:`;
- a `lens` target that is in two of the three lists;
- a slug kept and left out at once: in both `page_types` and `exclude_page_types`, or in both `topics` and `exclude_topics`. A `type:` or `topic:` target of `lens.block` counts as left out;
- `remove_top_sites` and `only_top_sites` both above 0;
- a `slug` another Space of your team already has.

## Limits

| Plan | Spaces per team |
|---|---|
| Trial key, Free | 10 |
| Starter, Growth, Scale | 100 |
| Business, Enterprise | 1,000 |

Creating one more than the plan allows is refused with `403 QUOTA_EXCEEDED`; `error.details.limit` is the plan's number. Delete a Space or move to a larger plan.

## List Spaces

```bash
curl "https://api.millionshort.com/v1/spaces?scope=all" \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY"
```

```python
import os

import requests

r = requests.get(
    "https://api.millionshort.com/v1/spaces?scope=all",
    headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
    timeout=30,
)
r.raise_for_status()
print(r.json()["data"])
```

```ts
const res = await fetch('https://api.millionshort.com/v1/spaces?scope=all', {
  headers: { Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}` },
});
if (!res.ok) throw new Error(`GET /v1/spaces failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);
```

| `scope` | Returns |
|---|---|
| `own` | Your team's Spaces, newest first. The default |
| `curated` | Our curated Spaces, by name |
| `all` | Both, your team's first |

```json
{
  "data": {
    "spaces": [
      {
        "id": "spc_01jd3v9k2m8q4r6s0t1u2v3w4x",
        "slug": "baking",
        "name": "Baking",
        "curated": false,
        "mode": "only",
        "sites": ["example.org", "example.com/blog", "docs.example.net"],
        "remove_top_sites": 1000,
        "created_at": "2026-11-18T10:00:00Z",
        "updated_at": "2026-11-18T10:00:00Z"
      }
    ]
  },
  "usage": null,
  "warnings": [],
  "request_id": "req_..."
}
```

Each entry is a whole Space; the sample is shortened.

## Read a Space

By id, by your slug, or a curated one:

```bash
curl https://api.millionshort.com/v1/spaces/$SPACE_ID \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY"
```

```python
import os

import requests

r = requests.get(
    f"https://api.millionshort.com/v1/spaces/{os.environ['SPACE_ID']}",
    headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
    timeout=30,
)
r.raise_for_status()
print(r.json()["data"])
```

```ts
const res = await fetch(`https://api.millionshort.com/v1/spaces/${process.env.SPACE_ID}`, {
  headers: { Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}` },
});
if (!res.ok) throw new Error(`GET /v1/spaces/… failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);
```

```bash
curl https://api.millionshort.com/v1/spaces/curated:home-cooking \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY"
```

```python
import os

import requests

r = requests.get(
    "https://api.millionshort.com/v1/spaces/curated:home-cooking",
    headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
    timeout=30,
)
r.raise_for_status()
print(r.json()["data"])
```

```ts
const res = await fetch('https://api.millionshort.com/v1/spaces/curated:home-cooking', {
  headers: { Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}` },
});
if (!res.ok) throw new Error(`GET /v1/spaces/curated:home-cooking failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);
```

The answer is the Space, in `data`, as in the answer to a create. `curated:home-cooking` stands for any curated slug; `GET /v1/spaces?scope=curated` lists the real ones.

## Change a Space

`PATCH` takes the same fields as a create, all optional. A field you send replaces the stored value; a field you leave out stays as it is. `lens` is one field: a `lens` you send replaces all three of its lists, so send the lists you want to keep. A `PATCH` with no field is a `400 INVALID_PARAM`.

```bash
curl -X PATCH https://api.millionshort.com/v1/spaces/$SPACE_ID \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "remove_top_sites": 10000, "exclude_page_types": ["listicles"] }'
```

```python
import os

import requests

r = requests.patch(
    f"https://api.millionshort.com/v1/spaces/{os.environ['SPACE_ID']}",
    headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
    json={
        "remove_top_sites": 10000,
        "exclude_page_types": [
            "listicles"
        ]
    },
    timeout=30,
)
r.raise_for_status()
print(r.json()["data"])
```

```ts
const res = await fetch(`https://api.millionshort.com/v1/spaces/${process.env.SPACE_ID}`, {
  method: 'PATCH',
  headers: {
    Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "remove_top_sites": 10000,
    "exclude_page_types": [
      "listicles"
    ]
  }),
});
if (!res.ok) throw new Error(`PATCH /v1/spaces/… failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);
```

The answer is the Space after the change.

Sending `slug` renames the Space. Searches that pass the old slug stop finding it, so update them first or refer to the Space by its `id`, which keeps working.

## Delete a Space

```bash
curl -X DELETE https://api.millionshort.com/v1/spaces/$SPACE_ID \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY"
```

```python
import os

import requests

r = requests.delete(
    f"https://api.millionshort.com/v1/spaces/{os.environ['SPACE_ID']}",
    headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
    timeout=30,
)
r.raise_for_status()
print(r.json()["data"])
```

```ts
const res = await fetch(`https://api.millionshort.com/v1/spaces/${process.env.SPACE_ID}`, {
  method: 'DELETE',
  headers: { Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}` },
});
if (!res.ok) throw new Error(`DELETE /v1/spaces/… failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);
```

```json
{
  "data": { "id": "spc_01jd3v9k2m8q4r6s0t1u2v3w4x", "deleted": true },
  "usage": null,
  "warnings": [],
  "request_id": "req_..."
}
```

A search that still names a deleted Space is answered with `404 SPACE_NOT_FOUND`.

## Import from the search site

A Space here is the same object as a Space on the MillionShort search site. `POST /v1/spaces/import` takes the search site's export file as it is, so the Spaces you made by hand there can be used by your agent.

```bash
curl https://api.millionshort.com/v1/spaces/import \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "millionshort_spaces": 1,
    "spaces": [
      {
        "id": "baking",
        "name": "Baking",
        "about": "Bread, mostly",
        "mode": "only",
        "sites": ["example.org", "example.com/blog"],
        "remove_top": 1000,
        "lens": { "boost": ["type:tutorials"], "bury": [], "block": ["type:products"] }
      }
    ]
  }'
```

```python
import os

import requests

r = requests.post(
    "https://api.millionshort.com/v1/spaces/import",
    headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
    json={
        "millionshort_spaces": 1,
        "spaces": [
            {
                "id": "baking",
                "name": "Baking",
                "about": "Bread, mostly",
                "mode": "only",
                "sites": [
                    "example.org",
                    "example.com/blog"
                ],
                "remove_top": 1000,
                "lens": {
                    "boost": [
                        "type:tutorials"
                    ],
                    "bury": [],
                    "block": [
                        "type:products"
                    ]
                }
            }
        ]
    },
    timeout=30,
)
r.raise_for_status()
print(r.json()["data"])
```

```ts
const res = await fetch('https://api.millionshort.com/v1/spaces/import', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "millionshort_spaces": 1,
    "spaces": [
      {
        "id": "baking",
        "name": "Baking",
        "about": "Bread, mostly",
        "mode": "only",
        "sites": [
          "example.org",
          "example.com/blog"
        ],
        "remove_top": 1000,
        "lens": {
          "boost": [
            "type:tutorials"
          ],
          "bury": [],
          "block": [
            "type:products"
          ]
        }
      }
    ]
  }),
});
if (!res.ok) throw new Error(`POST /v1/spaces/import failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);
```

The body is the export file, or `{"spaces": [...]}` with 1 to 100 entries. An entry is a Space as the search site writes it, or a Space as this API returns it. The search site's fields map like this:

| Search site | Here |
|---|---|
| `id` | `slug` |
| `name`, `emoji`, `mode`, `sites`, `lens` | The same |
| `about` | `description` |
| `remove_top` | `remove_top_sites` |

```json
{
  "data": {
    "imported": [
      {
        "id": "spc_01jd3v9k2m8q4r6s0t1u2v3w4x",
        "slug": "baking",
        "name": "Baking",
        "description": "Bread, mostly",
        "curated": false,
        "mode": "only",
        "sites": ["example.org", "example.com/blog"],
        "remove_top_sites": 1000,
        "lens": { "boost": ["type:tutorials"], "bury": [], "block": ["type:products"] },
        "created_at": "2026-11-18T10:00:00Z",
        "updated_at": "2026-11-18T10:00:00Z"
      }
    ],
    "skipped": []
  },
  "usage": null,
  "warnings": [],
  "request_id": "req_..."
}
```

- `imported` holds the Spaces that were created, each one whole.
- `skipped` names what was not, each with the `index` of the entry in the list you sent, a `reason` and a `message`. The reason is `invalid` for an entry that cannot be read, such as one with no name, or one whose `sites` were sent and none of them can be read, and `limit` for the entries that would take the team past its plan's number of Spaces. An import stops at the limit; what was created before it stays.
- An entry whose slug is already taken is not skipped: it gets the slug with `-2`, `-3` and so on.
- Inside an entry that is imported, a field we do not know and a list item that cannot be read are left out.

## Using a Space on a search

Pass `space` on [`POST /v1/search`](https://millionshort.com/docs/search/parameters): an id, a slug of your team, or `curated:` and a slug.

```bash
curl https://api.millionshort.com/v1/search \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "query": "sourdough hydration", "space": "baking" }'
```

```python
import os

from millionshort import MillionShort

client = MillionShort(api_key=os.environ["MILLIONSHORT_API_KEY"])

r = client.search("sourdough hydration", space="baking")
for hit in r.results:
    print(hit["position"], hit["site"], hit["title"])
print(r.space["sites_applied"], "of", r.space["sites_total"], "sites searched")
```

```ts
import { MillionShort } from 'millionshort';

const client = new MillionShort({ apiKey: process.env.MILLIONSHORT_API_KEY });

const r = await client.search('sourdough hydration', { space: 'baking' });
for (const hit of r.results) {
  console.log(hit.position, hit.site, hit.title);
}
console.log(r.space?.sites_applied, 'of', r.space?.sites_total, 'sites searched');
```

### The request wins

A parameter you send in the request replaces the Space's value for that setting. Everything you do not send comes from the Space. So a Space is a set of defaults, and one search can step outside it without changing it.

| Setting of the Space | Replaced when the request sends |
|---|---|
| `sources` | `sources` |
| `sites`, with `mode: only` | `include_domains` or `only_domains` |
| `sites`, with `mode: boost`, and the `site:` targets of `lens.boost` | `boost_domains` |
| The `site:` targets of `lens.bury` | `bury_domains` |
| `exclude_sites`, and the `site:` targets of `lens.block` | `exclude_domains` or `block_domains` |
| `remove_top_sites`, `only_top_sites` | `remove_top_sites`, `only_top_sites` or `index_level`. Any one of them replaces both |
| `page_types` | `page_types` |
| `topics` | `topics` |
| `exclude_page_types`, and the `type:` targets of `lens.block` | `exclude_page_types` |
| `exclude_topics`, and the `topic:` targets of `lens.block` | `exclude_topics` |
| The `type:` targets of `lens.boost` | `boost_page_types` |
| The `type:` targets of `lens.bury` | `bury_page_types` |
| The `topic:` targets of `lens.boost` | `boost_topics` |
| The `topic:` targets of `lens.bury` | `bury_topics` |
| `safe_search`, `popularity_buckets`, `traffic_trend`, `popular_in`, `site_tech`, `exclude_risky` | The parameter of the same name |

A replacement is whole: a list in the request takes the place of the Space's list, and the two are not merged.

When the request keeps a page type or topic that the Space leaves out, or leaves out one the Space keeps, the request's list stands and that slug is dropped from the Space's list for this search. The call is not refused.

Everything else on the request (`query`, `num_results`, dates, `language`, `country`, highlights, `include_content`, `explain`) works as on any search.

### `mode: only` applies the first 50 sites

A Space can hold up to 200 sites. A search inside a list of sites uses the first 50 of them, in the order of `sites`. A longer list is cut, and the answer says so twice: a `space_sites_cut` warning, and `sites_applied` lower than `sites_total` in `data.space`. Put the sites that matter most first, or split a long list into two Spaces.

With `mode: boost` the search is not limited to the sites, so nothing is cut out of the results. A path prefix does not narrow a preference: `example.com/blog` prefers the whole of `example.com`.

### What the answer adds

A search with a Space has `data.space`: the Space that was used and what it supplied.

```json
{
  "data": {
    "results": [
      {
        "title": "Hydration levels for a sourdough starter, measured",
        "url": "https://example.org/starter-hydration",
        "site": "example.org",
        "source": "web",
        "snippet": "At 100% hydration the starter peaks in four to six hours...",
        "highlights": ["At 100% hydration the starter peaks in four to six hours..."],
        "published_date": null,
        "page_type": "articles",
        "topic": "food",
        "popularity": { "rank": null, "bucket": "long-tail" },
        "risk": null,
        "position": 1,
        "score": 1.0,
        "extra": {}
      }
    ],
    "summary": {
      "returned": 10,
      "removed": { "popularity": 0, "blocked": 0, "duplicates": 1, "risk": 0, "safe_search": 0, "filters": 0 }
    },
    "warnings": [],
    "space": {
      "id": "spc_01jd3v9k2m8q4r6s0t1u2v3w4x",
      "slug": "baking",
      "name": "Baking",
      "curated": false,
      "mode": "only",
      "sites_total": 3,
      "sites_applied": 3,
      "applied": {
        "include_domains": ["example.org", "example.com/blog", "docs.example.net"],
        "remove_top_sites": 1000
      },
      "overridden": []
    }
  },
  "usage": { "credits": 1, "cost_usd": 0.001, "breakdown": { "search": 1 } },
  "warnings": [],
  "request_id": "req_..."
}
```

| Field | Type | Notes |
|---|---|---|
| `id`, `slug`, `name`, `curated`, `mode` | | Of the Space that was used |
| `sites_total` | integer | How many sites the Space holds |
| `sites_applied` | integer | How many of them this search used. Lower than `sites_total` when the list was cut, or when the request replaced it |
| `applied` | object | The settings the Space supplied to this search, under the names of the search parameters |
| `overridden` | array of strings | The request parameters that replaced a setting of the Space |

Read `applied` and `overridden` to see exactly what was searched: together with your own request they are the whole scope.

### Warnings

| Warning code | Meaning |
|---|---|
| `space_sites_cut` | The Space has `mode: only` and lists more sites than one search uses (50; 20 without a key). `sites_total` and `sites_applied` in the warning give the numbers |
| `space_setting_not_applied` | Something the Space asks for was left out: a setting that cannot be applied right now (named in `settings`), or a page type, topic or source that no longer exists (named in `values`). The search ran without it |

A setting of a Space is never dropped silently. The warnings a search can carry on its own, such as a `filter_not_applied` warning for page types on a source that has none, apply to settings that came from a Space as well.

### How a search inside a list of sites is counted

A search inside a list of sites on the `web` source, whether the list comes from a Space with `mode: only` or from `include_domains` in the request, is more work than a plain search. Its price is the same, 1 credit per source. Two limits count it differently:

- **Heavy-source searches a minute.** It counts as the number of sites divided by 10, rounded up, where a plain `web` search counts as 1. Up to 10 sites count once, 25 sites three times, 50 sites five times. The count is taken whole or not at all: a search that does not fit is refused with `429 RATE_LIMITED`, uses none of the limit, and `Retry-After` is the wait until all of it fits.
- **Capacity.** When the service is busy, it can be refused with `429 CAPACITY` where a plain search would have run. Nothing is charged. Wait `Retry-After` seconds and send it again.

[Credits and limits](https://millionshort.com/docs/credits-and-limits#rate-limits) has each plan's numbers.

### Without a key

The [playground](https://millionshort.com/docs/authentication#without-a-key) and the no-key mode of the [MCP server](https://millionshort.com/docs/mcp) can list the curated Spaces and search with one, as `curated:` and its slug. Their own bounds stay: one source (the first, when the Space names several), up to five results, and the first 20 sites of a Space with `mode: only`, said in a `space_sites_cut` warning. Making a Space needs a key.

## Curated Spaces

Curated Spaces are ours: scopes we have put together for a subject, the same ones the MillionShort search site offers. Every caller can read them and search with them, and nobody but us can change them.

- List them with `GET /v1/spaces?scope=curated`.
- Use one as `"space": "curated:<slug>"`.
- Changing or deleting one is refused with `403 SPACE_READ_ONLY`. To change one, read it and create your own Space from its fields: it then belongs to your team and counts towards your limit.

## Errors

| Code | HTTP | Meaning | Retry? |
|---|---|---|---|
| `SPACE_NOT_FOUND` | 404 | No such Space for this caller: it does not exist, or it belongs to another team. The two are not told apart. | No. |
| `SPACE_READ_ONLY` | 403 | A curated Space cannot be changed or deleted. | No. Create your own Space from its fields. |

Also: `400 INVALID_PARAM` for the cases under [Rules](#rules); `403 QUOTA_EXCEEDED` at the plan's number of Spaces; `401` for a missing or refused key; `429`. A search that names a Space that does not exist is answered with `404 SPACE_NOT_FOUND` and charged nothing. See [Errors](https://millionshort.com/docs/errors).

## In the SDKs

Both SDKs carry one method per endpoint, and `space` on `search`:

| Endpoint | Python | TypeScript |
|---|---|---|
| `POST /v1/spaces` | `create_space` | `createSpace` |
| `GET /v1/spaces` | `list_spaces` | `listSpaces` |
| `GET /v1/spaces/{id}` | `get_space` | `getSpace` |
| `PATCH /v1/spaces/{id}` | `update_space` | `updateSpace` |
| `DELETE /v1/spaces/{id}` | `delete_space` | `deleteSpace` |
| `POST /v1/spaces/import` | `import_spaces` | `importSpaces` |
| `POST /v1/search` with `space` | `search(..., space="baking")` | `search(..., { space: 'baking' })` |

The [Python](https://millionshort.com/docs/sdks/python#spaces) and [TypeScript](https://millionshort.com/docs/sdks/typescript#spaces) pages have samples.

## Over MCP

Two tools of the [MCP server](https://millionshort.com/docs/mcp#spaces) work with Spaces: `list_spaces`, which only reads and lists the curated Spaces without a key, and `create_space`, which needs a key. The `search` tool takes `space`.

## Without a Space

A Space saves what a search request can already say. To keep the scope in your own store instead, send it with each search: `include_domains` or `boost_domains` for the sites, `remove_top_sites`, the page-type and topic lists, and the site filters. [Lenses](https://millionshort.com/docs/search/lenses) and [Filters for agents](https://millionshort.com/docs/search/filters) show each one.
