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?

3 Answers 3


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 v4. Enter the following and click Execute: Add api_key for desired contact with Api Explorer

For those wanting to use APIv3, navigate to Support > Developer > Api v3 (/civicrm/api3#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, 2016 at 14:47
  • I've also updated the Wiki page with a link to this question.
    – G H
    Mar 14, 2016 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, 2017 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, 2016 at 9:33
  • I have checked it with 4.7.3 and it's working fine for me.
    – Prem Patel
    Mar 16, 2016 at 19:05

To add an API key to an existing contact in API Explorer v4:

  1. navigate to Support > Developer > API Explorer v4.

  2. In the "entity" drop-down menu select "contact", in the "action" drop-down select "update".

  3. In the "where" section select "id" from the "add clause" drop-down and make that equal to the contact id of the contact that you wish to add the API key to.

  4. In the "values" section select api_key from the "add value" drop-down and add your desired API key to the box that appears next to it.

  5. click the execute button.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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