Advanced7 min5 stepsBusiness

Create QR codes with the API

Make a styled QR code from your own code, change its design later and download it as SVG.

Open the QR codes reference

When codes are made by the hundred, for table cards, packaging or event badges, a script is quicker than a form. The API creates the short link and its QR code in one call and returns the drawing.

Before you start

  1. Create a code for a URL

    Post the long URL to /api/v1/qr_codes. Lnki shortens it and makes the code for the new short link. The response is 201 Created with the code, including scan_url, the address it encodes, and svg, the drawing itself.

    To choose the back-half yourself, create the link first and send its link_id instead of destination_url.

    Create a QR code
    curl -X POST https://lnki.io/api/v1/qr_codes \
      -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
      -H "Content-Type: application/json" \
      -d '{
        "destination_url": "https://example.com/menu/autumn",
        "name": "Autumn menu"
      }'
  2. Style it

    Add a design object to control the drawing: colours, the shape of the pattern, eyes and corners, the size in pixels, a logo and a label under the code. Every field is optional.

    A field the API does not know, or a value out of range, is refused with 422 and named in errors, and nothing is created.

    With a design
    curl -X POST https://lnki.io/api/v1/qr_codes \
      -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
      -H "Content-Type: application/json" \
      -d '{
        "destination_url": "https://example.com/menu/autumn",
        "name": "Autumn menu",
        "design": {
          "foreground_color": "#6D28D9",
          "pattern": "dots",
          "eyes": "rounded",
          "size": 600,
          "label": { "text": "Scan for the menu" }
        }
      }'

    Keep strong contrast between the foreground and background colours, and scan the result with a phone before you print a batch.

  3. Change the design later

    A PATCH changes only the design fields you name and redraws the code. The code keeps pointing at the same short link, so copies already printed keep working.

    Update one field
    curl -X PATCH https://lnki.io/api/v1/qr_codes/7315 \
      -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
      -H "Content-Type: application/json" \
      -d '{
        "design": { "background_color": "#F5F3FF" }
      }'
  4. Download the image

    /image returns the drawing as an SVG file, which stays sharp at any print size.

    Save the SVG
    curl https://lnki.io/api/v1/qr_codes/7315/image \
      -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
      --output autumn-menu.svg
  5. Find it in the dashboard

    Codes made through the API are ordinary QR codes: they are listed under QR Codes, count their scans, and can be restyled there too.

What you have now

Your code can produce branded, trackable QR codes on demand. Every design field and its allowed values are in the API reference.

Keep going