logo
APIAutomations

Set up pre-redirection forms with the API and automations

The four API fields of a Pre-redirection form on links and QR codes, live request and response examples, every validation error, bulk, webhooks, MCP.

Avatar for undefined
CodeQR Team
Content Team

After reading this page you can create or update a link or dynamic QR code with a Pre-redirection form from your own code, an import, or an automation platform, and you know the exact error each mistake produces. Every request and response below was executed against the production API on 2026-08-17 (domain replaced by go.example.com).

Availability

  • Plan: Business and above. Switching preRedirection on from a lower plan returns 403 forbiddenYou can only use pre-redirection on a Business plan and above. Upgrade to Business to use this feature.
  • Endpoints: POST /links, PUT /links/{linkId}, POST /links/bulk, POST /qrcodes, PUT /qrcodes/{qrcodeId}, POST /qrcodes/bulk. The four fields are returned by every link and QR code response (GET, list, webhooks).
  • Auth: Bearer token from SettingsAPI Keys. Base URL https://api.codeqr.io.
  • Not available: the MCP server (create_link, update_link, create_qrcode, update_qrcode expose none of these fields), and the Zapier, Make and Pluga modules (no form field). Pages and form responses are not part of the public API.

The four fields

  • Pre-redirection form toggle** — Field: preRedirection · Type: boolean, default false · Meaning: show a form before the redirect
  • Use platform formSelect Page — Field: pageId · Type: string or null · Meaning: id of the CodeQR Page with the form
  • page URL (filled by the picker) or Use external form field — Field: pageUrl · Type: string or null · Meaning: public URL of the form: https://<page domain>/<page key> for a CodeQR Page, or the external form URL
  • Mandatory Forms? — Field: isFormMandatory · Type: boolean, default false · Meaning: remove the close button; needs pageId

Rules the server applies:

  • preRedirection: true requires a valid pageUrl. The server never derives it from pageId — send both for a CodeQR Page. Copy the URL from the page card in Pages (it looks like https://go.example.com/p/NRGvqiks5e).
  • isFormMandatory: true requires pageId (a CodeQR Page). External forms are never mandatory.
  • pageId must exist; pageUrl must parse as a URL.
  • Turning preRedirection off keeps pageId, pageUrl and isFormMandatory stored, so turning it back on needs no other field.
  • Static QR codes: the API accepts and stores the fields, but a static QR code encodes the destination directly and never shows the form. Use "static": false.

Create a link with a CodeQR Page form (mandatory)

Request:

curl -X POST https://api.codeqr.io/links \
  -H "Authorization: Bearer codeqr_xxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/whitepaper",
    "domain": "go.example.com",
    "key": "whitepaper",
    "preRedirection": true,
    "pageId": "cmsx4bmpm0001a0d0hwow7468",
    "pageUrl": "https://go.example.com/p/NRGvqiks5e",
    "isFormMandatory": true
  }'

Response (200 OK):

{
  "id": "cmsx55jec0003ui96u4owiiyb",
  "domain": "go.example.com",
  "key": "whitepaper",
  "url": "https://example.com/whitepaper",
  "archived": false,
  "expiresAt": null,
  "expiredUrl": null,
  "password": null,
  "externalId": null,
  "trackConversion": false,
  "proxy": false,
  "title": null,
  "description": null,
  "image": null,
  "video": null,
  "utm_source": null,
  "utm_medium": null,
  "utm_campaign": null,
  "utm_term": null,
  "utm_content": null,
  "rewrite": false,
  "doIndex": false,
  "banned": false,
  "flexible": false,
  "filled": false,
  "ios": null,
  "android": null,
  "geo": null,
  "rules": null,
  "userId": "cm73yc6m70002mtesulffnrgb",
  "folderId": null,
  "projectId": "cm73y7wm100008j24i1b137wr",
  "preRedirection": true,
  "pageId": "cmsx4bmpm0001a0d0hwow7468",
  "pageUrl": "https://go.example.com/p/NRGvqiks5e",
  "isFormMandatory": true,
  "publicStats": false,
  "clicks": 0,
  "lastClicked": null,
  "leads": 0,
  "sales": 0,
  "saleAmount": 0,
  "createdAt": "2026-08-17T11:19:15.828Z",
  "updatedAt": "2026-08-17T11:19:15.828Z",
  "tagId": null,
  "comments": null,
  "notificationToken": null,
  "useAsTemplate": false,
  "tags": [],
  "shortLink": "https://go.example.com/whitepaper",
  "qrCode": "https://api.codeqr.io/qr?url=https://go.example.com/whitepaper?qr=1"
}

Create a link with an external form

