Supermemory logo

Integrate Supermemory with your AI CRM

Supermemory is a memory and context API for ingesting, organizing, searching, and recalling information across applications.

Explore Triggers and Actions

Add Document

Ingest text or a public URL as a Supermemory document and return its document ID and initial processing status.

ActionTry it

Add Documents

Add 1 to 600 documents in one request, with per-document metadata and processing options. Inspect counts and results for partial failures; the tool raises an error if all documents fail, and the API does not guarantee atomicity or result ordering.

ActionTry it

Add Namespace Document

Add text or a supported URL as searchable, evolving memory in an isolated namespace. Supply a new document ID to create a document, or reuse an existing ID to append information while preserving history. Ingestion is asynchronous: inspect the returned processing status and retrieve the document to check completion.

ActionTry it

Add Namespace Documents

Ingest 1 to 600 text or URL documents in an isolated namespace. Existing caller-defined IDs append information with single-document ingestion semantics. Acceptance is asynchronous, not completed processing. HTTP 200 may contain partial failures: inspect count, failed, and each result's error, details, and url. Accepted results precede failures; match by id or failed-item url, not position. An all-failed batch raises an error.

ActionTry it

Add or Update Namespace Profile Buckets

Add or update namespace-owned profile bucket definitions that guide memory classification. Omitted buckets remain unchanged. Organization-wide buckets are protected and cannot be changed. Returns the effective definitions, including organization buckets. Requires namespace write access.

ActionTry it

Bulk Delete Documents

Deprecated provider v3 endpoint; shuts down December 31, 2026. Use v5 namespace document deletion (DELETE /ns/{namespace}/document) instead. Delete up to 100 documents by ID, all documents in selected container tags, or documents matching a filepath. Container-tag and filepath selectors can delete many documents. Inspect success, deleted_count, and errors for the actual outcome; an HTTP 200 alone does not prove every document was deleted.

ActionTry it

Configure Automatic Top-Ups

Deprecated legacy v3 API, scheduled to shut down December 31, 2026. Configure automatic paid USD credit purchases for the connected organization. Enabling reloads can cause financial charges when the credit balance is low. Requires an unscoped organization API key with admin or owner access; paid-plan and saved-payment-method requirements apply when enabling. Supply the full console configuration explicitly, including when disabling. Purchase limits do not cap total usage or the full invoice.

ActionTry it

Configure Connection

Deprecated by the provider: the legacy v3 API shuts down December 31, 2026. Use the v5 namespace connectors API for new integrations. Configure selected resources for an existing legacy connection; currently only GitHub supports resource configuration. Returns the provider's success flag, outcome message, and optional registered-webhook count.

ActionTry it

Count Namespace Document Memories

Count live memories in a namespace for up to 100 public document IDs. Missing or inaccessible documents are omitted, not reported as zero.

ActionTry it

Create Connection

Deprecated by the provider: this legacy v3 endpoint shuts down on December 31, 2026. Use CREATE_CONNECTOR for v5 namespace-scoped connectors. Initialize a provider connection and return its ID and any authorization URL. This does not open the URL or complete user authorization; the user must authorize separately before the connection can import documents.

ActionTry it

Create Connector

Connect an external source to a namespace. Choose the provider-specific connector settings. OAuth providers return an authorization URL to send the user to; config-authenticated providers start syncing immediately.

ActionTry it

Create Memory

Deprecated by the provider; v3/v4 APIs shut down on December 31, 2026. Use v5 namespace document ingestion for new integrations. Create 1 to 100 memories directly in an existing container, bypassing document ingestion. Generates embeddings and makes the memories immediately searchable.

ActionTry it

Create Scoped Key

Deprecated legacy v3 route; provider shutdown is December 31, 2026. No v5 scoped-key creation alternative is documented. Create an API key restricted to one namespace or a fixed list of namespaces, using an organization API key; scoped keys cannot mint further keys. Writable scoped keys can update and delete content within their namespaces. Returns a secret credential: store it securely and do not log it.

ActionTry it

Delete Connection

Deprecated by the provider: this legacy v3 endpoint shuts down on December 31, 2026. Use DELETE_CONNECTOR for v5 namespace-scoped connector deletion instead. Delete a specific connection by ID. By default this also deletes documents imported by the connection; set deleteDocuments to 'false' to retain them. Returns deleted connection IDs and providers.

