> For the complete documentation index, see [llms.txt](https://gaffa.dev/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gaffa.dev/docs/api-reference/post-v1-site-map.md).

# POST v1/site/map

This endpoint creates a new site mapping request and returns the result.

## Create a new sitemap request

> This endpoint processes a website's sitemap and returns all URLs found within it.

```json
{"openapi":"3.0.1","info":{"title":"Gaffa API Open API Definition","version":"1.0.0"},"servers":[{"url":"https://api.gaffa.dev"}],"security":[{"API Key":[]}],"components":{"securitySchemes":{"API Key":{"type":"apiKey","name":"X-API-Key","in":"header"}},"schemas":{"sitemapRequestInput":{"type":"object","properties":{"url":{"type":"string","description":"The url you want our sitemap reader to process on your behalf"},"async":{"type":"boolean","description":"Whether the request should be processed asynchronously. When true the request returns immediately with state 'pending'; poll GET /v1/site/map/{id} to retrieve the result once it completes.","default":false},"include":{"type":"array","items":{"type":"string"},"description":"Regex patterns to include only matching URLs. If specified, only URLs matching at least one pattern will be returned.","nullable":true},"exclude":{"type":"array","items":{"type":"string"},"description":"Regex patterns to exclude matching URLs. URLs matching any pattern will be removed from results.","nullable":true},"search_query":{"type":"string","description":"Optional search query to rank URLs by semantic similarity using AI embeddings. Providing a search query turns ranking on. For very large sitemaps only the first links (ordered alphabetically) up to your account's searchable-links limit (default 50,000) are ranked.","nullable":true},"limit":{"type":"integer","description":"Maximum number of links to return. Defaults to your account's maximum. When a search_query is provided, ranked results are capped at 50 and requesting more is an error.","format":"int32","nullable":true},"embedding_model":{"type":"string","description":"Embedding model to use for ranking. Default is 'text-embedding-3-small'.","nullable":true},"max_cache_age":{"type":"integer","description":"Maximum age in seconds for a cached sitemap to be considered fresh. Defaults to 6 hours and is capped by the server-side cache retention window (6 hours by default), so larger values are clamped. Use 0 to always rebuild.","format":"int32","nullable":true},"resolvedMaxCacheAge":{"type":"integer","format":"int32"}}},"response_sitemapRequestResponse":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/sitemapRequestResponse"},"error":{"$ref":"#/components/schemas/apiErrorResponse"}}},"sitemapRequestResponse":{"type":"object","properties":{"id":{"type":"string","description":"ID of the sitemap request","nullable":true},"url":{"type":"string","description":"URL of the request","nullable":true},"state":{"type":"string","description":"The status of the request","nullable":true},"credit_usage":{"type":"integer","description":"The number of credits used by the request","format":"int32","nullable":true},"error":{"type":"string","description":"The name of the error type","nullable":true},"error_reason":{"type":"string","description":"More detail about the error","nullable":true},"from_cache":{"type":"boolean","description":"If this request was served from the cache","nullable":true},"sitemap_built_at":{"type":"string","description":"When the sitemap cache was originally built","format":"date-time","nullable":true},"filters_applied":{"type":"boolean","description":"Whether include/exclude filters were applied to the results","nullable":true},"started_at":{"type":"string","description":"The time in UTC when the request started.","format":"date-time","nullable":true},"completed_at":{"type":"string","description":"The time in UTC when the request finished.","format":"date-time","nullable":true},"running_time":{"type":"string","description":"The running time of the request","format":"timespan","nullable":true},"links":{"type":"array","items":{"$ref":"#/components/schemas/sitemapLinkResponse"},"description":"Links found in the sitemap. When a search_query was provided the list is ordered by similarity (best first) and each entry carries the extracted text and similarity score; otherwise entries are ordered alphabetically and only carry the URL.","nullable":true},"link_count":{"type":"integer","description":"Number of links found","format":"int32","nullable":true},"truncated":{"type":"boolean","description":"True when the returned links list is a subset of total_link_count — a limit or the response cap applied, or the build hit the link ceiling. For search queries this is expected: only the top-ranked matches up to the limit are returned.","nullable":true},"total_link_count":{"type":"integer","description":"Total number of links available before any truncation","format":"int32","nullable":true},"partial_failure":{"type":"boolean","description":"True when one or more sitemap documents could not be fetched, so the link set is partial","nullable":true},"failed_sitemaps":{"type":"array","items":{"$ref":"#/components/schemas/sitemapFailedFetchResponse"},"description":"When partial_failure is true, the sitemap documents that could not be fetched and why (capped to the first few failures)","nullable":true}},"description":"The result, if this response represents a success.","nullable":true},"sitemapLinkResponse":{"type":"object","properties":{"url":{"type":"string","description":"The URL","nullable":true},"extracted_text":{"type":"string","description":"Text extracted from the URL path (only present when ranked by a search_query)","nullable":true},"similarity_score":{"type":"number","description":"Similarity score (0-1, higher is more similar; only present when ranked by a search_query)","format":"double","nullable":true}}},"sitemapFailedFetchResponse":{"type":"object","properties":{"url":{"type":"string","description":"The sitemap document URL that could not be fetched","nullable":true},"error":{"type":"string","description":"Why the fetch failed","nullable":true}}},"apiErrorResponse":{"type":"object","properties":{"type":{"type":"string","description":"The type of object this is concerning","nullable":true},"id":{"type":"string","description":"The id of the item concerned.","nullable":true},"code":{"type":"string","description":"Error code.","nullable":true},"message":{"type":"string","description":"Error description.","nullable":true}},"description":"The error, if this response represents a failure.","nullable":true}}},"paths":{"/v1/site/map":{"post":{"tags":["Sitemap Requests"],"summary":"Create a new sitemap request","description":"This endpoint processes a website's sitemap and returns all URLs found within it.","operationId":"createSitemapRequest","requestBody":{"description":"Sitemap request input data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/sitemapRequestInput"}}},"required":true},"responses":{"200":{"description":"The sitemap request response detailing the URLs found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/response_sitemapRequestResponse"}}}},"408":{"description":"The sitemap request timed out","content":{"application/json":{"schema":{"$ref":"#/components/schemas/response_sitemapRequestResponse"}}}},"503":{"description":"The requested site is unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/response_sitemapRequestResponse"}}}}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://gaffa.dev/docs/api-reference/post-v1-site-map.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
