{"record":{"id":"7ba8d220fc639897","repo":"supermemoryai/supermemory","slug":"failed-to-add-conversation-response-status-r","errorCode":null,"errorMessage":"Failed to add conversation: ${response.status} ${response.statusText}. ${errorText}","messagePattern":"Failed to add conversation: (.+?) (.+?)\\. (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/tools/src/conversations-client.ts","lineNumber":96,"sourceCode":"\n\tconst response = await fetch(url, {\n\t\tmethod: \"POST\",\n\t\theaders: {\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t\tAuthorization: `Bearer ${params.apiKey}`,\n\t\t},\n\t\tbody: JSON.stringify({\n\t\t\tconversationId: params.conversationId,\n\t\t\tmessages: params.messages,\n\t\t\tcontainerTags: params.containerTags,\n\t\t\tmetadata: params.metadata,\n\t\t\tentityContext: params.entityContext,\n\t\t}),\n\t})\n\n\tif (!response.ok) {\n\t\tconst errorText = await response.text().catch(() => \"Unknown error\")\n\t\tthrow new Error(\n\t\t\t`Failed to add conversation: ${response.status} ${response.statusText}. ${errorText}`,\n\t\t)\n\t}\n\n\treturn await response.json()\n}\n","sourceCodeStart":78,"sourceCodeEnd":103,"githubUrl":"https://github.com/supermemoryai/supermemory/blob/d436792e777a99865939dd543c8d1a16d57f54ec/packages/tools/src/conversations-client.ts#L78-L103","documentation":"addConversation throws when the HTTP POST to the Supermemory conversations endpoint returns a non-2xx status. The message includes the status code, status text, and response body for diagnosis.","triggerScenarios":"Calling addConversation with an invalid/expired API key (401), malformed payload (400), wrong base URL, or when the API is down (5xx / network-level failure rendered as !response.ok).","commonSituations":"Missing SUPERMEMORY_API_KEY env var, pointing baseUrl at the wrong environment, sending entityContext or fields the API rejects, or rate limiting (429).","solutions":["Inspect the status code and errorText in the message to identify 401 vs 400 vs 429 vs 5xx","Verify the API key and baseUrl used by the client","Log and validate the params payload shape before sending","Retry with backoff for 429/5xx responses"],"exampleFix":"// before\nawait addConversation(params) // throws raw\n\n// after\ntry {\n  await addConversation(params)\n} catch (e) {\n  if (e instanceof Error && e.message.includes('401')) {\n    // refresh API key\n  }\n  throw e\n}","handlingStrategy":"try-catch","validationCode":"if (!params?.content) throw new TypeError('content is required for addConversation')","typeGuard":null,"tryCatchPattern":"try { await addConversation(params) } catch (e) { if (e instanceof Error && /401|403/.test(e.message)) rotateApiKey(); else if (/429|5\\d\\d/.test(e.message)) await retry(addConversation, params); else throw e }","preventionTips":["Validate payload shape client-side before posting","Keep API key and baseUrl in validated config","Retry 429/5xx with exponential backoff"],"tags":["http","api","conversations","supermemory"],"backgroundTag":"api-request-failed","analyzedSha":"d436792e777a99865939dd543c8d1a16d57f54ec","analyzedAt":"2026-08-28T18:04:46.947Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}