> ## Documentation Index
> Fetch the complete documentation index at: https://www.ayrshare.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Search Instagram audio

> Search Instagram's licensed audio catalog for a track to attach to a Reel

export const InstagramAudioNotice = () => <Warning>
  <strong>Requires Instagram linked through Facebook Login.</strong> Instagram's Audio API is only available to accounts connected via <strong>Facebook Login</strong>, which needs a Facebook Page connected to the Instagram account. Accounts connected with <strong>Instagram Login</strong> (the Ayrshare default) cannot search, look up, or attach audio, and every audio request returns <code>code: 514</code>.
  <br /><br />
  This is a Meta restriction, not an Ayrshare one. Meta's documentation states the Audio API "is only available on the Instagram API with Facebook Login. It is not supported on the Instagram API with Instagram Login." No permission or plan upgrade changes it.
  <br /><br />
  <strong>Three things are required:</strong>
  <br />
  1. An Instagram <strong>Business</strong> or <strong>Creator</strong> account<br />
  2. A <strong>Facebook Page connected</strong> to that Instagram account<br />
  3. Instagram linked to Ayrshare with <strong>Instagram Login disabled</strong>, so the Facebook Login flow is used
  <br /><br />
  See the <a href="/docs/dashboard/connect-social-accounts/instagram#music-attach-eligibility-facebook-login-required">step-by-step setup guide</a>.
</Warning>;

export const PlansAvailable = ({plans = [], maxPackRequired}) => {
  let displayPlans = plans;
  if (plans && plans.length === 1) {
    const lowerCasePlan = plans[0].toLowerCase();
    if (lowerCasePlan === "business") {
      displayPlans = ["Launch", "Business", "Enterprise"];
    } else if (lowerCasePlan === "premium") {
      displayPlans = ["Premium", "Launch", "Business", "Enterprise"];
    }
  }
  return <Note>
Available on {displayPlans.length === 1 ? "the " : ""}
{displayPlans.join(", ").replace(/\b\w/g, l => l.toUpperCase())}{" "}
{displayPlans.length > 1 ? "plans" : "plan"}.

{maxPackRequired && <span onClick={() => window.open('https://www.ayrshare.com/docs/additional/maxpack', '_self')} className="flex items-center mt-2 cursor-pointer">
 <span className="px-1.5 py-0.5 rounded text-sm" style={{
    backgroundColor: '#C264B6',
    color: 'white',
    fontSize: '12px'
  }}>
   Max Pack required
 </span>
</span>}
</Note>;
};

export const HeaderAPI = ({noProfileKey, profileKeyRequired}) => <>
    <ParamField header="Authorization" type="string" required>
      <a href="/docs/apis/overview#authorization">API Key</a> of the Primary Profile.
      <br />
      <br />
      Format: <code>Authorization: Bearer API_KEY</code>
    </ParamField>
    {!noProfileKey && (profileKeyRequired ? <ParamField header="Profile-Key" type="string" required>
          <a href="/docs/apis/overview#profile-key-format">Profile Key</a> of a User Profile.
          <br />
          <br />
          Format: <code>Profile-Key: PROFILE_KEY</code>
        </ParamField> : <ParamField header="Profile-Key" type="string">
          <a href="/docs/apis/overview#profile-key-format">Profile Key</a> of a User Profile.
          <br />
          <br />
          Format: <code>Profile-Key: PROFILE_KEY</code>
        </ParamField>)}
  </>;

<PlansAvailable plans={["premium"]} maxPackRequired={false} />

Search Instagram's audio catalog by keyword. Use the returned `audioId` with [`instagramOptions.audioConfiguration`](/docs/apis/post/social-networks/instagram#adding-music-to-a-reel) to attach the track when you publish a Reel.

<InstagramAudioNotice />

## Header Parameters

<HeaderAPI />

## Query Parameters

<ParamField query="query" type="string" required>
  Keyword to search for, such as an artist or track name. An empty or whitespace-only value returns
  `code: 101`.
</ParamField>

