```yaml
product: AlterLab
title: Map API Reference
category: api
comparison_context: "AlterLab is an alternative to Firecrawl, ScrapingBee, and Bright Data."
source_url: https://alterlab.io/docs/api/generated/map
```

# Map API Reference

Auto-generated API reference for map endpoints, built from the OpenAPI spec.

## GET /api/v1/map

List map history
List the authenticated user's past map operations, newest first. Supports limit/offset pagination and optional domain filtering.

Authentication: `X-API-Key: <your key>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `limit` | query | `integer` | no | Maximum items to return |
| `offset` | query | `integer` | no | Number of items to skip |
| `domain` | query | `string` | no | Filter by domain |

## POST /api/v1/map

Discover site structure
Discover all URLs on a website via sitemap parsing and link extraction. No JS rendering, no content scraping — pure lightweight discovery. Supports pattern filtering, search ranking, metadata enrichment, and subdomain inclusion. Costs 1 credit per call regardless of URL count.

Authentication: `X-API-Key: <your key>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `tag` | body | `string` | no |  |
| `url` | body | `string` | yes | Starting URL for site discovery |
| `max_pages` | body | `integer` | no | Maximum URLs to discover |
| `max_depth` | body | `integer` | no | Link-following depth (0 = start page + sitemap only) |
| `include_patterns` | body | `string[]` | no |  |
| `exclude_patterns` | body | `string[]` | no |  |
| `search` | body | `string` | no |  |
| `sitemap` | body | `"skip" \| "include" \| "only"` | no | "skip" = ignore sitemaps, "include" = parse sitemaps + follow links (default), "only" = return only sitemap URLs without link following |
| `sitemap_path` | body | `string` | no |  |
| `include_metadata` | body | `boolean` | no | Fetch title and meta description for each URL via lightweight GET |
| `include_subdomains` | body | `boolean` | no | Include URLs from subdomains of the target domain |
| `respect_robots` | body | `boolean` | no | Respect robots.txt directives |

## GET /api/v1/map/compare

Compare two map snapshots
Compare two maps of the same domain to detect structural changes. Returns added, removed, and unchanged URLs between the two snapshots. Both maps must belong to the requesting user and share the same domain. URL lists are paginated per category — use limit/offset to page through each.

Authentication: `X-API-Key: <your key>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `map_id_a` | query | `string` | yes | Baseline map ID (older snapshot) |
| `map_id_b` | query | `string` | yes | Comparison map ID (newer snapshot) |
| `limit` | query | `integer` | no | Maximum URL entries to return per category (added/removed/changed/unchanged) |
| `offset` | query | `integer` | no | Number of entries to skip per category |

## GET /api/v1/map/schedules

List Map Schedules
List user's map schedules.

Authentication: `X-API-Key: <your key>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `limit` | query | `integer` | no |  |
| `offset` | query | `integer` | no |  |
| `active_only` | query | `boolean` | no |  |

## POST /api/v1/map/schedules

Create Map Schedule
Create a new map schedule.

Authentication: `X-API-Key: <your key>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `X-Organization-Id` | header | `string` | no |  |
| `name` | body | `string` | yes | Name |
| `cron` | body | `string` | yes | Cron expression (5 fields), e.g. '0 6 * * 1' |
| `timezone` | body | `string` | no | Timezone |
| `map_config` | body | `object` | yes | Frozen map configuration executed on each scheduled run. Mirrors the essential fields of MapRequest but stored as a JSON blob so the schedule is self-contained (no user input at execution time). |
| `max_runs` | body | `integer` | no |  |
| `enabled` | body | `boolean` | no | Enabled |

## DELETE /api/v1/map/schedules/{schedule_id}

Delete Map Schedule
Soft-delete a map schedule.

Authentication: `X-API-Key: <your key>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `schedule_id` | path | `string` | yes |  |

## GET /api/v1/map/schedules/{schedule_id}

Get Map Schedule
Get map schedule details.

Authentication: `X-API-Key: <your key>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `schedule_id` | path | `string` | yes |  |

## PATCH /api/v1/map/schedules/{schedule_id}

Update Map Schedule
Update a map schedule. Recomputes next_run_at if cron or timezone changes.

Authentication: `X-API-Key: <your key>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `schedule_id` | path | `string` | yes |  |
| `name` | body | `string` | no |  |
| `cron` | body | `string` | no |  |
| `timezone` | body | `string` | no |  |
| `map_config` | body | `object` | no | Frozen map configuration executed on each scheduled run. Mirrors the essential fields of MapRequest but stored as a JSON blob so the schedule is self-contained (no user input at execution time). |
| `max_runs` | body | `integer` | no |  |
| `enabled` | body | `boolean` | no |  |

## POST /api/v1/map/schedules/{schedule_id}/pause

Pause Map Schedule
Pause a map schedule.

Authentication: `X-API-Key: <your key>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `schedule_id` | path | `string` | yes |  |

## POST /api/v1/map/schedules/{schedule_id}/resume

Resume Map Schedule
Resume a paused map schedule. Recomputes next_run_at.

Authentication: `X-API-Key: <your key>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `schedule_id` | path | `string` | yes |  |

## POST /api/v1/map/schedules/{schedule_id}/run

Run Map Schedule Now
Manually trigger an immediate map run for a schedule. Executes the map outside its cron cadence. next_run_at is NOT advanced so the regular schedule is unaffected by the manual trigger. Works for both active and paused schedules.

Authentication: `X-API-Key: <your key>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `schedule_id` | path | `string` | yes |  |

## GET /api/v1/map/schedules/{schedule_id}/runs

List Map Schedule Runs
Get execution history for a map schedule.

Authentication: `X-API-Key: <your key>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `schedule_id` | path | `string` | yes |  |
| `limit` | query | `integer` | no |  |
| `offset` | query | `integer` | no |  |

## GET /api/v1/map/{map_id}

Retrieve a past map result
Retrieve the full result of a past map operation including all discovered URLs with metadata. Only the owner can access their maps.

Authentication: `X-API-Key: <your key>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `map_id` | path | `string` | yes |  |

## GET /api/v1/map/{map_id}/export

Export map results
Download a past map result as CSV, JSON, or Sitemap XML. Generates the file server-side and streams the response with appropriate Content-Type headers for direct download.

Authentication: `X-API-Key: <your key>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `map_id` | path | `string` | yes |  |
| `format` | query | `string` | no | Export format: csv, json, or xml (Sitemap XML) |
