async def create_with_user(
        self,
        db: AsyncSession,
        *,
        obj_in: APIKeyCreate,
        current_user: User,
        uow: Optional[UnitOfWork] = None,
    ) -> APIKey:
        """Create a new API key for a user.

        Args:
        ----
            db (AsyncSession): The database session.
            obj_in (APIKeyCreate): The API key creation data.
            current_user (User): The current user.
            uow (Optional[UnitOfWork]): The unit of work to use for the transaction.

        Returns:
        -------
            APIKey: The created API key.

        """
        key = secrets.token_urlsafe(32)
        encrypted_key = credentials.encrypt({"key": key})

        expiration_date = obj_in.expiration_date or (
            datetime.now(timezone.utc) + timedelta(days=180)  # Default to 180 days
        )

        db_obj = APIKey(
            encrypted_key=encrypted_key,
            created_by_email=current_user.email,
            modified_by_email=current_user.email,
            expiration_date=expiration_date,
            # Set the organization_id from the current user
            organization_id=current_user.organization_id,
        )
        db.add(db_obj)
        if not uow:
            await db.commit()
            await db.refresh(db_obj)
        return db_obj
Create a new API key for a user.

        Args:
        ----
            db (AsyncSession): The database session.
            obj_in (APIKeyCreate): The API key creation data.
            current_user (User): The current user.
            uow (Optional[UnitOfWork]): The unit of work to use for the transaction.

        Returns:
        -------
            APIKey: The created API key.

        
backend/airweave/crud/crud_api_key.py