Skip to content
Turn spreadsheet rows into short links with n8n

Turn spreadsheet rows into short links with n8n

Read one Google Sheets row, create a short link, and write the result back to the same row.

You shorten twelve links and paste them into your campaign sheet. Then two destinations change. Give each row a permanent ID so n8n can update the right chck.my link and write the result back.

Start with one unpublished row

This fictional bookstore shares one event through its newsletter and its poster. Each placement has its own row. The short address is an example.

row_idrevisioninput_urlstatusshort_url
book-fair-email1example.com/book-fair?utm_source=newsletterREADYEmpty
book-fair-poster1example.com/book-fair?utm_source=posterDONEchck.my/Ab3xYz9

Use full HTTPS destinations in the sheet. Add link_id for the returned ID and error_code to find rows that need attention.

Keep the row ID and version separate

Send the row ID as externalId. It stays the same when you sort the sheet. The API looks up that link in the workspace and creates it if missing. Use distinct ID prefixes if several sheets feed the same workspace.

Use the optional Idempotency-Key to identify one request version, such as links.book-fair-email.v1. If the response is lost, send the same key and body again. For an approved destination change, keep the same externalId, raise the revision to 2, and use links.book-fair-email.v2. That updates the existing link. Reuse the version-two key on any retry.

Connect the nodes

Use a Pro or Team workspace, a write-enabled API key, and a Google credential that can edit the test sheet. n8n or connected services may cost extra.

  1. Manual Trigger → Google Sheets Get Row(s). Filter by the test row’s row_id. When you expand the workflow, filter for READY and turn on Return All Matches.
  2. HTTP Request. Use PUT and append /links/upsert to the API base URL in the developer guide. In Header Auth, use Authorization with Bearer, a space, and your key. Send JSON. Map input_url to url and row_id to externalId. Set the Idempotency-Key header from the row ID and revision.
  3. Check the result → Google Sheets Update Row. Enable Include Response Headers and Status and Never Error. On a 2xx with a shortLink, match the original row_id and write shortLink to short_url, id to link_id, and DONE to status. On an error, record the code and keep the last published URL.

Run the same input twice and compare the IDs and addresses. Sort the sheet and check the result reaches the same row. If the sheet write fails after the API succeeds, rerun the original request to recover the result.

Retry the affected row

On a 429, wait for Retry-After and cap retries. Keep the row ID and revision on the n8n error path for timeouts. Check input on 400, the key on 401, and access on 403. On 409, check whether the body changed under the same key. A 410 can mean the result was deleted or its 30-day retrieval window ended. Look up the link before starting a new operation. On 422, check the destination against the URL rules.

Keep keys in n8n credentials and use destinations you can share with your team. Execution history can retain requests and responses. Revoke a leaked key in chck.my and replace the credential in n8n.

Open the developer guide below and use one test row before enabling a schedule.

References

short link automationn8nGoogle SheetsURL shortener API

Keep reading