diff --git a/CHANGELOG.md b/CHANGELOG.md
index cdb3286..77505dd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,3 +4,4 @@
 - Info endpoint (/) for API v1
 - Add new datasets using the command line
 - Update existing datasets using the command line
+- Delete a dataset using the command line
diff --git a/cgbeacon2/cli/add.py b/cgbeacon2/cli/add.py
index 5dc977a..64cb633 100644
--- a/cgbeacon2/cli/add.py
+++ b/cgbeacon2/cli/add.py
@@ -42,9 +42,14 @@ def dataset(id, name, build, desc, version, url, cc, info, update):
     dataset_obj = {
         '_id' : id,
         'name' : name,
-        'assembly_id' : build,
-        'created' : datetime.datetime.now(),
+        'assembly_id' : build
     }
+
+    if update is True:
+        dataset_obj["updated"] = datetime.datetime.now()
+    else:
+        dataset_obj["created"] = datetime.datetime.now()
+
     if desc is not None:
         dataset_obj["description"] = desc
 
diff --git a/cgbeacon2/cli/commands.py b/cgbeacon2/cli/commands.py
index c06e941..cbbaad0 100644
--- a/cgbeacon2/cli/commands.py
+++ b/cgbeacon2/cli/commands.py
@@ -6,6 +6,7 @@ from flask.cli import FlaskGroup
 
 from cgbeacon2.server import create_app
 from .add import add