<ParamField query="audioType" type="string" default="music">
  Which catalog to search. Either `music` for licensed commercial tracks or `original_sound` for
  audio taken from other creators' Reels. Any other value returns `code: 101`.
</ParamField>

<ParamField query="limit" type="integer">
  Maximum number of tracks to return, from `1` to `100`. Non-integer or out-of-range values return
  `code: 101`. When omitted, Instagram's own default applies.
</ParamField>

## Response Fields

Instagram does not return every field for every track, so treat all track fields except `audioId` as optional.

<ResponseField name="status" type="string">
  `success` when the search completed. An empty catalog match is still a success.
</ResponseField>

<ResponseField name="query" type="string">
  The keyword that was searched, echoed back.
</ResponseField>

<ResponseField name="audio" type="array">
  Matching tracks. An empty array means the search ran and matched nothing.

  <Expandable title="Track fields">
    <ResponseField name="audioId" type="string">
      The id to pass as `audioConfiguration.audioId` when publishing a Reel.
    </ResponseField>

    <ResponseField name="title" type="string">Track title.</ResponseField>
    <ResponseField name="displayArtist" type="string">Artist name as Instagram displays it.</ResponseField>
    <ResponseField name="durationMs" type="integer">Track length in milliseconds.</ResponseField>
    <ResponseField name="thumbnailUrl" type="string">Cover artwork thumbnail URL.</ResponseField>
    <ResponseField name="audioType" type="string">Either `music` or `original_sound`.</ResponseField>

    <ResponseField name="isAdsEligible" type="boolean">
      Whether the track may be used in an ad. Licensed music is frequently unavailable for ads even
      when it is available for an organic Reel.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseExample>
  ```json 200: Success theme={"system"}
  {
    "status": "success",
    "query": "summer",
    "audio": [
      {
        "audioId": "17901234567890123",
        "title": "Summer Nights",
        "displayArtist": "The Example Band",
        "durationMs": 32000,
        "thumbnailUrl": "https://scontent.example.com/cover.jpg",
        "audioType": "music",
        "isAdsEligible": true
      }
    ]
  }
  ```

  ```json 200: No matches theme={"system"}
  {
    "status": "success",
    "query": "asdfghjkl",
    "audio": []
  }
  ```

  ```json 400: Instagram Login account theme={"system"}
  {
    "status": "error",
    "code": 514,
    "action": "post",
    "message": "Adding music to a Reel requires an Instagram account connected via Facebook Login. This profile is connected with Instagram Login, which Meta does not permit for music attach, search, or lookup. Please relink Instagram using Facebook Login and grant the instagram_content_publish permission, then try again.",
    "platform": "instagram"
  }
  ```
</ResponseExample>

## Errors

| Code | Meaning                                                                                                                                                                 |
| ---- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 101  | Missing or empty `query`, an unrecognized `audioType`, or a `limit` outside 1 to 100.                                                                                   |
| 156  | Instagram is not linked to this profile.                                                                                                                                |
| 161  | Instagram's authorization expired or was revoked. Relink the account.                                                                                                   |
| 239  | Instagram rejected the request for an account-level reason, including an unavailable track. On search this reports 239 rather than the 517 the lookup endpoint returns. |
| 258  | Instagram returned a malformed response or an unmapped failure.                                                                                                         |
| 425  | The connection is missing a required Instagram permission. Relink and grant all permissions.                                                                            |
| 435  | Instagram's rate limit was reached. Wait before retrying.                                                                                                               |
| 514  | Instagram is linked with Instagram Login. The Audio API requires Facebook Login.                                                                                        |

Codes 514 to 518 are described in [Instagram Reels audio errors](/docs/errors/errors-ayrshare#instagram-reels-audio-errors); the rest are in the [Ayrshare error reference](/docs/errors/errors-ayrshare).

## Next Steps

<Card title="Attach the track to a Reel" icon="music" href="/docs/apis/post/social-networks/instagram#adding-music-to-a-reel" horizontal />

<Card title="Look up a single track" icon="magnifying-glass" href="/docs/apis/media/get-instagram-audio" horizontal />
