Programmatically create alias using pathauto for node
Basically to generate URL aliases in code using the pathauto module you would have something like this:

module_load_include('inc', 'pathauto'); // include the inc file for Pathauto module

/*
   pathauto_create_alias($module, $op, $source, $data, $type, $language)
   @param $module: Your module name
   @param $op: The operation (insert, update, return, bulkupdate)
   @param $source: Internal Drupal path (i.e.: node/1)
   @param $data: Addition data used to generate a pathalias, in this case the node object
   @param $type: Type of content that will be used to match a pattern, defined in the backend url alias patterns
   @param $language: If you have a multlingual website, you need to pass the language for which you want to generate the url alias
*/

pathauto_create_alias('your_module_name', 'insert', 'node/1', array('node' =&gt; $node), $node-&gt;type, $language-&gt;language); // Language is optional