async def METHOD_NAME(self, env: data.Environment, code_id: int, resources: JsonType) -> Apireturn:
    # validate
    for rtype, sources in resources.items():
        if not isinstance(rtype, str):
            raise BadRequest("All keys in the resources map must be strings")
        if not isinstance(sources, dict):
            raise BadRequest("All values in the resources map must be dicts")
        for name, refs in sources.items():
            if not isinstance(name, str):
                raise BadRequest("All keys in the sources map must be strings")
            if not isinstance(refs, (list, tuple)):
                raise BadRequest("All values in the sources map must be lists or tuple")
            if (
                len(refs) != 3
                or not isinstance(refs[0], str)
                or not isinstance(refs[1], str)
                or not isinstance(refs[2], list)
            ):
                raise BadRequest("The values in the source map should be of the form (filename, module, [requirements])")
    allrefs = [ref for sourcemap in resources.values() for ref in sourcemap.keys()]
    val = self.file_slice.stat_file_internal(allrefs)
    if len(val) != 0:
        raise BadRequest("Not all file references provided are valid", details={"references": val})
    code = await data.Code.get_versions(environment=env.id, version=code_id)
    oldmap: Dict[str, data.Code] = {c.resource: c for c in code}
    new = {k: v for k, v in resources.items() if k not in oldmap}
    conflict = [k for k, v in resources.items() if k in oldmap and oldmap[k].source_refs != v]
    if len(conflict) > 0:
        raise ServerError(
            "Some of these items already exists, but with different source files", details={"references": conflict}
        )
    newcodes = [
        data.Code(environment=env.id, version=code_id, resource=resource, source_refs=hashes)
        for resource, hashes in new.items()
    ]
    await data.Code.insert_many(newcodes)
    return 200