How to programmatically duplicate a node? I'm looking to create a copy of a webform I've made, with a new email address as the recipient.

After I load the node with node_load, can I just save it with node_save?  Will that create a new node with new timestamps and ids?

How can I get the nid of the new node that has been created?
Just unset the node ID with unset($node-&gt;nid), and node_save() will create a new node.

The code executed from node_save() is the following one:

// Insert a new node.
$node-&gt;is_new = empty($node-&gt;nid);
// ...
if ($node-&gt;is_new) {
  _node_save_revision($node, $user-&gt;uid);
  drupal_write_record('node', $node);
  db_query('UPDATE {node_revisions} SET nid = %d WHERE vid = %d', $node-&gt;nid, $node-&gt;vid);
  $op = 'insert';
}    


The last argument of drupal_write_record() is not passed; this means the function will not update an existing database row.

Once the node object has been saved with node_save(), $node-&gt;nid contains the node ID for the newly created database row.