ActionTry it

Delete Connector

Disconnect a connector in a namespace and stop its webhooks. Imported documents are also deleted by default. Set deleteDocuments to false to preserve those documents.

ActionTry it

Delete Container Tag

Deprecated by the provider: the legacy v3 API shuts down on December 31, 2026. Use v5 DELETE /ns/{namespace} to delete a namespace instead. Delete a container tag and all its documents and memories. Only organization owners and admins can perform this destructive action.

ActionTry it

Delete Document

Permanently delete one document by ID. This does not remove the document's container-tag settings record.

ActionTry it

Delete Namespace

Retire a namespace and permanently delete its documents and memories. Optionally set moveTo to preserve its content by moving everything into another namespace first. A queued response only acknowledges an asynchronous move, not completed deletion; a deleted response confirms permanent removal.

ActionTry it

Delete Namespace Documents

Permanently delete 1 to 100 documents and their derived knowledge from a namespace by document ID or caller-defined ID. Each identifier is handled independently; successful deletions are preserved if others fail. Inspect count and every errors entry: HTTP 200 does not mean all documents were deleted.

ActionTry it

Delete Namespace Profile Buckets

Remove 1 to 50 profile bucket categories created specifically for a namespace and return its updated effective bucket definitions. Unknown names are safely ignored. Organization-wide buckets are protected and cannot be removed with this action. Requires namespace write access.

ActionTry it

Delete Provider Connection

Deprecated by the provider: this legacy v3 endpoint shuts down on December 31, 2026. Use DELETE_CONNECTOR for v5 namespace-scoped connector deletion by connector ID instead. Delete connections for a specific provider and container tags. Returns the deleted connection IDs and providers.

ActionTry it

Forget Matching Memories

Deprecated by Supermemory: legacy v3/v4 APIs shut down December 31, 2026. Use v5 DELETE /ns/{namespace}/memories/semantic for semantic forgetting, or DELETE /ns/{namespace}/memories for exact IDs. Soft-delete memories in one container matching a natural-language instruction or exact IDs. Set dry_run=true to preview first; omission defaults to real forgetting. Semantic matches may change between preview and apply; use exact IDs for a reviewable selection.

ActionTry it

Forget Memory

Deprecated by the provider; v3/v4 APIs shut down on December 31, 2026. Use v5 DELETE /ns/{namespace}/memories for new integrations. Soft-delete a memory by ID or exact content within a required container tag. The memory is marked as forgotten, not permanently deleted.

ActionTry it

Forget Namespace Memories

Remove 1 to 500 exact memories from normal recall in a namespace by stable memory ID, preserving their audit history. Each ID is handled independently: missing or ineligible memories are reported without rolling back successful changes. Inspect count, errors, and matches; HTTP 200 does not mean every requested memory was forgotten.

ActionTry it

Forget Namespace Memories Semantically

Preview or forget memories in a namespace using a natural-language query. Explicitly set dryRun to true to preview or false to apply forgetting. For a reviewable, drift-free workflow, preview here and pass the returned memory IDs to the exact-ID forget action instead of rerunning the query. Inspect count, matches, and errors for the provider-reported outcome.

ActionTry it

Get Account Status

Return the connected Supermemory organization's plan, credit balance, high-level usage, and reset date.

ActionTry it

Get Automatic Top-Ups

Deprecated legacy v3 API, scheduled to shut down December 31, 2026. Get the connected organization's automatic credit top-up configuration and payment-method availability without changing billing settings or purchasing credits. Requires an unscoped organization API key; scoped API keys cannot read billing.

ActionTry it

Get Billing Usage

Deprecated legacy v3 API; provider shutdown is December 31, 2026. Retrieve the connected organization's per-feature billing usage, limits, units, and period bounds when available. Requires an organization API key; scoped API keys cannot read billing. Console usage estimates are not authoritative invoices.

ActionTry it

Get Billing Usage Events

Deprecated legacy v3 API, scheduled to shut down December 31, 2026. Get daily billing meter events for the connected organization, including per-feature consumption and Memory versus SuperRAG token totals. Optional ISO 8601 start and end override the billing period. Requires an organization API key; scoped API keys cannot read billing. Console usage is an estimate; invoice line items are authoritative.

ActionTry it

Get Connection

