# How do I schedule automatic reindexing for my knowledge bases? You can [create a scheduled function](https://docs.digitalocean.com/products/functions/how-to/schedule-functions/index.html.md) to automatically reindex your knowledge base on a schedule you choose. For example, you can use the following Python script, which triggers a reindex usin g[PyDo’s `create_indexing_job()`](https://docs.digitalocean.com/reference/pydo/reference/genai/create_indexing_job/index.html.md): ```python from pydo import Client import os c = Client(os.getenv("DO_API_KEY")) c.genai.create_indexing_job(body={ "knowledge_base_uuid": "KB UUID", "data_source_uuids": ["DS UUID"] # optional, reindexes all data sources if not specified }) ``` You can also write your own function that sends a POST request to [the indexing jobs API endpoint](https://docs.digitalocean.com/reference/api/digitalocean/index.html.md#tag/GradientAI-Platform/operation/genai_create_indexing_job). ## Learn More [How to Schedule Functions](https://docs.digitalocean.com/products/functions/how-to/schedule-functions/index.html.md): Schedule functions to run periodically. [DigitalOcean API Reference](https://docs.digitalocean.com/reference/api/digitalocean/index.html.md): Complete reference documentation for the DigitalOcean API, including request samples in cURL, Python, Go, and Ruby.