+from .delete import delete
 
 @click.version_option(__version__)
 @click.group(cls=FlaskGroup, create_app=create_app, invoke_without_command=False, add_default_commands=True,
@@ -16,3 +17,4 @@ def cli(**_):
 
 
 cli.add_command(add)
+cli.add_command(delete)
diff --git a/cgbeacon2/cli/delete.py b/cgbeacon2/cli/delete.py
new file mode 100644
index 0000000..04956fa
--- /dev/null
+++ b/cgbeacon2/cli/delete.py
@@ -0,0 +1,32 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+import click
+from flask.cli import with_appcontext, current_app
+
+from cgbeacon2.utils.delete import delete_dataset
+
+@click.group()
+def delete():
+    """Delete items from database using the CLI"""
+    pass
+
+@delete.command()
+@with_appcontext
+@click.option('-id', type=click.STRING, nargs=1, required=True, help="dataset ID")
+def dataset(id):
+    """Delete a dataset using its _id key
+
+    Accepts:
+        id(str): dataset _id field
+    """
+
+    click.echo(f"deleting dataset with id '{id}' from database")
+
+    deleted = delete_dataset(mongo_db=current_app.db, id=id)
+
+    if deleted is None:
+        click.echo("Aborting")
+    elif deleted == 0:
+        click.echo(f"Coundn't find a dataset with id '{id}' in database.")
+    elif deleted == 1:
+        click.echo("Dataset was successfully deleted")
diff --git a/cgbeacon2/utils/add.py b/cgbeacon2/utils/add.py
index 8095a0e..0c9bf67 100644
--- a/cgbeacon2/utils/add.py
+++ b/cgbeacon2/utils/add.py
@@ -24,13 +24,12 @@ def add_dataset(mongo_db, dataset_dict, update=False):
         if old_dataset is None:
             LOG.fatal("Couldn't find any dataset with id '{}' in the database".format(dataset_dict['_id']))
             return
-
+        dataset_dict["created"] = old_dataset["created"]
         result = mongo_db[collection].replace_one({'_id': dataset_dict['_id']}, dataset_dict)
         if result.modified_count > 0:
             return dataset_dict['_id']
         else:
             return
-
     try:
         result = mongo_db[collection].insert_one(dataset_dict)
 
diff --git a/cgbeacon2/utils/delete.py b/cgbeacon2/utils/delete.py
new file mode 100644
index 0000000..d551319
--- /dev/null
+++ b/cgbeacon2/utils/delete.py
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+import logging
+
+LOG = logging.getLogger(__name__)
+
+def delete_dataset(mongo_db, id):
+    """Delete a dataset from dataset collection
+
+    Accepts:
+        id(str): dataset id
+
+    Returns:
+        result.deleted(int): number of deleted documents
+    """
+
+    collection = "dataset"
+
+    try:
+        result = mongo_db[collection].delete_one({"_id":id})
+    except Exception as err:
+        LOG.error(err)
+        return
+    return result.deleted_count

Code to delete a dataset
diff --git a/tests/cli/add/__init__.py b/tests/cli/add/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/tests/cli/test_add_dataset.py b/tests/cli/add/test_add_dataset.py
similarity index 97%
rename from tests/cli/test_add_dataset.py
rename to tests/cli/add/test_add_dataset.py
index 2369fff..244fc6f 100644
--- a/tests/cli/test_add_dataset.py
+++ b/tests/cli/add/test_add_dataset.py
@@ -1,11 +1,12 @@
 # -*- coding: utf-8 -*-
-from cgbeacon2.cli.commands import cli
+import datetime
 
+from cgbeacon2.cli.commands import cli
 
 def test_add_dataset_no_id(test_dataset_cli, mock_app):
     """Test the cli command which adds a dataset to db without a required param"""
 
-     # test add a dataset_obj using the app cli
+    # test add a dataset_obj using the app cli
     runner = mock_app.test_cli_runner()
 
     dataset = test_dataset_cli
@@ -174,6 +175,7 @@ def test_update_dataset(test_dataset_cli, mock_app, database):
     runner = mock_app.test_cli_runner()
 
     dataset = test_dataset_cli
+    dataset["created"] = datetime.datetime.now()
 
     # Having a database dataset collection with one item
     result = database["dataset"].insert_one(dataset)
@@ -202,3 +204,4 @@ def test_update_dataset(test_dataset_cli, mock_app, database):
     # And the dataset should be updated
     updated_dataset = database["dataset"].find_one({"_id": dataset["_id"]})
     assert updated_dataset["version"] == 2
+    assert updated_dataset["updated"] is not None
diff --git a/tests/cli/delete/__init__.py b/tests/cli/delete/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/tests/cli/delete/test_delete_dataset.py b/tests/cli/delete/test_delete_dataset.py
new file mode 100644
index 0000000..486dade
--- /dev/null
+++ b/tests/cli/delete/test_delete_dataset.py
@@ -0,0 +1,57 @@
+# -*- coding: utf-8 -*-
+import click
+
+from cgbeacon2.cli.commands import cli
+
+def test_delete_non_existing_dataset(mock_app):
+    """Test the command to delete a dataset when dataset doesn't exist"""
+
+    # test add a dataset_obj using the app cli
+    runner = mock_app.test_cli_runner()
+
+    # When invoking the command without the -id parameter
+    result =  runner.invoke(cli, [
+        'delete',
+        'dataset',
+        '-id', 'foo'
+        ])
+
+    # Then the command should run
+    assert result.exit_code == 0
+
+    # and return a warning
+    assert "Coundn't find a dataset with id 'foo' in database" in result.output
+
+def test_delete_existing_dataset(test_dataset_cli, mock_app, database):
+    """Test the command line to delete an existing dataset"""
+
+    # test add a dataset_obj using the app cli
+    runner = mock_app.test_cli_runner()
+
+    dataset = test_dataset_cli
+
+    # When a dataset is inserted into database
+    result =  runner.invoke(cli, [
+       'add',
+       'dataset',
+       '-id', dataset["_id"],
+       '-name', dataset["name"],
+       ])
+
+    new_dataset = database["dataset"].find_one()
+    assert new_dataset is not None
+
+    # If the dataset delete command is invoked providing the right database id
+    result =  runner.invoke(cli, [
+       'delete',
+       'dataset',
+       '-id', new_dataset["_id"],
+       ])
+
+    # Then the command should be executed with no errors
+    assert result.exit_code == 0
+    assert "Dataset was successfully deleted" in result.output
+
+    # And the dataset should be removed from the database
+    new_dataset = database["dataset"].find_one()
+    assert new_dataset is None

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest pytest-cov mongomock
apt-get update apt-get install -y gcc
3.9
requirements.txt requirements-dev.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
blinker==1.9.0
certifi==2025.1.31
-e git+https://github.com/Clinical-Genomics/cgbeacon2.git@b2d8b02cc353864c03cb3dc717860fec40e5b21d#egg=cgbeacon2
charset-normalizer==3.4.1
click==8.1.8
coverage==7.8.0
coveralls==4.0.1
dnspython==2.7.0
docopt==0.6.2
exceptiongroup==1.2.2
Flask==3.1.0
idna==3.10
importlib_metadata==8.6.1
iniconfig==2.1.0
itsdangerous==2.2.0
Jinja2==3.1.6
MarkupSafe==3.0.2
mongomock==4.3.0
packaging==24.2
pluggy==1.5.0
pymongo==4.11.3
pytest==8.3.5
pytest-cov==6.0.0
pytz==2025.2
requests==2.32.3
sentinels==1.0.0
tomli==2.2.1
urllib3==2.3.0
Werkzeug==3.1.3
zipp==3.21.0

name: cgbeacon2
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - blinker==1.9.0
      - certifi==2025.1.31
      - charset-normalizer==3.4.1
      - click==8.1.8
      - coverage==7.8.0
      - coveralls==4.0.1
      - dnspython==2.7.0
      - docopt==0.6.2
      - exceptiongroup==1.2.2
      - flask==3.1.0
      - idna==3.10
      - importlib-metadata==8.6.1
      - iniconfig==2.1.0
      - itsdangerous==2.2.0
      - jinja2==3.1.6
      - markupsafe==3.0.2
      - mongomock==4.3.0
      - packaging==24.2
      - pluggy==1.5.0
      - pymongo==4.11.3
      - pytest==8.3.5
      - pytest-cov==6.0.0
      - pytz==2025.2
      - requests==2.32.3
      - sentinels==1.0.0
      - tomli==2.2.1
      - urllib3==2.3.0
      - werkzeug==3.1.3
      - zipp==3.21.0
prefix: /opt/conda/envs/cgbeacon2

tests/cli/add/test_add_dataset.py::test_update_dataset tests/cli/delete/test_delete_dataset.py::test_delete_non_existing_dataset tests/cli/delete/test_delete_dataset.py::test_delete_existing_dataset
tests/cli/add/test_add_dataset.py::test_add_dataset_wrong_build
tests/cli/add/test_add_dataset.py::test_add_dataset_no_id tests/cli/add/test_add_dataset.py::test_add_dataset_no_name tests/cli/add/test_add_dataset.py::test_add_dataset_complete tests/cli/add/test_add_dataset.py::test_add_dataset_wrong_consent tests/cli/add/test_add_dataset.py::test_update_non_existent_dataset
cgbeacon2/cli/delete.py cgbeacon2/cli/commands.py CHANGELOG.md cgbeacon2/utils/add.py cgbeacon2/cli/add.py cgbeacon2/utils/delete.py
cgbeacon2/cli/delete.py cgbeacon2/cli/commands.py CHANGELOG.md cgbeacon2/utils/add.py cgbeacon2/cli/add.py cgbeacon2/utils/delete.py