---
title: prefactor_core.utils module
editUrl: true
head: []
template: doc
sidebar:
  hidden: false
  attrs: {}
pagefind: true
draft: false
---

# prefactor_core.utils module

Utility functions for prefactor-core.

### prefactor_core.utils.generate_idempotency_key() → str

Generate a new UUID-based idempotency key.

The returned key is a UUID4 string (36 characters), always within the
64-character API limit.

* **Returns:**
  A unique idempotency key string.

### prefactor_core.utils.validate_idempotency_key(key: str) → str

Validate that an idempotency key is a non-empty string of at most 64 characters.

* **Parameters:**
  **key** – The idempotency key to validate.
* **Returns:**
  The key unchanged if valid.
* **Raises:**
  **ValueError** – If the key is empty or exceeds 64 characters.