# Get Instagram user

> Read someone who messaged the account, and whether they follow it.

Canonical: <https://www.tryadeli.com/docs/api/messages/get-instagram-user>

`GET https://app.tryadeli.com/api/v1/messages/instagram/users/{igsid}`

Authorization: `Bearer <API key>` — see [Authentication](https://www.tryadeli.com/docs/authentication)

Read someone who has messaged an Instagram account: their username and name,
and whether they follow the account. Use it to gate a comment-to-DM flow on a
follow: when the person taps your button, check `isFollowing` before sending
the link, and ask them to follow first if it is `false`.

The answer comes live from Instagram on every call, so a follow made a moment
ago shows up straight away.

**Path parameters**

| Name    | Type     | Required | Description                                                                                                                                                                   |
| ------- | -------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `igsid` | `string` | Yes      | The person's Instagram-scoped id: `from.id` on a [`message.created`](https://www.tryadeli.com/docs/api/webhooks#direct-messages) event or `senderId` on a `message.postback`. |

**Query parameters**

| Name        | Type   | Required | Description                                                                       |
| ----------- | ------ | -------- | --------------------------------------------------------------------------------- |
| `accountId` | `uuid` | Yes      | The connected Instagram account they messaged.                                    |
| `profileId` | `uuid` |          | Optional, because accountId names its profile. If you pass both, they must agree. |

`isFollowing` is whether the person follows the account, and
`isFollowedByAccount` whether the account follows them. Either is null when
Instagram does not say.

> **Note: Only after they message you**
>
> Instagram shares a person's profile only once they have sent the account a
> message or tapped one of its buttons. Before that, the response is
> `409 user_consent_required`. Someone who taps a button on your private reply
> has already done so.

**Errors** — `401 unauthorized`, `400 invalid_request`, `404 profile_not_found`,
`404 account_not_found`, `404 user_not_found`, `409 user_consent_required`,
`403 permission_required` with missing permission and reconnect details,
`422 connection_expired`, `502 provider_error`.

## Request examples

**cURL**

```bash
curl "https://app.tryadeli.com/api/v1/messages/instagram/users/17841400000000001?accountId=00000000-0000-0000-0000-000000000000" \
  -H "Authorization: Bearer $ADELI_API_KEY"
```

**JavaScript**

```javascript
const response = await fetch("https://app.tryadeli.com/api/v1/messages/instagram/users/17841400000000001?accountId=00000000-0000-0000-0000-000000000000", {
  headers: {
    Authorization: `Bearer ${process.env.ADELI_API_KEY}`,
  },
});
console.log(await response.json());
```

**Python**

```python
import os

import requests

response = requests.get(
    "https://app.tryadeli.com/api/v1/messages/instagram/users/17841400000000001",
    headers={"Authorization": f"Bearer {os.environ['ADELI_API_KEY']}"},
    params={
        "accountId": "00000000-0000-0000-0000-000000000000",
    },
)
print(response.json())
```

## Responses

### 200

```json
{
  "platform": "instagram",
  "accountId": "00000000-0000-0000-0000-000000000000",
  "profileId": "00000000-0000-4000-8000-000000000001",
  "user": {
    "id": "17841400000000001",
    "username": "maya.makes",
    "name": "Maya",
    "followerCount": 812,
    "isFollowing": true,
    "isFollowedByAccount": false
  }
}
```

### 409

```json
{
  "error": {
    "code": "user_consent_required",
    "message": "Instagram shares this person's profile only after they have sent the account a message or tapped one of its buttons"
  }
}
```
