# Link Tracking API

## POST - Create Shortlink&#x20;

This  API is used for creating shortlinks for a destination URL, often used for affiliate marketing .

{% embed url="<https://dashboard.ylytic.com/ylytic/admin/api/v1/shortlinks>" %}

```
curl --location 'https://dashboard.ylytic.com/ylytic/admin/api/v1/shortlinks' \
--header 'Authorization: Bearer {{auth_token}} \
--data '{"target_url":"https://www.ylytic.com/"}'

```

<table><thead><tr><th width="235">ATTRIBUTES</th><th>DESCRIPTION</th></tr></thead><tbody><tr><td><strong>target_url</strong></td><td>URL of which the shortlink has to be created. </td></tr></tbody></table>

### PAYLOAD

```json
{"target_url":"https://www.ylytic.com/"}
```

### OUTPUT (JSON)

```json
{
    "short_link": "https://app.ylytic.com/sl/1705923271.798946"
}
```

## GET - Shortlink Insights Tracking

Get the insights of the created shortlink.

{% embed url="<https://insights.ylytic.com/ylytic/admin/api/v1/shortlinks/1703838910.587752/insights>" %}

```
curl --location 'https://insights.ylytic.com/ylytic/admin/api/v1/shortlinks/1703838910.587752/insights' \
--header 'Authorization: Bearer {{auth_token}}'
```

### OUTPUT(JSON)

{% code overflow="wrap" fullWidth="true" %}

```json
{
    "id": "1703838910.587752",
    "client": {
        "id": "643d294c4c77fb75c38bc751",
        "short_name": "anuraggupta",
        "name": "-"
    },
    "short_link": "https://app.ylytic.com/sl/1703838910.587752",
    "name": "ylytic",
    "target_url": "https://instagram.com",
    "analytics": {
        "users": 1,
        "clicks": 1,
        "city_distribution": [
            {
                "city": "Ahmedabad",
                "users": 1,
                "clicks": 1
            }
        ],
        "country_distribution": [
            {
                "country": "India",
                "users": 1,
                "clicks": 1
            }
        ],
        "platform_distribution": [
            {
                "platform": "browser",
                "users": 1,
                "clicks": 1
            }
        ],
        "device_distribution": [
            {
                "device": null,
                "users": 1,
                "clicks": 1
            }
        ],
        "date_distribution": [
            {
                "date": "2023-12-29",
                "users": 1,
                "clicks": 1
            }
        ]
    },
    "analyticsAt": "2024-01-22 11:29:09.420000",
    "createdDate": "29-12-2023"
}
```

{% endcode %}
