Answers.Body: <p>You need to use the extension which creates an 'API Key' tab on the contact record.</p>
  
  <p><a href="https://github.com/cividesk/com.cividesk.apikey/archive/v1.0.zip" rel="nofollow">https://github.com/cividesk/com.cividesk.apikey/archive/v1.0.zip</a></p>
  
  <p>JMC</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-26T09:33:02.970Z
Answers.Text: It works on 4.2, 4.3, 4.4 and 4.5 in our experience
Answers.UserDisplayName: Jon-man
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-16T19:05:37.163Z
Answers.Text: I have checked it with 4.7.3 and it's working fine for me.
Answers.UserDisplayName: Prem Patel
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-26T09:31:50.960Z
Answers.LastActivityDate: 2016-02-26T09:31:50.960Z
Answers.UserDisplayName: Jon-man
Answers.Body: <p>To add an API key to an existing contact in API Explorer v4:</p>
  <ol>
  <li><p>navigate to Support &gt; Developer &gt; API Explorer v4.</p>
  </li>
  <li><p>In the &quot;entity&quot; drop-down menu select &quot;contact&quot;, in the &quot;action&quot; drop-down select &quot;update&quot;.</p>
  </li>
  <li><p>In the &quot;where&quot; section select &quot;id&quot; from the &quot;add clause&quot; drop-down and make that equal to the contact id of the contact that you wish to add the API key to.</p>
  </li>
  <li><p>In the &quot;values&quot; section select api_key from the &quot;add value&quot; drop-down and add your desired API key to the box that appears next to it.</p>
  </li>
  <li><p>click the execute button.</p>
  </li>
  </ol>
  <p><a href="https://i.sstatic.net/2Sqxp.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/2Sqxp.png" alt="" /></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-11-14T01:15:17.433Z
Answers.LastActivityDate: 2022-11-14T01:15:17.433Z
Answers.UserDisplayName: Toby-fz
Answers.Body: <p>Hopefully a new release will be made for the <a href="https://civicrm.org/extensions/api-key" rel="nofollow noreferrer">API Key</a> 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.</p>
  <p>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 &gt; 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. <a href="https://i.sstatic.net/QA3H3.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/QA3H3.png" alt="enter image description here" /></a></p>
  <p>Create a 16 character random value for the API Key, eg at <a href="http://passwordsgenerator.net/" rel="nofollow noreferrer">http://passwordsgenerator.net/</a> with settings that exclude special characters, eg <a href="https://i.sstatic.net/l1Noo.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/l1Noo.png" alt="Create random 16 character API key with a password generator" /></a></p>
  <p>Now use your CiviCRM installation's API explorer to set the API key for your user. Navigate to Support &gt; Developer &gt; Api Explorer v4. Enter the following and click Execute:
  <a href="https://i.sstatic.net/zTxyt.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/zTxyt.png" alt="Add api_key for desired contact with Api Explorer" /></a></p>
  <p>For those wanting to use APIv3, navigate to Support &gt; Developer &gt; 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.
  <a href="https://i.sstatic.net/7xumz.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/7xumz.png" alt="Use CiviCRM API Explorer to set the API key for newly created contact" /></a></p>
  <p>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'.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-14T14:47:15.647Z
Answers.Text: 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.
Answers.UserDisplayName: G H
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-14T14:53:56.803Z
Answers.Text: I've also updated the Wiki page with a link to this question.
Answers.UserDisplayName: G H
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-16T02:30:02.090Z
Answers.Text: 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?
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2016-02-25T19:36:40.557Z
Answers.LastActivityDate: 2022-11-15T18:30:32.013Z
Answers.LastEditDate: 2022-11-15T18:30:32.013Z
Answers.UserDisplayName: Joe Murray
Body: <p>The current documentation for creating an API key for user is on the wiki at <a href="https://wiki.civicrm.org/confluence/display/CRMDOC/REST+interface#RESTinterface-CreatingAPIkeysforusers">https://wiki.civicrm.org/confluence/display/CRMDOC/REST+interface#RESTinterface-CreatingAPIkeysforusers</a>. 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?</p>
  
Tags: <api><extension><security><rest>
Title: How do I set up an API key for a user?
ThreadText: # How do I set up an API key for a user?
  
  (Asked by: username_0 on 2016-02-25)
  
  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?
  
  **Tags:** api, extension, security, rest
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_0 on 2016-02-25. Score: 20 | Accepted answer
  
  Hopefully a new release will be made for the [API Key](https://civicrm.org/extensions/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](https://i.sstatic.net/QA3H3.png)](https://i.sstatic.net/QA3H3.png)
  
  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](https://i.sstatic.net/l1Noo.png)](https://i.sstatic.net/l1Noo.png)
  
  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](https://i.sstatic.net/zTxyt.png)](https://i.sstatic.net/zTxyt.png)
  
  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](https://i.sstatic.net/7xumz.png)](https://i.sstatic.net/7xumz.png)
  
  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'.
  
  > **Comments:**
  > **username_4**: 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.  
  > **username_4**: I've also updated the Wiki page with a link to this question.  
  > **username_5**: 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?  
  
  ---
  
  ### Answer by username_1 on 2016-02-26. Score: 3
  
  You need to use the extension which creates an 'API Key' tab on the contact record.
  
  <https://github.com/cividesk/com.cividesk.apikey/archive/v1.0.zip>
  
  JMC
  
  > **Comments:**
  > **username_1**: It works on 4.2, 4.3, 4.4 and 4.5 in our experience  
  > **username_2**: I have checked it with 4.7.3 and it's working fine for me.  
  
  ---
  
  ### Answer by username_3 on 2022-11-14. Score: 2
  
  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.
  
  [![](https://i.sstatic.net/2Sqxp.png)](https://i.sstatic.net/2Sqxp.png)
  
  
  ---
  
  