Answers.Body: <p>You can achieve this by giving the key 'tag_id' an array containing multiple tags. Something like this:</p>
  
  <p><code>'tag_id' =&gt; array('volunteer', 'Major Donor'),</code></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-05T00:52:06.203Z
Answers.Text: This returns an empty result. Tested against 4.7.25 and the as-yet-unreleased 4.7.31.
Answers.UserDisplayName: universalhandle
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-04T17:04:20.367Z
Answers.LastActivityDate: 2018-01-04T17:04:20.367Z
Answers.UserDisplayName: Hassan Farooq
Body: <p>If I tag a contact as a Major Donor and a Volunteer, I can retrieve their contact ID via the API using an API call such as:</p>
  
  <pre><code>$result = civicrm_api3('EntityTag', 'get', array(
    'entity_table' =&gt; "civicrm_contact",
    'tag_id' =&gt; "Volunteer",
  ));
  </code></pre>
  
  <p>or</p>
  
  <pre><code>$result = civicrm_api3('EntityTag', 'get', array(
    'entity_table' =&gt; "civicrm_contact",
    'tag_id' =&gt; "Major Donor",
  ));
  </code></pre>
  
  <p>but I want to find only contacts who have both tags, I have to resort to making two API calls and comparing the results.</p>
  
  <p>This seems to be the case across various CiviCRM APIs. For example, it doesn't seem to be possible to make an API call to retrieve groups that are of type ACL <em>and</em> Mailing List. Am I missing something? Have folks developed a recipe for this kind of query?</p>
  
Tags: <api>
Title: Can the API be used to find contacts with multiple tags?
ThreadText: # Can the API be used to find contacts with multiple tags?
  
  (Asked by: username_0 on 2017-05-05)
  
  If I tag a contact as a Major Donor and a Volunteer, I can retrieve their contact ID via the API using an API call such as:
  
  ```
  $result = civicrm_api3('EntityTag', 'get', array(
    'entity_table' => "civicrm_contact",
    'tag_id' => "Volunteer",
  ));
  
  ```
  
  or
  
  ```
  $result = civicrm_api3('EntityTag', 'get', array(
    'entity_table' => "civicrm_contact",
    'tag_id' => "Major Donor",
  ));
  
  ```
  
  but I want to find only contacts who have both tags, I have to resort to making two API calls and comparing the results.
  
  This seems to be the case across various CiviCRM APIs. For example, it doesn't seem to be possible to make an API call to retrieve groups that are of type ACL *and* Mailing List. Am I missing something? Have folks developed a recipe for this kind of query?
  
  **Tags:** api
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-01-04. Score: 1
  
  You can achieve this by giving the key 'tag\_id' an array containing multiple tags. Something like this:
  
  `'tag_id' => array('volunteer', 'Major Donor'),`
  
  > **Comments:**
  > **username_0**: This returns an empty result. Tested against 4.7.25 and the as-yet-unreleased 4.7.31.  
  
  ---
  
  