# Links

When a person replies to a bot with a photo, video, audio or file and the reply is saved to a variable (the "Write the answer to the user variable" switch in the block's [Advanced](https://support.watbot.org/chatbots/blocks/messages#advanced) section), the variable gets a short link to the file rather than the file itself — something like `…/w/bK3x9`. The same kind of short link leads to the file of a bot's list [export to Excel](https://support.watbot.org/lists/import-export#export-to-excel).

The `decodeShortLink` method turns such a link into a direct link to the file, so your system can download it without following a redirect.

## decodeShortLink

Returns a direct link to a file for a short link.

```endpoint
GET POST https://watbot.org/api/v1/decodeShortLink
```

| Parameter | Type | Required | Description |
|---|---|---|---|
| `url` | string | yes | The full short link, including `https://` and the `?k=…` parameter if it has one. The method takes the code after `/w/`; the domain is not checked |

```bash title="Request"
curl -X POST "https://watbot.org/api/v1/decodeShortLink" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/w/bK3x9"}'
```

```json title="Response 200"
{
  "data": {
    "url": "https://files.example.com/bots/12345/passport-scan.jpg"
  }
}
```

```json title="Response 404"
{
  "error": "Short link not found",
  "message": "Short link not found"
}
```

Only links to files are resolved, and only those that belong to your bot or your list — including a list created in a project rather than in a bot. Short links of other kinds are not resolved. An expired link is not resolved, just as it does not open when followed.

Method errors (general ones are under [Errors](https://support.watbot.org/api#errors)):

| Code | When | Response |
|---|---|---|
| `403` | The link belongs to a bot or list of another account, or is tied to neither a bot nor a list | `{"error": "…", "message": "…"}` |
| `404` | There is no short link with this code, it has expired, the `?k=` key does not match, or the list it leads to was deleted | `{"error": "…", "message": "…"}` |
| `422` | The link does not lead to a file | `{"error": "…", "message": "…"}` |
| `422` | `url` is missing, is not a URL, or has no `/w/code` path | `{"message": "…", "errors": {"url": ["…"]}}` |
