POST /api/v2/sitemaps/generate

Request Body

Send a JSON payload containing the configuration for your sitemap generation job. All fields except domain are optional. The system uses intelligent crawling to respect robots.txt and server load limits.

Parameter Type Required Description
domain string Yes The base domain to crawl (e.g., example.com)
depth integer No Maximum crawl depth (1-10). Default: 5
include_assets boolean No Include CSS, JS, and media files. Default: false
priority_mode string No Algorithm for URL priority: auto, manual, or ml_score

Example Request

const response = await fetch('https://api.sitemap.xml/api/v2/sitemaps/generate', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': `Bearer ${API_KEY}`
  },
  body: JSON.stringify({
    domain: 'myapp.io',
    depth: 7,
    include_assets: true,
    priority_mode: 'ml_score'
  })
});

const data = await response.json();
console.log(data);

Response

On success, the API returns a 202 Accepted status with a job ID. Use the GET /api/v2/jobs/{id} endpoint to track progress. The system automatically handles pagination and sitemap index files for large domains.

{
  "status": "accepted",
  "job_id": "sj_8f9a2c1d4e5b",
  "estimated_completion": "2025-03-15T14:22:00Z",
  "webhook_url": null,
  "crawl_budget_remaining": 4820
}

Error Handling

The API uses standard HTTP status codes. Common errors include:

Status Code Meaning
400 INVALID_PAYLOAD Missing required fields or malformed JSON
401 AUTH_FAILED Missing or expired API key
429 RATE_LIMITED Too many requests. Retry after X-RateLimit-Reset
503 CRAWLER_UNAVAILABLE Target domain is blocking crawlers or unreachable

Next Steps

After generation completes, you can: