Points an existing short link at a different target URL. The short link itself stays the same, so it keeps working in messages that have already been sent.

## API URL

The URL used to send the HTTP requests:

```url
https://portal.bulkgate.com/api/1.0/shortener/change
```

> [!NOTE]
> If the request does not reach its destination, repeat it on the [backup server](https://www.bulkgate.com/en/docs/api-administration-tokens/api-backup-server/) `backup1.bulkgate.com`.

## Supported HTTP methods

- `POST` - `application/json`

```http
POST /api/1.0/shortener/change HTTP/1.1
Host: portal.bulkgate.com
Content-Type: application/json
```

> [!NOTE]
> The API has a quota of `20` requests per minute.

## Parameters table

| PARAMETER NAME    | VALUE                                                   | MANDATORY | DEFAULT VALUE |
|:------------------|:---------------------------------------------------------|:----------|:--------------|
| application_id    | [Application ID](https://www.bulkgate.com/en/docs/api-administration-tokens/api-administration/)           | **Yes**   | -             | 
| application_token | [Application authentication token](https://www.bulkgate.com/en/docs/api-administration-tokens/api-tokens/)	 | **Yes**   | -             |
| short_url         | Abbreviated url to be changed	                          | **Yes**   | -             |
| target_url        | New URL                                                 | **Yes**   | -             |

## Request example

```http-json
POST /api/1.0/shortener/change HTTP/1.1
Host: portal.bulkgate.com
Content-Type: application/json

{
  "application_id": 451,
  "application_token": "NKN02TWE6NfBkfl-your-secret-token-Wf05GaqLIWLW4aBj",
  "short_url": "ur7.wf/K",
  "target_url": "www.insymbo.com"
}
```

## Response

**In case of success:**

```json
{
    "data": {
        "short_url": "http://ur7.wf/K",
        "target_url": "http://www.insymbo.com/",
        "final_url": "www.insymbo.com",
        "title": "Online assessment tool for employee selection - INSYMBO"
    }
}
```

The response fields work the same as in [shorten](https://www.bulkgate.com/en/docs/shortener/shortener-shorten/), with one difference: `final_url` here carries the address **exactly as you sent it**, without the scheme being added.

**In case of error:**

```json
{
    "type": "url_not_found",
    "code": 400,
    "error": "Url not found",
    "detail": null
}
```

```json
{
    "type": "the_per_minute_quota_has_been_exceeded",
    "code": 400,
    "error": "The per minute quota has been exceeded",
    "detail": null
}
```

Where:

- **type** and **error** (description of the error) can be found in the [error types table](https://www.bulkgate.com/en/docs/api-administration-tokens/api-error-types/)
- **code** is the HTTP error code
- **detail** is additional information about the error

### Shortener API error types

Besides the [general types](https://www.bulkgate.com/en/docs/api-administration-tokens/api-error-types/), the Shortener API returns its own:

| TYPE                                    | WHEN IT HAPPENS                                                        |
|:----------------------------------------|:-----------------------------------------------------------------------|
| `url_not_found`                         | `short_url` does not exist in the account.                             |
| `url_is_not_valid`                      | The new `target_url` could not be parsed.                              |
| `domain_is_not_white_listed`            | The new target domain is not whitelisted (for restricted domains).     |
| `the_per_minute_quota_has_been_exceeded`| The quota of 20 requests per minute is used up.                        |
