MemorySync
API Reference

Rate Limits & Errors

Classify HTTP and SDK errors before choosing the next application action. Do not hardcode an undocumented quota.

Handle unsuccessful requests

import os
from memorysync import MemorySyncClient
client = MemorySyncClient(
api_key=os.environ["MEMORYSYNC_API_KEY"],
base_url="https://api.memorysync.io",
project_id=os.environ["MEMORYSYNC_PROJECT_ID"],
end_user_id="usr_7f3a9c2e",
)
from memorysync import MemorySyncError, RateLimitError
try:
result = client.query("What preferences are known?", k=5)
except RateLimitError as error:
print("Rate limited", error.retry_after_seconds)
except MemorySyncError as error:
print("Request failed", error)

Choose the next action

StatusMeaningNext action
2xxThe request completed with an operation-specific result.Read the documented body; an empty or skipped result can be valid.
400, 409, or 422The fields or requested change are invalid.Correct the request rather than waiting.
401 or 403Authentication or project access failed.Correct server credentials or scope.
404The resource is unavailable in this scope.Check scope and ID; show a not-found state.
429The request is rate limited.Use returned error metadata and a bounded application fallback.
5xxThe service could not complete the request.Preserve a recoverable state and avoid assuming a write outcome.

Illustrative error response

429-response.json
{"detail":"Rate limited","retry_after":2}

Keep error handling safe

SDK error classes

ConditionPythonNode.jsTypical action
Authentication or accessAuthErrorAuthErrorCorrect credentials or authorized scope.
Invalid inputValidationErrorValidationErrorCorrect fields; do not retry unchanged.
Unavailable resourceNotFoundErrorNotFoundErrorCheck scope and show a not-found state.
Rate limitedRateLimitErrorRateLimitErrorUse returned retry metadata when present.
Service failureServerErrorServerErrorKeep the task recoverable and reconcile writes.
Network or timeoutMemorySyncErrorMemorySyncErrorTreat write outcome as uncertain.

Decide whether to retry

What kind of failure occurred?

Invalid request or authentication

The same request will fail again.

Use: Correct the request, credential, or scope before another call.

Rate limit with retry metadata

The service supplied a wait signal.

Use: Wait as directed, bound the retry count, and preserve a user fallback.

Read failed with a service or network error

No mutation is involved.

Use: Retry according to your product policy or continue without memory context.

Write response is uncertain

The connection ended before a reliable result was received.

Use: Reconcile through Get or Query before repeating a potentially duplicate action.

Build resilient error handling

  • Catch the most specific SDK error class before the base error class.
  • Keep human-readable messages separate from machine decisions.
  • Do not assume every 2xx means a new record was created; inspect operation-specific bodies.
  • Do not expose raw service errors or memory content directly to end users.
  • Record safe correlation data for support while excluding credentials and sensitive payloads.
Was this page helpful?