Skip to content

Introducing detach

Queue a request now, collect it later

December 3, 2026

Starting today, any Microlink API request can run in the background. Add detach to it, and the API queues it and answers at once. Send the same request again later to get the result.

The following examples show how to use the Microlink API with CLI, cURL, JavaScript, Python, Ruby, PHP & Golang, targeting 'https://microlink.io' URL with 'screenshot' & 'detach' API parameters:

CLI Microlink API example

microlink screenshot https://microlink.io --detach

cURL Microlink API example

curl -G "https://api.microlink.io" \
  -d "url=https://microlink.io" \
  -d "screenshot=true" \
  -d "detach=true"

JavaScript Microlink API example

import createClient from 'microlink.io'

const microlink = createClient()

const data = await microlink.screenshot('https://microlink.io', {
  detach: true
})

Python Microlink API example

import requests

url = "https://api.microlink.io/"

querystring = {
    "url": "https://microlink.io",
    "screenshot": "true",
    "detach": "true"
}

response = requests.get(url, params=querystring)

print(response.json())

Ruby Microlink API example

require 'uri'
require 'net/http'

base_url = "https://api.microlink.io/"

params = {
  url: "https://microlink.io",
  screenshot: "true",
  detach: "true"
}

uri = URI(base_url)
uri.query = URI.encode_www_form(params)

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Get.new(uri)
response = http.request(request)

puts response.body

PHP Microlink API example

<?php

$baseUrl = "https://api.microlink.io/";

$params = [
    "url" => "https://microlink.io",
    "screenshot" => "true",
    "detach" => "true"
];

$query = http_build_query($params);
$url = $baseUrl . '?' . $query;

$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET"
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
    echo "cURL Error #: " . $err;
} else {
    echo $response;
}

Golang Microlink API example

package main

import (
    "fmt"
    "net/http"
    "net/url"
    "io"
)

func main() {
    baseURL := "https://api.microlink.io"

    u, err := url.Parse(baseURL)
    if err != nil {
        panic(err)
    }
    q := u.Query()
    q.Set("url", "https://microlink.io")
    q.Set("screenshot", "true")
    q.Set("detach", "true")
    u.RawQuery = q.Encode()

    req, err := http.NewRequest("GET", u.String(), nil)
    if err != nil {
        panic(err)
    }

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    body, err := io.ReadAll(resp.Body)
    if err != nil {
        panic(err)
    }

    fmt.Println(string(body))
}
TL;DR
  • detach answers 202 {"status":"pending"} with a Retry-After header while the request runs.
  • The same request answers with the result once it is done: the normal 200, or the error it ended with.
  • A detached request has 5 minutes to finish on every plan, instead of 90 seconds on pro and 30 seconds on free.
  • Timeouts and server errors are tried up to 3 times before an error is returned.
  • It is a query parameter on api.microlink.io and pro.microlink.io, so it works with any SDK or integration that can repeat a request.

A connection is a short deadline

Every API request holds its HTTP connection open until the work is done.
That sets a ceiling on how much work fits in one request: 90 seconds on pro, 30 seconds on free. Most requests finish far below it. A heavy page, a long PDF or an animated screenshot of a slow site can need more, and then the answer is a timeout.
It also makes a burst expensive. When thousands of requests arrive together, all of them wait for a browser at the same time, and the ones that wait longest run out of time before they start.

One parameter, the same request

A detached request is the request you already send, with detach added:
curl -i -H "x-api-key: $MICROLINK_API_KEY" \
  'https://pro.microlink.io/?url=https%3A%2F%2Fmicrolink.io&screenshot&detach'
If the result is cached, you get it right away. Otherwise the request is queued:
content-type   : application/json; charset=utf-8
x-pricing-plan : pro
cache-control  : private, no-cache, no-store, max-age=0
retry-after    : 5
{ "status": "pending" }
Wait at least 5 seconds and send it again. It answers 202 until the request is done, and then answers with the response you would have got without detach.
There is no job id to store and no webhook to expose. The request is its own id: sending it again while it runs does not queue it twice, and its answer is kept for 24 hours for the API key that sent it (or the IP address, on the free endpoint).

Five minutes instead of ninety seconds

The time budget starts when the request starts running, not when you send it, and it is the same on every plan: 5 minutes. That covers the whole request: loading the page, rendering it, and building the response. The limits inside it stay the same, such as the time function code can run; the reference lists them.
When a run ends in a timeout, an unreachable page or a server error, the API tries it again, up to 3 times in all, before it keeps the error. A server that stops in the middle of a run does not lose it either: after a few minutes the request goes back to the queue and another server runs it.

Bursts become a queue

Detached requests wait in a queue and start when a browser is free. Each server runs only part of its capacity on them, so requests you wait for keep the rest.
For a batch, that changes the failure mode. Thousands of URLs sent together are no longer a race against the clock: once queued, they wait there instead of timing out while they wait.

What it costs

Every request counts against your quota, as before. The first request and each repeat count once; the background run does not. Retry-After is the shortest wait, not the best one: a request that takes 2 minutes costs about 25 requests when it is repeated every 5 seconds, and about 8 when the wait grows up to 30 seconds. The guide has a loop that does that.
detach works on the free endpoint too, but each repeat takes one of the requests of the day, so an API key is the better fit.

Get started

  • The detach reference covers the parameter, the time budget and the error codes.
  • The background requests guide has a polling loop with backoff for JavaScript and the shell, and a pattern for many URLs.

Start building

Sign up, add the key to your requests, and start turning any link into what you need.
Get your free API key
25 requests/day · Proxy, headers and ttl · No credit card
Trusted with 140M+ requests every month