import secrets


def generate_numeric_id(num_digits):
    """
    Generate a numeric ID with the provided number of digits.

    Args:
        num_digits:
            The number of digits present in the returned ID.

    Returns:
        A random ID with the specified number of digits.
    """
    if num_digits < 1:
        raise ValueError('The number of digits in the ID must be at least 1.')

    lower_bound = 10 ** (num_digits - 1)
    upper_bound = 10 ** num_digits - 1

    # Random generates a number in the range [0, bound), so we have to
    # offset it by our lower bound.
    rand_bound = upper_bound - lower_bound + 1

    return secrets.randbelow(rand_bound) + lower_bound