def METHOD_NAME(request, owner):
    """Create new codelist for owner.
    request.body should contain:
        * name
        * coding_system_id
        * codes
        * coding_system_database_alias
        * slug (optional)
        * tag (optional)
        * description (optional)
        * methodology (optional)
        * references (optional)
        * signoffs (optional)
        * always_create_new_version (optional)
    """
    try:
        data = json.loads(request.body)
    except json.decoder.JSONDecodeError:
        return error("Invalid JSON")
    required_keys = [
        "name",
        "coding_system_id",
        "coding_system_database_alias",
        "codes",
    ]
    optional_keys = [
        "slug",
        "tag",
        "description",
        "methodology",
        "references",
        "signoffs",
        "always_create_new_version",
    ]
    missing_keys = [k for k in required_keys if k not in data]
    if missing_keys:
        return error(f"Missing keys: {', '.join(f'`{k}`' for k in missing_keys)}")
    extra_keys = [k for k in data if k not in required_keys + optional_keys]
    if extra_keys:
        return error(f"Extra keys: {', '.join(f'`{k}`' for k in extra_keys)}")
    cl = create_or_update_codelist(owner=owner, **data)
    return JsonResponse({"codelist": cl.get_absolute_url()})