{"record":{"id":"b138db9d2337722e","repo":"jackwener/OpenCLI","slug":"instagram-private-route-could-not-derive-x-ig-app","errorCode":null,"errorMessage":"Instagram private route could not derive X-IG-App-ID from instagram runtime","messagePattern":"Instagram private route could not derive X-IG-App-ID from instagram runtime","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/instagram/_shared/private-publish.js","lineNumber":113,"sourceCode":"            await page.wait({ time: 2 });\n            const [cookies, runtime, entries] = await Promise.all([\n                page.getCookies({ domain: 'instagram.com' }),\n                page.evaluate(buildReadInstagramRuntimeInfoJs()),\n                typeof page.readNetworkCapture === 'function'\n                    ? page.readNetworkCapture()\n                    : Promise.resolve([]),\n            ]);\n            const captureEntries = (Array.isArray(entries) ? entries : []);\n            const capturedContext = derivePrivateApiContextFromCapture(captureEntries)\n                ?? derivePartialPrivateApiContextFromCapture(captureEntries);\n            const csrfToken = runtime?.csrfToken || getCookieValue(cookies, 'csrftoken') || capturedContext.csrfToken || '';\n            const igAppId = runtime?.appId || capturedContext.igAppId || '';\n            const instagramAjax = runtime?.instagramAjax || capturedContext.instagramAjax || '';\n            if (!csrfToken) {\n                throw new CommandExecutionError('Instagram private route could not derive CSRF token from browser session');\n            }\n            if (!igAppId) {\n                throw new CommandExecutionError('Instagram private route could not derive X-IG-App-ID from instagram runtime');\n            }\n            if (!instagramAjax) {\n                throw new CommandExecutionError('Instagram private route could not derive X-Instagram-AJAX from instagram runtime');\n            }\n            const asbdId = capturedContext.asbdId || '';\n            const igWwwClaim = capturedContext.igWwwClaim || '';\n            const webSessionId = capturedContext.webSessionId || '';\n            return {\n                apiContext: {\n                    asbdId,\n                    csrfToken,\n                    igAppId,\n                    igWwwClaim,\n                    instagramAjax,\n                    webSessionId,\n                },\n                jazoest: deriveInstagramJazoest(csrfToken),\n            };","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/_shared/private-publish.js#L95-L131","documentation":"The private API route must send the X-IG-App-ID header. It is taken from the instagram runtime appId or the captured browser context; when neither provides it the request would be rejected by Instagram, so this error is thrown up front.","triggerScenarios":"resolveInstagramPrivatePublishConfig runs with runtime.appId unset and no captured context containing igAppId.","commonSituations":"Minimal runtime config without appId, private route invoked before any page load captured headers, Instagram changed the app id and captures are stale/absent.","solutions":["Set appId in the instagram runtime config (the standard web app id: 936619743392459)","Ensure a page load happens before the private call so headers are captured","Re-login / reload instagram.com to refresh captured context","Upgrade the CLI if Instagram rotated app ids and captures no longer include it"],"exampleFix":"// before\nruntime = { csrfToken };\n// after\nruntime = { csrfToken, appId: '936619743392459', instagramAjax: ajaxValue };","handlingStrategy":"validation","validationCode":"if (!runtime.appId && !captured.igAppId) {\n  runtime.appId = '936619743392459'; // standard Instagram web app id\n}","typeGuard":"function hasIgAppId(rt) {\n  return typeof rt?.appId === 'string' && /^\\d{10,}$/.test(rt.appId);\n}","tryCatchPattern":"try {\n  await publishPrivate(cfg);\n} catch (e) {\n  if (/could not derive X-IG-App-ID/.test(e.message)) {\n    cfg.runtime.appId = '936619743392459'; // retry with known app id\n  } else throw e;\n}","preventionTips":["Set appId explicitly in the instagram runtime config","Load an instagram.com page first so request headers are captured","Keep the CLI updated if Instagram rotates its web app id"],"tags":["instagram","headers","configuration","private-api"],"backgroundTag":"missing-required-header","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}