URL Shortener

The URL Shortener API allows you to programmatically create short URLs for longer URL (a 'destination').

Each short URL you create can be used to redirect the end user (person clicking on the link) to one or more destination URLs.

In order to use the Shortener API you can choose to bind your own branded domain, sub-domain or to use our default domain β†’ msgi.me

πŸ“˜

NOTE

If you want to use your own branded domain (Custom Domain), contact our support team and we will be pleased to provide you technical assistance soon.

You are only able to create a custom domain per owner.

Therefore, a URL shortener is a service that takes a long, complicated URL and turns it into a shorter, easier-to-remember one. For example, if you wanted to share the URL for a long news article, you could use a URL shortener to create a much shorter link that would be much easier for people to type or click on. In addition to making links more manageable, URL shorteners can also be used to track how many people click on a particular link. This information can be valuable for understanding which links are most popular and how people are finding your website.

Our Shortener URL API offers the following features:

  • (Easy) Short URL is easy and fast, enter the long link to get your shortened link.
  • (Shortened) Use any link, no matter what size, Short URL always shortens.
  • (Secure) It is fast and secure, our service has HTTPS protocol and data encryption.
  • (Devices) Compatible with smartphones, tablets and desktop.

Creating Short URL

This POST method creates a new short URL under a specified domain. If no domain is specified in the request the short URL will be attached to the default domain msgi.me

When you create a short URL, the request body contains the following data:

HTTP Request: POST / links

{
  "longUrl": "www.your_URL.com"
}

The parameters presented in the request body example when creating the short URL are the following:

Parameter Required Description
longUrl Yes

URL destination name.

Enter the URL link to which the short URL will redirect.

domain No

Domain which short URL will belong to (string without http/https or /).

Enter the custom domain in case you have requested it from the support team.

By default is "msgi.me"

data No

This array can be used by the customer to enter and store additional information about the short URL.

This additional information must be set in JSON format at key/value level.

For example:

"data": { "name": "Elizabeth Smith", "email": "[email protected]" }

callbacks No

Webhook URL to notify about the events of the short URL.

The URL is the external callback where the events of the short URL will be registered and published. The following short URL status sent to your callback URL will be the status to be recorded in the callback once end user has clicked on the short URL:

  • "open": End user clicked on the short URL link.

externalId No

Alphanumeric identifier used for reporting purposes.

When you created the short URL, the response body contains the following data:

{
  "meta": {
    "timestamp": 1688140030182,
    "transactionId": "aff87e14-d362-41c7-9db8-cb4dfc9b"
  },
  "data": {
    "id": "T75bmJ",
    "longUrl": "www.your_URL.com",
    "data": {},
    "shortLink": "msgi.me/T75bmJ",
    "date": "2023-06-30T15:47:10.281138536Z"
  }
}

Parameters presented in the response body example when creating the short URL are the following:

Parameter Description
data Data contained in the Short URL.
data.id Unique identifier of the short URL.
data.longUrl

URL destination name.

URL link to which the short URL will redirect.

data.domain

Optional. Domain which short URL will belong to (string without http/https or /).

By default is "msgi.me"

data.data

Optional. This array can be used by the customer to enter and store additional information about the short URL.

This additional information must be set in JSON format at key/value level.

For example:

"data": { "name": "Elizabeth Smith", "email": "[email protected]" }

data.callbacks

Optional. Webhook URL to notify about the events of the short URL.

The URL is the external callback where the events of the short URL will be registered and published. The following short URL status sent to your callback URL will be the status to be recorded in the callback once end user has clicked on the short URL:

  • "open": End user clicked on the short URL link.

data.externalId

Optional. Alphanumeric identifier used for reporting purposes.

data.shortLink

Short URL link.

Copy and paste this short URL into your browser to test it.

data.date

Date when the short URL was created.

The date is represented with date in UTC Zulu format: (yyyy-mm-dd-Thh:mm:ss.ssZ).

Creating Batch Short URLs

With this endpoint, you can create multiple short URLs in one POST call.

There are two types of creating multiple short links:

  • By single long URL
  • By multiple long URLs

Single Long URL

In this request, you are able to create multiple unique URLs in one call. That is, each short URL you create will redirect to the same long URL.

In your request body, include the following parameters to create multiple short URLs:

HTTP Request: POST /links/batch

Before creating multiple unique URLs, you need to provide the total number of short URLs you want to create.

Required ParameterDescription
sizeTotal number of short URLs to generate.
{
  "listUrl": [
    {
      "longUrl": "www.your_URL.com"
    }
  ]
}

The parameters presented in the request body example when creating the short URLs are the following:

Parameter Required Description
listUrl Yes

URL destination name.

Enter the URL link to which the short URL will redirect.

listUrl.longUrl Yes

URL destination name.

Enter the URL link to which the short URL will redirect.

listUrl.domain No

Domain which short URL will belong to (string without http/https or /).

Enter the custom domain in case you have requested it from the support team.

By default is "msgi.me"

listUrl.data No

This array can be used by the customer to enter and store additional information about the short URL.

This additional information must be set in JSON format at key/value level.

For example:

"data": { "name": "Elizabeth Smith", "email": "[email protected]" }

listUrl.callbacks No

Webhook URL to notify about the events of the short URL.

The URL is the external callback where the events of the short URL will be registered and published. The following short URL status sent to your callback URL will be the status to be recorded in the callback once end user has clicked on the short URL:

  • "open": End user clicked on the short URL link.

