MemorySync
API Reference

Remove User

Soft-delete a user with optional email anonymization. The handler revokes sessions, marks the row as removed, and (when anonymize is true) replaces the email with a deterministic placeholder so the audit trail stays intact while PII is wiped.
DELETE/api/v1/users/{user_id}

Authentication

Accepts a JWT bearer token (Authorization: Bearer eyJ…) or an API key (X-API-Key: ms_live_…). API-key callers should send X-Project-ID unless the key is project-locked. Cross-tenant operators must send X-Tenant-ID.

Path parameters

FieldTypeRequiredDescription
user_idintegerrequiredUser to remove. Cannot be the organisation owner.

Query parameters

FieldTypeRequiredDescription
organization_idintegeroptionalOrganisation context.
actor_idintegeroptionalActor performing the removal.

Request body

FieldTypeRequiredDescription
reasonstringrequiredStored on the audit row.
anonymizebooleanoptionalDefault false. When true, email becomes removed-{user_id}@anon.invalid.
request.json
{
"reason": "user_request_gdpr",
"anonymize": true
}

Response

Returns 200 OK with the following body.

FieldTypeRequiredDescription
user_idintegeroptionalRemoved user id.
statusstringoptionalAlways removed.
anonymizedbooleanoptionalWhether email was anonymised.
removed_atstringoptionalRFC 3339 UTC.
200.json
{
"user_id": 4271,
"status": "removed",
"anonymized": true,
"removed_at": "2026-05-04T12:30:11Z"
}

Errors

StatusCodeDescription
400validation_errorBody or query failed schema validation. The error includes the offending field name.
401unauthenticatedMissing or invalid bearer token / API key.
403forbiddenAuthenticated principal lacks the required scope, role, or project access.
404not_foundTarget resource does not exist or is not visible to the calling tenant.
429rate_limitedPer-IP or per-route limit exceeded. Respect the Retry-After header.
500internal_errorUnhandled server error. Quote the request_id when contacting support.

Examples

cURL
curl -X DELETE https://api.memorysync.io/api/v1/users/EXAMPLE_ID \
-H "Authorization: Bearer $MEMORYSYNC_KEY" \
-H "Content-Type: application/json" \
-d '{
"reason": "user_request_gdpr",
"anonymize": true
}'
javascript
import { MemorySync } from 'memorysync'
const client = new MemorySync({ apiKey: process.env.MEMORYSYNC_KEY })
const result = await client.request({
method: 'DELETE',
path: '/api/v1/users/EXAMPLE_ID',
body: {
"reason": "user_request_gdpr",
"anonymize": true
},
})
console.log(result)
python
from memorysync import Client
client = Client(api_key=os.environ["MEMORYSYNC_KEY"])
result = client.request(
method="DELETE",
path="/api/v1/users/EXAMPLE_ID",
json={
"reason": "user_request_gdpr",
"anonymize": true
},
)
print(result)

Behavior & notes

Idempotent through Idempotency-Key on writes. Replays within 24h return the original response unchanged.