Developer
Features

Creating a mobile-targeted link

Creating a mobile-targeted link with the ShortFreeURL REST API: POST /api/links. The original URL provides the fallback for other visitors.

Complete this task in your own workspace. The screenshots use demonstration data.

1. Prepare your workspace and API key

Open Dashboard → Integrations & API → API. Create a named secret key with the smallest required scope. Use a key with write access for this operation; a create-only key cannot update existing records. Store it as SHORTFREEURL_API_KEY in your environment. The secret is shown once.

ShortFreeURL API keys in a demonstration workspace
Select the scope before creating your key. Never share the secret in a screenshot. · Demo workspace. Click to enlarge.

2. Find the correct resource

Open Mobile targeting. Select your domain. A link editor URL contains id=; use that link ID in requests. Get domain IDs from GET /api/domains. Replace example IDs 42 and 918 and the example hostname with your own values.

ShortFreeURL Mobile targeting in a demonstration workspace
Mobile targeting · Demo workspace. Click to enlarge.

3. Review the operation

The original URL provides the fallback for other visitors. Test both platforms and the desktop fallback.

POST /api/links. This changes data. Check every ID and field before running it. Inspect upgradeRequired in responses: a successful update can leave unsupported fields unchanged.

4. Choose a language and run the request

Terminal setup with PowerShell, Bash and screenshots →

Shell uses curl. Node requires a runtime with fetch. Python uses its standard library. Other examples list their required HTTP library in code. Set the API host to this installation’s deployed HTTPS origin, then run the example from your terminal or backend.

curl --request POST 'https://api.shortfreeurl.com/api/links' \
  --header "Authorization: Bearer $SHORTFREEURL_API_KEY" \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "domainId": 42,
  "original_url": "https://example.com",
  "android_url": "https://example.com/android",
  "iphone_url": "https://example.com/ios"
}'

5. Verify the result

  1. Read the HTTP status and response. For QR exports, save the returned image instead of parsing JSON.
  2. Read the resource again and reopen it in the dashboard. Confirm the intended field changed and unrelated settings stayed intact.
  3. For targeting, expiry or password changes, make a controlled test visit. A real visit may add to analytics. For deletion, verify the record is absent before retrying.

6. Troubleshoot safely

  • 401: check key expiry, revocation and workspace membership.
  • 403/402: check role, key scope, feature access and subscription.
  • 404: confirm the resource belongs to your workspace and domain.
  • 429: wait for Retry-After, reduce concurrency and check plan limits.
  • Timeout after a write: read the resource first; avoid creating duplicates.

Try a request in the API reference · All workflow guides