What are the valid types for the type parameter in bpy.context.scene.node_tree.nodes.new(type)?
The correct type for this would be: 'CompositorNodeIDMask'.

Too create a new ID Mask node the line would be :  C.scene.node_tree.nodes.new('CompositorNodeIDMask')

If this is confusing, at least they have a pattern so you have 'CompositorNode'or'ShaderNode'or'TextureNode' plus the node type like 'ShaderNode'+'ObjectInfo'.

For the full list of node types see these links: shader nodes, compositor nodes and texture nodes