Import links with the API
Create up to 500 short links in one request and read back exactly what happened to each row.
Open the imports referenceCreating links one request at a time is limited to 60 a minute. An import sends many at once: a product catalogue, a batch of personalised links, a migration from another tool.
Before you start
- An access token. Make your first API request shows how to get one from an API key.
Describe each link as a row
A row needs a
destination_urlthat starts withhttp://orhttps://. It can also carry aslug, atitle, afoldername andtags.Without a
slug, the back-half is taken from the last part of the URL's path. Send your own when that part is not unique.Send the import
Post up to 500 rows to
/api/v1/imports. Setcreate_foldersandcreate_tagsto make the folders and tags your rows name; left off, unknown names are ignored.Create an importcurl -X POST https://lnki.io/api/v1/imports \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "rows": [ { "destination_url": "https://example.com/products/wool-coat", "slug": "wool-coat", "folder": "Catalogue", "tags": ["autumn"] }, { "destination_url": "https://example.com/products/leather-boots", "folder": "Catalogue", "tags": ["autumn"] } ], "settings": { "create_folders": true, "create_tags": true } }'Read the result
The request returns when every row has been processed:
201 Createdwith the import, itssummaryand thelinksthat were made, each with therowit came from.One bad row does not stop the others. Rows that are not valid URLs, repeat a destination that already has a link, or ask for a back-half that is taken are skipped and counted in the summary.
See why rows were skipped
Retrieve the import with
rows=issuesto get only the rows that did not become links, each with anerror_message.Rows that were not createdcurl "https://lnki.io/api/v1/imports/11?rows=issues" \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Send larger sets in batches
Split more than 500 links over several imports. A workspace may run 10 imports a minute; when you go over, the API answers
429with aRetry-Afterheader saying how many seconds to wait.
What you have now
You can load whole catalogues of links from a script and account for every row. Imports made this way also appear under Imports in the dashboard.
