Advanced6 min5 stepsBusiness

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 reference

Creating 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

  1. Describe each link as a row

    A row needs a destination_url that starts with http:// or https://. It can also carry a slug, a title, a folder name and tags.

    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.

  2. Send the import

    Post up to 500 rows to /api/v1/imports. Set create_folders and create_tags to make the folders and tags your rows name; left off, unknown names are ignored.

    Create an import
    curl -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 }
      }'
  3. Read the result

    The request returns when every row has been processed: 201 Created with the import, its summary and the links that were made, each with the row it 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.

  4. See why rows were skipped

    Retrieve the import with rows=issues to get only the rows that did not become links, each with an error_message.

    Rows that were not created
    curl "https://lnki.io/api/v1/imports/11?rows=issues" \
      -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
  5. 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 429 with a Retry-After header 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.

Keep going