Deprecated by the provider: this legacy v3 endpoint shuts down December 31, 2026. Use the v5 GET /ns/{namespace}/connectors/{id} endpoint for new integrations. Retrieve a legacy connection by ID, including available provider metadata and the latest sync run status.

ActionTry it

Get Connector

Read a connector in a namespace, including its setup, selection, and latest sync status. Optionally include the 10 most recent sync runs with failed items or a one-time hosted picker URL. Requesting picker requires admin write access because the link allows changing what syncs.

ActionTry it

Get Container Tag

Deprecated by the provider: this legacy v3 endpoint shuts down on December 31, 2026. Use v5 GET /ns/{namespace} for namespace settings instead. Get a container tag's display name, entity context, memory filesystem paths, profile buckets, and creation and update timestamps.

ActionTry it

Get Container Tag Merge

Deprecated by the provider: this legacy v3 endpoint shuts down on December 31, 2026. Get the status and progress of a queued container tag merge by its merge job ID, including copied rows, renamed custom IDs, and the last error. This read does not start or retry a merge.

ActionTry it

Get Document

Get one document's content, metadata, source details, and processing status by document ID.

ActionTry it

Get Document Chunks

Return the ordered extracted chunks for one processed document.

ActionTry it

Get Document File URL

Deprecated by the provider: this legacy endpoint shuts down December 31, 2026. Get a fresh presigned download URL for a document's uploaded file. The URL is valid for 24 hours. Returns an error if the document does not exist or has no file.

ActionTry it

Get Error Analytics

Deprecated legacy v3 endpoint scheduled to shut down December 31, 2026. Retrieve organization-wide error analytics, including request-type summaries, HTTP error breakdowns, hourly trends, and per-key metrics for a time window. Returns one page; increment page using the returned pagination metadata.

ActionTry it

Get Namespace Document

Retrieve a document's canonical content, metadata, and processing state by document ID or caller-defined ID within a namespace. Optionally include source chunks, derived memories, or both. Processing status done does not necessarily mean memory generation is complete; inspect dreamingStatus separately.

ActionTry it

Get Namespace Memory

Retrieve one memory by ID within a namespace, including its text, metadata, version, and recall flags. Optionally include version history up to three steps away (nearest first), direct extends and derives links, and source documents. relatedLimit caps each related list separately.

ActionTry it

Get Namespace Profile

Read the continuously maintained profile of a namespace's subject without a search query. Returns stable facts, evolving context, and custom buckets; optionally restrict contributing memories with metadata filters or select buckets.

ActionTry it

Get Namespace Profile Buckets

Inspect the profile taxonomy active in a Supermemory namespace. Returns a name-to-description map combining organization-wide profile buckets with namespace-owned additions.

ActionTry it

Get Namespace Settings

Read a namespace's supporting context and lifecycle timestamps. Supporting context helps Supermemory understand content and form better memories inside this namespace.

ActionTry it

Get Organization

Read the connected organization's shared background that guides memory formation across all namespaces, together with its active namespace count. This action takes no parameters and does not change organization settings.

ActionTry it

Get Profile

Retrieve the static, dynamic, or bucketed profile learned for one container tag, optionally with matching search results.

ActionTry it

Get Profile Buckets

Deprecated by the provider: this legacy v4 endpoint shuts down on December 31, 2026. Use v5 GET /ns/{namespace}/profile/buckets instead. Return the effective profile bucket definitions for a container tag, merging organization-level buckets with container-tag-level additions.

ActionTry it

Get Provider Connection

Deprecated by the provider: this legacy v3 endpoint shuts down on December 31, 2026. Use v5 LIST_CONNECTORS to find namespace connectors and GET_CONNECTOR to retrieve one by ID. Retrieve a legacy connection by provider and container tags, including its latest synchronization status when available. This POST only reads connection details.

ActionTry it

Get Settings

Deprecated legacy v3 API, scheduled to shut down December 31, 2026. Use the v5 organization and namespace settings APIs for new integrations. Retrieve the connected organization's ingestion filters, connector OAuth configuration, chunk size, and profile buckets. Connector client secrets are omitted from the response.

ActionTry it

Get Usage Analytics

