The current documentation for creating an API key for user is on the wiki at https://wiki.civicrm.org/confluence/display/CRMDOC/REST+interface#RESTinterface-CreatingAPIkeysforusers. Unfortunately there is not a release for the user friendly API Key extension for CiviCRM 4.5, 4.6 or 4.7. And the manual method is not very user friendly for those who are not programmers. How can a relatively non-technical user set up an API key that is needed for an extension, for example?


Hopefully a new release will be made for the API Key extension soon. Here are detailed instructions for creating one manually without needing to get access to your database through phpMyAdmin, mysql on the command line or some similar MySQL database administration tool.

Usually it is a good idea to create a special separate contact for each service that needs to use CiviCRM's REST API. Do this at Contact > New Individual, enter a name like Attentive.ly Service, and click Save. At the bottom of your page in small faint type and in the url you can get the Contact ID of the new contact. enter image description here

Create a 16 character random value for the API Key, eg at http://passwordsgenerator.net/ with settings that exclude special characters, eg Create random 16 character API key with a password generator

Now use your CiviCRM installation's API explorer to set the API key for your user. Navigate to Support > Developer > API Explorer (/civicrm/api#explorer), and enter the following values then click on the Execute button. Note that the image shows Internal Contact ID as the fieldname. This is true CiviCRM up to version 4.6, but you'll need to select the Contact ID for versions 4.7 and above since it was relabeled in the API Explorer. Use CiviCRM API Explorer to set the API key for newly created contact

You will need to ensure that the contact is given a role that has the appropriate permissions required for the relevant Extension. At a minimum this will include 'Access AJAX API', and unless otherwise specified, 'Administer CiviCRM'.

  • Very nice! For completeness, please mark this as answered. Also, 4.7 changes things just slightly. The field "Internal Contact ID" is seen as "Contact ID." Additionally, don't forget to hit Execute to apply the changes.
    – G H
    Mar 14 '16 at 14:47
  • I've also updated the Wiki page with a link to this question.
    – G H
    Mar 14 '16 at 14:53
  • 1
    Does this need to mention that a User needs creating and eg in Drupal it might be easier to 'create new user' and get the civi contact as a result?
    – petednz - fuzion
    Feb 16 '17 at 2:30

You need to use the extension which creates an 'API Key' tab on the contact record.



  • It works on 4.2, 4.3, 4.4 and 4.5 in our experience
    – Jon-man
    Feb 26 '16 at 9:33
  • I have checked it with 4.7.3 and it's working fine for me.
    – Prem Patel
    Mar 16 '16 at 19:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.