---
title: "Extract URLs from a sitemap.xml"
method: POST
path: "/knowledgebase/get-sitemap-urls"
tags: ["Knowledge Base"]
---

# Extract URLs from a sitemap.xml

`POST /knowledgebase/get-sitemap-urls`

Fetches a website's `sitemap.xml`, parses it, and returns the list of URLs inside. Use this before calling `POST /knowledgebase/{id}/scrape-urls` to let the customer pick which URLs they actually want indexed.

Returns `422` if the URL doesn't return a fetchable sitemap or if the XML is malformed.

## Request body

- object
  - `siteUrl` string, uri, required — URL of the sitemap.xml file (or a homepage that links to one).
  - `knowledgeBaseId` string, required — Target knowledge base ID — used for ownership validation only. The endpoint doesn't write any URLs at this stage.

## Response `200`

Extracted URLs, ready to be filtered + passed to `/scrape-urls`.

- object
  - `status` boolean
  - `data` object
    - `urls` string[] — All URLs discovered in the sitemap.
    - `extractedAt` string, date-time

## Other responses

- `400` — Invalid input
- `401` — Unauthorized access
- `404` — Knowledge base not found in your organization.
- `422` — Could not fetch sitemap, or the sitemap XML is malformed.
- `500` — Internal server error

---

[API](https://skmtc.net/smallest-inc/apis/agent-management-api.md) · [All operations](https://skmtc.net/smallest-inc/apis/agent-management-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/smallest-inc/agent-management-api/versions/6d1036a76fbc/schema)
