URL Shortener API
This API allows you to shorten your URLs in order to minimize the number of SMS characters.
Registration
To access this service, send an email to support@mtarget.fr with the following subject "URL Shortener API access demand" and specifying these contact details :
- account email
- name
- first name
- society name
- DUNS
- mobile phone number
In return, we will provide your identifiers in order to allows you to access our online tools and visualize your statistics. If you need to use our API, we will also provide you an access key which allows you to use it and a short domain name for your shortened URLs.
Shorten an URL
This API allows you to generate shorts URL from longer ones.
When you send requests, you have to place the access key that we provide to you into your requests headers.
To shorten an URL, you will need to specify 3 fields :
- Campaign name related to the URLs that you wish to shorten
- The short domain name configurated by us for your needs
- The long URL that you wish to shorten
Content-Typeapplication/json
Content type sended in the request
access-keyOFAFhdezhj645oiha78fFU78Z65FAccess key fiven to you during your registration
BODY{
"campaign": { "name": "MyCampaignName", "createIfNotExist": false, "endDate": "2023-02-28" },
This JSON is explained in the next part.
"short_domain": "shtl.eu",
"url": [ { "long_url": "https:\/\/urllong.com\/" }, { "long_url": "https:\/\/urllong.com\/" } ],
}
Shorten an URL
Important information :
- Fields in bold are mandatory.
- Fields in italic are optional.
- If createIfNotExist is false or not specified, the campaign will not be created if it doesn't exist
-
Once the end date of the campaign has passed (endDate), all generated short links for the campaign will be deactivated. If used by a user, he will be redirected on a 404 page.
You will still be able to see the number of total hits for the campaign, but the list of all short urls will be disabled.
Request example :
{ "campaign": { "name": "MonNomDeCampagne", "createIfNotExist" : false, "endDate": "2024-01-01" }, "short_domain":"shtl.eu", "url": [ {"long_url":"https://urllong.com/"}, {"long_url":"https://urllong.com/"} ] }
- campaign: All information of the campaign.
- name: Name of the campaign.
- createIfNotExist: If true and if the campaign doesn't exist, create it. Default value : false.
- endDate: End date of the campaign. Default value : 6 months after the creation date. Detailed statistics are kept for 6 months after the end date of the campaign.
- short_domain: The short configured domain used to shorten your urls.
- url: Array of all urls to shorten. Maximum of 500 urls.
Response :
{ "status": 0, "campaign": { "name": "Test campaign", "createIfNotExist": false, "endDate": "2023-02-28" }, "short_domain": "shtl.eu", "url": { "success": [ { "long_url": "https://urllong.com/", "short_url": "http://shtl.eu/80zSPi" }, { "long_url": "https://urllong.com/", "short_url": "http://shtl.eu/16F2W5" } ], "error": [] } }
- status: State of response
- 0: Success
- 1: Partial success
- 2: Error
- campaign: All information of the campaign.
- name: Name of the campaign.
- createIfNotExist: If true and if the campaign doesn't exist, create it. Default value : false.
- endDate: End date of the campaign. Default value : 6 months after the creation date. Detailed statistics are kept for 6 months after the end date of the campaign.
- short_domain: The short configured domain used to shorten your urls.
- success: Array of all shortened urls.
- error: Array of all urls that have failed.