curl -X POST https://api.codeqr.io/links \
  -H "Authorization: Bearer codeqr_xxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/catalog",
    "domain": "go.example.com",
    "key": "catalog-form",
    "preRedirection": true,
    "pageUrl": "https://docs.google.com/forms/d/e/1FAIpQLSf_prf_docs_example/viewform?embedded=true"
  }'

200 OK with "preRedirection": true, "pageId": null, "pageUrl": "https://docs.google.com/forms/…", "isFormMandatory": false.

Update an existing link

Switch from a CodeQR Page to an external form:

curl -X PUT https://api.codeqr.io/links/cmsx55jec0003ui96u4owiiyb \
  -H "Authorization: Bearer codeqr_xxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{ "preRedirection": true, "pageId": null,
        "pageUrl": "https://form.typeform.com/to/prfDocsExample", "isFormMandatory": false }'

Turn the form off (the other fields stay stored):

curl -X PUT https://api.codeqr.io/links/cmsx55jec0003ui96u4owiiyb \
  -H "Authorization: Bearer codeqr_xxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{ "preRedirection": false }'

200 OK — the response still shows "pageId": "cmsx4bmpm0001a0d0hwow7468", "pageUrl": "https://go.example.com/p/NRGvqiks5e", "isFormMandatory": true with "preRedirection": false.

Dynamic QR codes

Same fields on POST /qrcodes and PUT /qrcodes/{qrcodeId}, any type:

curl -X POST https://api.codeqr.io/qrcodes \
  -H "Authorization: Bearer codeqr_xxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "whatsapp",
    "static": false,
    "domain": "go.example.com",
    "key": "wa-qr",
    "whatsapp": { "number": "5511999999999", "message": "Hi, I want the catalog" },
    "preRedirection": true,
    "pageId": "cmsx4bmpm0001a0d0hwow7468",
    "pageUrl": "https://go.example.com/p/NRGvqiks5e"
  }'

200 OK; after the form the visitor is sent to https://wa.me/5511999999999?text=Hi%2C%20I%20want%20the%20catalog. For a URL QR code send "type": "url", "url": "https://example.com/menu".

Errors

  • preRedirection: true without pageUrl (also pageId without pageUrl) — Status: 400 · error.code: unprocessable_entity · error.message: Pre-redirection page URL missing
  • pageUrl: "not a url" — Status: 400 · error.code: unprocessable_entity · error.message: Invalid pre-redirection page URL
  • isFormMandatory: true without pageId — Status: 400 · error.code: unprocessable_entity · error.message: CodeQR page required for form submission
  • unknown pageId — Status: 404 · error.code: not_found · error.message: Page not found
  • workspace below Business turning it on — Status: 403 · error.code: forbidden · error.message: You can only use pre-redirection on a Business plan and above. Upgrade to Business to use this feature.

Example body:

{
  "error": {
    "code": "unprocessable_entity",
    "message": "Pre-redirection page URL missing",
    "doc_url": "https://docs.codeqr.io/api-reference/errors#unprocessable_entity"
  }
}

Bulk and CSV import

POST /links/bulk and POST /qrcodes/bulk accept the same four fields per item. The CSV importers in the app (Links and QR Codes → import) accept the columns PRE_REDIRECTION, PAGE_URL and PAGE_ID; isFormMandatory is not importable — set it afterwards with PUT. See Import links from CSV.

Webhooks and automations

  • link.created, link.updated, qrcode.created, qrcode.updated payloads carry the four fields, so a downstream automation can react to a form being enabled.
  • A submission on a CodeQR Page form produces a lead.created event when the page has Conversion tracking on (Pro and above): customer (name, email, customFields with the form fields relabeled and the UTM values of the short link), interaction (the click), and the link or qrcode object. Nothing is emitted for external forms.
  • Zapier, Make, Pluga: to create a link with a form use an HTTP step (Make: Make an API Call module of the CodeQR app) with the POST /links body above. To receive the leads use the lead.created trigger — with Conversion tracking on. See Where your leads go.
  • MCP: ask the agent to create the link, then set the four fields with one PUT /links/{linkId} — the MCP tools do not accept them today.

Verify

curl -s https://api.codeqr.io/links/cmsx55jec0003ui96u4owiiyb \
  -H "Authorization: Bearer codeqr_xxxxxxxxxxxxxxxxxxxxxxxx" | grep -oE '"(preRedirection|pageId|pageUrl|isFormMandatory)":[^,]*'
# "preRedirection":true
# "pageId":"cmsx4bmpm0001a0d0hwow7468"
# "pageUrl":"https://go.example.com/p/NRGvqiks5e"
# "isFormMandatory":true

curl -sI -A "Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X)" https://go.example.com/whitepaper | grep -i x-pathname
# x-pathname: /go.example.com/pre-redirection/whitepaper/link

Related articles