Delete logs

Add MCP server to your AI tool

Allow AI tools and LLMs to interact with the API documentation portal through MCP.

MCP server URL

https://openapi.logto.io/mcp

Standard setup for AI tools providing an mcp.json file

mcp.json
{
  "Logto API references MCP server": {
    "url": "https://openapi.logto.io/mcp"
  }
}

Close
DELETE /api/logs

Delete log rows in bounded batches.

start_time / end_time carry the same inclusive semantics as GET /api/logs: a row is deleted when its createdAt falls in [start_time, end_time], at millisecond granularity. Note that this operation removes every log row in that window, while GET /api/logs returns audit logs only.

Webhook delivery logs (TriggerHook.*) share the logs table but are read through GET /api/hooks/{id}/recent-logs rather than by GET /api/logs, so deletedCount can exceed the number of rows an export returned. A window covering the last 24 hours also removes the deliveries counted by the execution stats on GET /api/hooks.

end_time is required, so a bare DELETE /api/logs never means "delete everything". end_time must not be in the future and is rejected with 400 otherwise; a common cause is passing microseconds or nanoseconds instead of milliseconds, or a miscomputed timezone offset. Passing seconds instead yields a boundary in the past, which deletes nothing rather than deleting too much.

This operation is irreversible and reachable by any Management API token. Each call deletes at most limit rows in a single statement and reports hasMore. Keep both bounds fixed across calls and repeat while hasMore is true; recomputing a boundary between calls would skip rows. Run one cleanup at a time: a concurrent purge can make hasMore under-report.

Performance

DELETE marks rows dead and leaves index cleanup to autovacuum, so writes are dominated by heap tuples and WAL. The statement is matched on ctid, so the outer side is a Tid Scan over exactly limit rows and the inner select reads those row ids from logs__created_at_id; expect the cost of a call to track limit rather than the size of the table. Measure with EXPLAIN (ANALYZE, BUFFERS) on your own data before running a large purge.

Freed space is reused by later inserts but the table file does not shrink, so disk usage will not drop immediately after a purge.

Query parameters

  • end_time string Required

    Inclusive upper bound on createdAt, in unix milliseconds, with the same semantics as GET /api/logs. Only log rows with createdAt <= end_time are deleted. Returns 400 if the value is in the future.

  • start_time string

    Inclusive lower bound on createdAt, in unix milliseconds, with the same semantics as GET /api/logs. Only log rows with createdAt >= start_time are deleted. Omit to purge everything up to end_time. Returns 400 if it is after end_time.

  • limit string

    Maximum rows deleted by this call. Default 1000, maximum 10000. Returns 400 for values outside that range.

Responses

  • 200 application/json

    Summary of the rows deleted by this call. deletedCount is the number of log rows deleted, and deletedRange is an optional { oldest, newest } object holding the unix-millisecond timestamps of the deleted rows; it is omitted when nothing was deleted. hasMore is true when deletedCount equals limit, meaning this batch was full rather than that more rows definitely exist, so the caller should repeat the request with the same bounds.

    Hide response attributes Show response attributes object
    • deletedCount number Required
    • hasMore boolean Required
    • deletedRange object
      Hide deletedRange attributes Show deletedRange attributes object
      • oldest number Required
      • newest number Required
  • 400

    Returned when end_time is missing, empty, negative, outside the safe integer range, in the future, or not a finite number; when start_time is malformed or after end_time; or when limit is outside 1..10000.

  • 401

    Unauthorized

  • 403

    Forbidden

DELETE /api/logs
curl \
 --request DELETE 'https://[tenant_id].logto.app/api/logs?end_time=string' \
 --header "Authorization: Bearer $ACCESS_TOKEN"
Response examples (200)
{
  "deletedCount": 42.0,
  "hasMore": true,
  "deletedRange": {
    "oldest": 42.0,
    "newest": 42.0
  }
}