title: Facebook Ads API error: must be a valid custom audience id
body: <p>Unlike targeting a <code>custom audience</code>, it seems impossible to create an ad targeting a <code>saved audience</code> using <a href="https://developers.facebook.com/docs/marketing-api/targeting-specs/v2.9" rel="noreferrer">Facebook Ads API</a>. Can someone confirm that is the case? What would be a workaround? This is the error I'm getting:</p>
  
  <pre><code>Error #100: Param targeting[custom_audiences][id] must be a valid custom audience id
  </code></pre>
  
  <p>There is a difference between a <code>saved audience</code> and a <code>custom audience</code>. A <code>saved audience</code> is an audience you manually create specifying age range, geographic region and interests. While a <code>custom audience</code> is a list of customers you gathered (uploaded or visitors or your site etc). You can create these audiences manually through the Ads Manager interface: </p>
  
  <p><a href="https://i.stack.imgur.com/Uy4mT.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Uy4mT.png" alt="enter image description here"></a></p>
  
  <p>Using <a href="https://developers.facebook.com/tools/explorer/" rel="noreferrer">Graph API Explorer</a>, one can retrieve <code>saved audiences</code> as follow:</p>
  
  <pre><code>act_1234567890/saved_audiences
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/0OgYb.png" rel="noreferrer"><img src="https://i.stack.imgur.com/0OgYb.png" alt="enter image description here"></a></p>
  
  <p>Using <a href="https://developers.facebook.com/tools/explorer/" rel="noreferrer">Graph API Explorer</a>, one can retrieve <code>custom audiences</code> as follow:</p>
  
  <pre><code>act_123456789/customaudiences
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/2KxiS.png" rel="noreferrer"><img src="https://i.stack.imgur.com/2KxiS.png" alt="enter image description here"></a></p>
  
  <p><em>Note that <code>123456789</code> is not my real account number. I changed it for security reasons.</em> </p>
  
  <p>So, I can retrieve IDs for both <code>custom audiences</code> and <code>saved audiences</code> and creating an ad targeting a <code>custom audience</code> works fine, unlike targeting a <code>saved audience</code> which gives the above error message.</p>
  
  <p>A cumbersome workaround could be to save the <a href="https://developers.facebook.com/docs/marketing-api/targeting-specs/v2.9#flexible" rel="noreferrer"><code>flexible_spec</code></a> of each <code>saved audience</code> locally and use that spec when creating ads. The problem with that is that some <code>targeting segments</code> become invalid (Facebook decides to discontinue some segments at random times) which causes Facebook Ads API to hickup. Additionally, this means I constantly need to keep <code>saved audiences</code> in sync with my local copy. Unless of course I retrieve the <code>targeting</code> of a <code>saved audience</code> on the fly and re-use it, each time I create an ad resulting in yet another API request.</p>