Deprecated legacy v3 API, scheduled to shut down December 31, 2026. Get organization-wide request usage analytics, including counts by request type, hourly performance, per-API-key metrics, and total memories. Filter by a relative period or ISO 8601 from_ and to bounds. Returns one page; use pagination to request further pages. Recorded tokensUsed is not the billable ingestion-token meter.

ActionTry it

Ingest Conversation

Deprecated by the provider: the v3/v4 API shuts down December 31, 2026. For new integrations, ingest a conversation transcript through v5 POST /ns/{namespace}/document instead. Ingest or update a conversation by its conversationId using structured messages, optional container tags, and metadata. Returns the backing document ID and processing status, not a guarantee that asynchronous processing has finished.

ActionTry it

List All Connectors

List one page of connectors across every namespace the API key can read, optionally filtered by provider. Use for admin views spanning users or projects. Pending connectors are not listed. Increment page up to pagination.totalPages to retrieve subsequent pages.

ActionTry it

List Connection Documents

Deprecated by the provider: this legacy v3 endpoint shuts down on December 31, 2026. For v5 document listing, use LIST_NAMESPACE_RESOURCES with type documents; v5 connectors are namespace-scoped. List documents indexed for a connected provider, optionally filtered by container tags. Returns document IDs, processing statuses, titles, summaries, types, and timestamps.

ActionTry it

List Connection Resources

Deprecated by the provider: this legacy v3 endpoint shuts down on December 31, 2026. List one page of accessible resources for a connection; only GitHub is currently documented as supported. Use page and per_page to request additional pages, and parent_id to scope resources to a parent.

ActionTry it

List Connections

Deprecated by the provider: this legacy v3 endpoint shuts down on December 31, 2026. Use v5 LIST_CONNECTORS for namespace connectors or LIST_ALL_CONNECTORS across namespaces. List all legacy connections, optionally filtered by container tags, including the latest synchronization status when available.

ActionTry it

List Connectors

List one page of connectors that sync into a namespace, optionally filtered by provider. Pending authorization connectors are not listed. Use page and limit with the returned pagination metadata to retrieve subsequent pages.

ActionTry it

List Container Tags

Deprecated by the provider: the legacy v3 API shuts down December 31, 2026. Use the v5 namespace listing API for new integrations. List all container tags, optionally restricted by a comma-separated filter, including summaries, Nova flags, document and memory counts, and active merge details.

ActionTry it

List Documents

List documents, optionally filtered by containers, metadata, or filepath, one page at a time.

ActionTry it

List Inferred Memories

List a namespace's inferred memories awaiting review. This review route is still served under v3; pass the namespace as containerTag. Returns up to 50 memories ordered by parentCount descending, then createdAt descending, excluding forgotten, expired, or reviewed memories. No pagination is documented; total can exceed the returned count. Unknown or empty namespaces return an empty list and zero total. No v5 replacement is documented.

ActionTry it

List Invoices

Deprecated legacy v3 API, scheduled to shut down December 31, 2026. List the connected Supermemory organization's billing invoices without changing billing settings or purchasing credits. Requires an unscoped organization API key; scoped API keys cannot read billing.

ActionTry it

List Memories

List extracted memory entries for one or more container tags, one page at a time.

ActionTry it

List Namespace Resources

Browse one page of documents, extracted chunks, or learned memories in a namespace. The other collection arrays are empty. Use pagination.totalPages and page to retrieve further pages. Position sorting is for chunks only; include.content and include.memoryCount apply to documents, and include.forgotten applies to memories.

ActionTry it

List Namespaces

List namespaces available to the caller, newest first, including their purpose, document and memory counts, and lifecycle timestamps. Optionally filter names with q. Returns one page; use page and the returned pagination to fetch more.

ActionTry it

List Processing Documents

Deprecated by the provider: the legacy v3 API shuts down December 31, 2026. Use the v5 namespace document listing API for new integrations. List the live processing queue, all unfinished documents, or unfinished and failed documents. For view=all, fetch subsequent pages using page and limit and inspect the returned pagination information.

ActionTry it

List Request Logs

Deprecated legacy v3 endpoint scheduled to shut down December 31, 2026. List one page of organization-wide request logs filtered by time. Use pagination metadata and increment page to continue. Outputs are compacted and may be truncated. The ordinary tracker skips HTTP 402, 404, and 500 responses, so logs are not a complete audit trail. Historical retention is not guaranteed. Request type, status code, and API key filters are not supported.