listUrl.externalId No

Alphanumeric identifier used for reporting purposes.

If you set 3 (size) as the total number of short URLs you want to create, the response body contains the following data:

{
  "meta": {
    "timestamp": 1688403131016,
    "transactionId": "b58521b4-e711-483d-aa39-3de01f355eca"
  },
  "items": [
    {
      "id": "P2siWu",
      "longUrl": "www.your_URL.com",
      "data": {},
      "shortLink": "msgi.me/P2siWu",
      "date": "2023-07-03T16:52:11.096051603Z"
    },
    {
      "id": "08KDbx",
      "longUrl": "www.your_URL.com",
      "data": {},
      "shortLink": "msgi.me/08KDbx",
      "date": "2023-07-03T16:52:11.134291422Z"
    },
    {
      "id": "40rN6n",
      "longUrl": "www.your_URL.com",
      "data": {},
      "shortLink": "msgi.me/40rN6n",
      "date": "2023-07-03T16:52:11.168937835Z"
    }
  ]
}

Parameters presented in the response body example when creating the short URLs are the following:

Parameter Description
items List (array) of short URLs created.
items.id Unique identifier of the short URL.
items.longUrl

URL destination name.

URL link to which the short URL will redirect.

items.domain

Optional. Domain which short URL will belong to (string without http/https or /).

By default is "msgi.me"

items.data

Optional. This array can be used by the customer to enter and store additional information about the short URL.

This additional information must be set in JSON format at key/value level.

For example:

"data": { "name": "Elizabeth Smith", "email": "[email protected]" }

items.callbacks

Optional. Webhook URL to notify about the events of the short URL.

The URL is the external callback where the events of the short URL will be registered and published. The following short URL status sent to your callback URL will be the status to be recorded in the callback once end user has clicked on the short URL:

  • "open": End user clicked on the short URL link.

items.externalId

Optional. Alphanumeric identifier used for reporting purposes.

items.shortLink

Short URL link.

Copy and paste this short URL into your browser to test it.

items.date

Date when the short URL was created.

The date is represented with date in UTC Zulu format: (yyyy-mm-dd-Thh:mm:ss.ssZ).

Multiple Long URLs

In this request, you are able to create multiple different long URLs in one call. That is, each short URL you create will redirect to a different long URL, not just one.

In your request body, include the following parameters to create multiple short URLs:

HTTP Request: POST /links/batch

{
  "listUrl": [
    {
      "longUrl": "www.your_URL.com"
    },
    {
      "longUrl": "www.your_URL_2.com"
    }
  ]
}

The parameters presented in the request body example when creating the short URLs are the following:

Parameter Required Description
listUrl Yes

URL destination name.

Enter the URL link to which the short URL will redirect.

listUrl.longUrl Yes

URL destination name.

Enter the URL link to which the short URL will redirect.

listUrl.domain No

Domain which short URL will belong to (string without http/https or /).

Enter the custom domain in case you have requested it from the support team.

By default is "msgi.me"

listUrl.data No

This array can be used by the customer to enter and store additional information about the short URL.

This additional information must be set in JSON format at key/value level.

For example:

"data": { "name": "Elizabeth Smith", "email": "[email protected]" }

listUrl.callbacks No

Webhook URL to notify about the events of the short URL.

The URL is the external callback where the events of the short URL will be registered and published. The following short URL status sent to your callback URL will be the status to be recorded in the callback once end user has clicked on the short URL:

  • "open": End user clicked on the short URL link.

listUrl.externalId No

Alphanumeric identifier used for reporting purposes.

When you created the short URLs, the response body contains the following data:

{
  "meta": {
    "timestamp": 1688152455360,
    "transactionId": "41a59219-b213-49e7-9b5c-336c02a5a929"
  },
  "items": [
    {
      "id": "8kukt7",
      "longUrl": "www.your_URL.com",
      "data": {},
      "shortLink": "msgi.me/8kukt7",
      "date": "2023-06-30T19:14:15.445127033Z"
    },
    {
      "id": "CM9X2S",
      "longUrl": "www.your_URL_2.com",
      "data": {},
      "shortLink": "msgi.me/CM9X2S",
      "date": "2023-06-30T19:14:15.483220634Z"
    }
  ]
}

Parameters presented in the response body example when creating the short URLs are the following:

Parameter Description
items List (array) of short URLs created.
items.id Unique identifier of the short URL.
items.longUrl

URL destination name.

URL link to which the short URL will redirect.

items.domain

Optional. Domain which short URL will belong to (string without http/https or /).

By default is "msgi.me"

items.data

Optional. This array can be used by the customer to enter and store additional information about the short URL.

This additional information must be set in JSON format at key/value level.

For example:

"data": { "name": "Elizabeth Smith", "email": "[email protected]" }

items.callbacks

Optional. Webhook URL to notify about the events of the short URL.

The URL is the external callback where the events of the short URL will be registered and published. The following short URL status sent to your callback URL will be the status to be recorded in the callback once end user has clicked on the short URL:

  • "open": End user clicked on the short URL link.

items.externalId

Optional. Alphanumeric identifier used for reporting purposes.

items.shortLink

Short URL link.

Copy and paste this short URL into your browser to test it.

items.date

Date when the short URL was created.

The date is represented with date in UTC Zulu format: (yyyy-mm-dd-Thh:mm:ss.ssZ).