# Short Links

Redirect links are one of the core primitives on Spindl. They map a Spindl link (`https://spindl.link/abcd`) to a specified URL (typically a dApp website).

## Get all links for your organization

<mark style="color:blue;">`GET`</mark> `https://api.spindl.xyz/v1/links`

Links will sorted by the time they were created, descending.

#### Headers

| Name                                        | Type   | Description   |
| ------------------------------------------- | ------ | ------------- |
| X-API-Key<mark style="color:red;">\*</mark> | String | The API token |

{% tabs %}
{% tab title="200: OK OK" %}

```json
{
  "links": [
    {
      "id": "dfec5988-5108-465c-be87-ce42039f572e",
      "name": "Spindl Campaign - 2022 - Discord",
      "link": "https://spindl.link/bcdef",
      "redirectUrl": "https://demo.spindl.xyz/",
      "createdAt": "2022-11-09T22:56:24.303Z",
      "totalVisits": 0,
      "latestVisit": null
    },
    {
      "id": "7c087843-a7a1-4b2c-9f28-2ccbe40f23e5",
      "name": "Spindl Campaign - 2022 - Twitter",
      "link": "https://spindl.link/abcd",
      "redirectUrl": "https://demo.spindl.xyz/",
      "createdAt": "2022-11-04T00:29:49.810Z",
      "totalVisits": 100,
      "latestVisit": "2022-11-06T17:32:12.632Z"
    }
  ]
}
```

{% endtab %}
{% endtabs %}

## Create a link

<mark style="color:green;">`POST`</mark> `https://api.spindl.xyz/v1/links`

Create a new short link with Spindl tracking.

#### Headers

| Name      | Type   | Description   |
| --------- | ------ | ------------- |
| X-API-Key | String | The API token |

#### Request Body

| Name                                   | Type   | Description                                                                                                                            |
| -------------------------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------- |
| name<mark style="color:red;">\*</mark> | String | The internal name of the link. While names aren't unique, we recommend using descriptive names like "Winter Campaign - Twitter Post 1" |
| url<mark style="color:red;">\*</mark>  | String | The URL to redirect to (typically where your app lives).                                                                               |

{% tabs %}
{% tab title="200: OK OK" %}

```javascript
{
  "link": {
    "id": "dfec5988-5108-465c-be87-ce42039f572e",
    "name": "Test New 2",
    "link": "https://spindl.link/abcde",
    "redirectUrl": "https://demo.spindl.xyz/",
    "createdAt": "2022-11-09T22:56:24.303Z",
    "totalVisits": 0,
    "latestVisit": null
  }
}
```

{% endtab %}
{% endtabs %}

##
