supermemoryai/supermemory · error · Error

Failed to add conversation: ${response.status} ${response.st

Error message

Failed to add conversation: ${response.status} ${response.statusText}. ${errorText}

What it means

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.

Source

Thrown at packages/tools/src/conversations-client.ts:96

	const response = await fetch(url, {
		method: "POST",
		headers: {
			"Content-Type": "application/json",
			Authorization: `Bearer ${params.apiKey}`,
		},
		body: JSON.stringify({
			conversationId: params.conversationId,
			messages: params.messages,
			containerTags: params.containerTags,
			metadata: params.metadata,
			entityContext: params.entityContext,
		}),
	})

	if (!response.ok) {
		const errorText = await response.text().catch(() => "Unknown error")
		throw new Error(
			`Failed to add conversation: ${response.status} ${response.statusText}. ${errorText}`,
		)
	}

	return await response.json()
}

View on GitHub (pinned to d436792e77)

Solutions

  1. Inspect the status code and errorText in the message to identify 401 vs 400 vs 429 vs 5xx
  2. Verify the API key and baseUrl used by the client
  3. Log and validate the params payload shape before sending
  4. Retry with backoff for 429/5xx responses

Example fix

// before
await addConversation(params) // throws raw

// after
try {
  await addConversation(params)
} catch (e) {
  if (e instanceof Error && e.message.includes('401')) {
    // refresh API key
  }
  throw e
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (!params?.content) throw new TypeError('content is required for addConversation')

Try / catch

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 }

Prevention

When it happens

Trigger: 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).

Common situations: Missing SUPERMEMORY_API_KEY env var, pointing baseUrl at the wrong environment, sending entityContext or fields the API rejects, or rate limiting (429).

Related errors


AI-assisted analysis of supermemoryai/supermemory@d436792e77 (2026-08-28). Data as JSON: /api/errors/7ba8d220fc639897. Report an issue: GitHub.