ActionTry it

Merge Container Tags

Deprecated by the provider: the legacy v3 API shuts down December 31, 2026. Queue a merge of exactly two container tags into a target tag. All source documents are updated to reference the target, and source tags are deleted after a successful merge. Requires an organization admin or owner. The response confirms queuing, not completion; use GET_CONTAINER_TAG_MERGE with the returned mergeId to check progress.

ActionTry it

Replace Namespace File

Replace an existing document with a new file within an isolated namespace, keeping its stable document ID. Content and caller metadata are overwritten and the document is reprocessed asynchronously. The returned status reports processing state, not guaranteed completion. Requires namespace write access.

ActionTry it

Reset Organization Data

Deprecated by the provider: this legacy v3 endpoint shuts down on December 31, 2026. Destructively reset the ENTIRE connected organization's content: delete documents, memories, spaces except the default project, connections, and organization settings, and clear the default space context. Preserves the organization itself, members, and billing. This is not scoped to an individual document, container tag, or namespace. Only call with explicit authorization to delete the entire organization's data.

ActionTry it

Review Inferred Memory

Provider deprecation notice: legacy v3/v4 APIs are scheduled to shut down December 31, 2026. These review routes still serve namespaces under v3; no v5 replacement is documented. Approve, decline, or undo a review of one inferred memory in a namespace. Approve confirms the fact; decline forgets it and removes it from search; undo restores the unreviewed inferred state, including un-forgetting a declined memory. Requires a key with write access to the namespace. A non-reviewable memory or an undo without a prior review returns 409.

ActionTry it

Revoke Scoped Key

Deprecated by the provider: this legacy v3 endpoint shuts down on December 31, 2026. Revoke a scoped API key using the ID returned at creation. Subsequent requests using the revoked key receive 401. Memories and namespaces are not deleted. Authenticate with an organization API key, not a scoped key.

ActionTry it

Search Documents

Deprecated by the provider: legacy v3/v4 APIs shut down December 31, 2026. Use v5 namespace search (POST /ns/{namespace}/search) for new integrations. Search documents and their content chunks with optional container, document, metadata, and filepath filters. Returns one bounded result set with relevance scores and optional full content or summaries.

ActionTry it

Search Memory

Semantically search Supermemory memories, document chunks, or both, with optional container and metadata filters.

ActionTry it

Search Namespace

Recall relevant learned context and source passages from an isolated namespace. Hybrid search combines memories and document chunks by default. Supports typed metadata filters (up to five levels), query rewriting, reranking, and optional source documents and related memories.

ActionTry it

Send Feedback

Send a bug report, feature request, documentation problem, or other feedback to the Supermemory team. This contacts real engineers and consumes the organization's quota of three submissions per UTC day, subject to a shared authenticated pool of 200 per day. Do not automatically retry uncertain deliveries, including HTTP 502: delivery may already have occurred.

ActionTry it

Suggest Profile Buckets

Deprecated by the provider: the legacy v3 API shuts down December 31, 2026. Suggest profile bucket definitions using the organization's saved context prompt. Returns 3 to 6 suggestions tailored to that context without saving bucket definitions. Fails when no organization context is available.

ActionTry it

Sync Connection

Deprecated provider v3 API; shuts down December 31, 2026. For v5, use SYNC_CONNECTOR with a namespace and connector ID instead. Initiate a manual sync of connections for a provider, optionally filtered by container tags. The acknowledgement means importing was accepted, not that sync has finished.

ActionTry it

Sync Connector

Start a sync now for a connector in a namespace. Returns the connector ID and queued status, not a completed sync result. Returns a conflict if a sync for this connector is already running. Use Get Connector to inspect sync progress and results.

ActionTry it

Update Connector

Change what a connector syncs in a namespace or its maximum document count. A supplied selection replaces the old selection and starts a sync. Only send selection for providers that support choosing resources. Returns the updated connector and its latest sync status.

ActionTry it

Update Container Tag

Deprecated by the provider: the legacy v3 API shuts down December 31, 2026. Use the v5 namespace settings API (PATCH /ns/{namespace}) for new integrations. Update an existing container tag's display name, document processing context, memory filesystem paths, or tag-level profile buckets. Omitted fields remain unchanged; explicit nulls are sent for fields that support them.

