Custom tokens in custom module
You would have to add them to a global token piece like [site] for them to be able to be used anywhere tokens are used. 

But to use in a custom module you can use the following hooks:

Generate token info:

/**
 * Implements hook_token_info().
 */
function module_name_token_info() {
  $info = array();
  // Define a new token type.
  $info['types']['my_custom_tokens'] = array(
    'name' =&gt; t('My custom tokens'),
    'description' =&gt; t('A token type for my custom tokens.'),
  );
  // Define any new tokens.
  $info['tokens']['my_custom_tokens']['my_token'] = array(
    'name' =&gt; t('My token'),
    'description' =&gt; t('A token I use in my module.'),
  );
  return $info;
}


Give values to token:

/**
 * Implements hook_tokens().
 */
function module_name_tokens($type, $tokens, array $data = array(), array $options = array()) {
  $replacements = array();

  if ($type == 'my_custom_tokens') {
    // Loop through the available tokens.
    foreach ($tokens as $name =&gt; $original) {
      // Find our custom tokens by name.
      switch ($name) {
        case 'my_token':
          // Work out the value of our token.
          $value = 'Value of token';
          // Give our token it's value!
          $replacements[$original] = $value;
          break;
      }
    }
  }

  return $replacements;
}


That should get you started with custom tokens. I've used this a few different times with different situations and it works very well.