ActionTry it

Update Document

Update the content, metadata, container, or processing configuration of one existing document. When metadata is supplied, it completely replaces the document's metadata, so omitted metadata keys are removed.

ActionTry it

Update Memory

Deprecated by the provider; v3/v4 APIs shut down on December 31, 2026. Use v5 namespace document updates for document-backed memory changes in new integrations. Update a memory by ID or exact content within a container, creating a new version. The original memory is preserved with isLatest=false. Omitted metadata and expiry inherit from the previous version; explicit null forgetAfter clears the expiry.

ActionTry it

Update Namespace

Update the background context used during ingestion and memory formation in an existing namespace. Omit supportingContext to leave it unchanged, or explicitly set it to null to clear it. Requires write access.

ActionTry it

Update Namespace Document

Partially update an existing document in an isolated namespace without changing its stable ID. Supplied content replaces canonical content and is reprocessed; omitted fields remain unchanged. Returns the document ID and processing state, not a guarantee of completed processing.

ActionTry it

Update Namespace File

Partially update a file-backed document in an isolated namespace. Supply a file to replace canonical content, or update metadata and processing context without a file. Omitted metadata and processing context remain unchanged. Returns the document ID and current processing state, not a guarantee of completed processing.

ActionTry it

Update Organization

Update organization-wide background that guides content interpretation and memory formation across every namespace. Provide organizationalContext as a nonempty string to set it, or null to remove the existing context. Requires admin access.

ActionTry it

Update Settings

Deprecated by the provider: the legacy v3 API shuts down December 31, 2026. Use v5 organization and namespace settings APIs for new integrations. Update the connected organization's settings, including filtering, custom connector OAuth credentials, chunk size, and profile buckets. Omitted fields are unchanged; explicit nulls are sent to the provider. This changes live organization configuration. Connector client secrets are accepted as input but omitted from the response.

ActionTry it

Upload Document File

Deprecated by the provider: this legacy endpoint shuts down December 31, 2026. Use the v5 namespace file upload endpoint POST /ns/{namespace}/document/file for new integrations. Upload a file as a document for processing, with optional container tags, metadata, and extraction settings. The returned status reports processing state and does not guarantee processing has finished.

ActionTry it

Upload Namespace File

Upload a file into an isolated Supermemory namespace to form searchable knowledge and learned memory. Ingestion returns once safely queued; extraction and memory formation continue asynchronously. The returned status is the document's current processing state, not a guarantee that processing has completed. Use task_type=superrag for retrieval without generating memories.

ActionTry it

How the Supermemory integration works

The Supermemory integration connects your Dench AI CRM directly to Supermemory, so agents can read and act on your Supermemory data as part of everyday work — answering questions in chat, keeping your CRM in sync, and running automations without anyone copying data between tools.

86 actions are available for agents to invoke on your behalf. Every call runs through Supermemory's own authorization, scoped to the account you connect.

Set up Supermemory in Dench

  1. 1

    Sign in to your Dench workspace and open Integrations.

  2. 2

    Find Supermemory and click Connect — you'll authorize access through Supermemory's own sign-in flow. No API keys or code required.

  3. 3

    Ask an agent to use Supermemory in chat, or call it from an automation.

  4. 4

    Manage or disconnect the connection any time from workspace settings.

Frequently asked questions

How does the Supermemory integration work with Dench?

The Dench Supermemory integration connects your AI CRM to Supermemory, so AI agents can work with your Supermemory data as part of chats, automations, and CRM workflows. You connect your account once, and every agent in your workspace can use it — governed by your workspace permissions.

What actions can AI agents perform with Supermemory via Dench?

The Supermemory integration currently exposes 86 actions, including Add Document, Add Documents, Add Namespace Document, Add Namespace Documents, Add or Update Namespace Profile Buckets, and Bulk Delete Documents. Agents invoke them on your behalf from chat or from automations.

Do I need to write code to connect Supermemory to Dench?

No. You connect Supermemory from your Dench workspace using Supermemory's own sign-in and authorization flow — no API keys to copy, no glue code to maintain.

Is the Supermemory integration secure?

Connections are authorized through Supermemory's own authentication flow, and Dench stores only the authorization needed to act on your behalf. You can review and disconnect the Supermemory connection from your workspace settings at any time.

Supermemory | Dench AI CRM