Skip to content
Notice This app is in Beta Testing We are still testing Record Sender, so features may change.
Sign in

Retention and legal holds — API reference

Retention policies (delete or archive mail after N days) and legal holds with their exports (docs/retention.md).

← All groups
GET /api/v1/legal-holds

Legal holds

Needs `legal_hold:manage` (the superadmin and security administrators by default).

Scope: account · paginated · retention.holds

ParameterInTypeDescription
cursorquerystringThe `next_cursor` of the previous page
limitqueryintegerPage size
Responses 200 · 401 · 403 · 429

200 Success

has_more boolean
holds * [LegalHold]
fields

LegalHold

covers object
fields
personal integer In personal mailboxes
total integer
from_date string | null
id * string (uuid)
inserted_at string (date-time)
mailbox_ids [string (uuid)]
matter string | null
name string
query string | null
released_at string | null
status "active" | "released"
to_date string | null
user_ids [string (uuid)]
next_cursor string | null Pass as `cursor` for the next page; null on the last

401 Problem details (401)

403 Problem details (403)

429 Problem details (429)

POST /api/v1/legal-holds

Place a legal hold

Needs `legal_hold:manage` (the superadmin and security administrators by default). Held mail is kept from deletion by people, retention and emptying Trash.

Scope: account · Idempotency-Key · retention.create_hold

Request body application/json
file_space_ids [string (uuid)]
from_date string | null
mailbox_ids [string (uuid)]
matter string | null The case or matter
name * string
query string | null Search query narrowing the hold
to_date string | null
user_ids [string (uuid)] People whose mail is held
Responses 201 · 401 · 402 · 403 · 409 · 422 · 429

201 Success

hold * LegalHold
fields

LegalHold

covers object
fields
personal integer In personal mailboxes
total integer
from_date string | null
id * string (uuid)
inserted_at string (date-time)
mailbox_ids [string (uuid)]
matter string | null
name string
query string | null
released_at string | null
status "active" | "released"
to_date string | null
user_ids [string (uuid)]

401 Problem details (401)

402 Problem details (402)

403 Problem details (403)

409 Problem details (409)

422 Problem details (422)

429 Problem details (429)

GET /api/v1/legal-holds/{id}

A legal hold with its exports

Needs `legal_hold:manage` (the superadmin and security administrators by default).

Scope: account · retention.hold

ParameterInTypeDescription
id *pathstring (uuid)
Responses 200 · 401 · 403 · 404 · 429

200 Success

exports [LegalHoldExport]
fields

LegalHoldExport

bytes integer | null
error string | null
finished_at string | null
format "mbox" | "eml_zip"
hold_id string (uuid)
id * string (uuid)
inserted_at string (date-time)
messages integer | null
personal_preserved integer | null Personal-mailbox messages preserved but not exported
status "running" | "done" | "failed"
hold * LegalHold
fields

LegalHold

covers object
fields
personal integer In personal mailboxes
total integer
from_date string | null
id * string (uuid)
inserted_at string (date-time)
mailbox_ids [string (uuid)]
matter string | null
name string
query string | null
released_at string | null
status "active" | "released"
to_date string | null
user_ids [string (uuid)]

401 Problem details (401)

403 Problem details (403)

404 Problem details (404)

429 Problem details (429)

PATCH /api/v1/legal-holds/{id}

Change a legal hold

Needs `legal_hold:manage` (the superadmin and security administrators by default).

Scope: account · retention.update_hold

ParameterInTypeDescription
id *pathstring (uuid)
Request body application/json
file_space_ids [string (uuid)]
from_date string | null
mailbox_ids [string (uuid)]
matter string | null The case or matter
name string
query string | null Search query narrowing the hold
to_date string | null
user_ids [string (uuid)] People whose mail is held
Responses 200 · 401 · 402 · 403 · 404 · 422 · 429

200 Success

hold * LegalHold
fields

LegalHold

covers object
fields
personal integer In personal mailboxes
total integer
from_date string | null
id * string (uuid)
inserted_at string (date-time)
mailbox_ids [string (uuid)]
matter string | null
name string
query string | null
released_at string | null
status "active" | "released"
to_date string | null
user_ids [string (uuid)]

401 Problem details (401)

402 Problem details (402)

403 Problem details (403)

404 Problem details (404)

422 Problem details (422)

429 Problem details (429)

POST /api/v1/legal-holds/{id}/exports

Export what a hold covers

Needs `legal_hold:manage` (the superadmin and security administrators by default). Built in the background (202); poll the export. Mail in personal mailboxes is preserved by the hold but not exported (counted in `personal_preserved`; see eDiscovery); sign-in and security mail never is.

Scope: account · Idempotency-Key · retention.create_export

ParameterInTypeDescription
id *pathstring (uuid)
Request body application/json
format "mbox" | "eml_zip" Default mbox
Responses 202 · 401 · 402 · 403 · 404 · 409 · 422 · 429

202 Success

export * LegalHoldExport
fields

LegalHoldExport

bytes integer | null
error string | null
finished_at string | null
format "mbox" | "eml_zip"
hold_id string (uuid)
id * string (uuid)
inserted_at string (date-time)
messages integer | null
personal_preserved integer | null Personal-mailbox messages preserved but not exported
status "running" | "done" | "failed"

401 Problem details (401)

402 Problem details (402)

403 Problem details (403)

404 Problem details (404)

409 Problem details (409)

422 Problem details (422)

429 Problem details (429)

GET /api/v1/legal-holds/{id}/exports/{export_id}

A hold export's state, or its file

Needs `legal_hold:manage` (the superadmin and security administrators by default). With `download=1` (a `done` export) the answer is the export file itself (`application/octet-stream` or its own type) instead of JSON.

Scope: account · retention.export

ParameterInTypeDescription
id *pathstring (uuid)
export_id *pathstring (uuid)The export
downloadquery"1" | "true"Send the file
Responses 200 · 401 · 403 · 404 · 429

200 Success

export * LegalHoldExport
fields

LegalHoldExport

bytes integer | null
error string | null
finished_at string | null
format "mbox" | "eml_zip"
hold_id string (uuid)
id * string (uuid)
inserted_at string (date-time)
messages integer | null
personal_preserved integer | null Personal-mailbox messages preserved but not exported
status "running" | "done" | "failed"

401 Problem details (401)

403 Problem details (403)

404 Problem details (404)

429 Problem details (429)

POST /api/v1/legal-holds/{id}/release

Release a legal hold

Needs `legal_hold:manage` (the superadmin and security administrators by default).

Scope: account · Idempotency-Key · retention.release_hold

ParameterInTypeDescription
id *pathstring (uuid)
Responses 200 · 401 · 402 · 403 · 404 · 409 · 422 · 429

200 Success

hold * LegalHold
fields

LegalHold

covers object
fields
personal integer In personal mailboxes
total integer
from_date string | null
id * string (uuid)
inserted_at string (date-time)
mailbox_ids [string (uuid)]
matter string | null
name string
query string | null
released_at string | null
status "active" | "released"
to_date string | null
user_ids [string (uuid)]

401 Problem details (401)

402 Problem details (402)

403 Problem details (403)

404 Problem details (404)

409 Problem details (409)

422 Problem details (422)

429 Problem details (429)

GET /api/v1/retention/policies

Retention policies with what each would touch now

Needs `retention:manage` (the superadmin and security administrators by default).

Scope: account · paginated · retention.policies

ParameterInTypeDescription
cursorquerystringThe `next_cursor` of the previous page
limitqueryintegerPage size
Responses 200 · 401 · 403 · 429

200 Success

has_more boolean
next_cursor string | null Pass as `cursor` for the next page; null on the last
policies * [RetentionPolicy]
fields

RetentionPolicy

action "delete" | "archive"
after_days integer
enabled boolean
folder_role string | null
id * string (uuid)
label string | null
last_result object | null
last_run_at string | null
name string
preview object Listing only
fields
held integer Kept by a legal hold
matching integer Messages it would act on now
scope_id string | null
scope_type "account" | "workspace" | "mailbox"

401 Problem details (401)

403 Problem details (403)

429 Problem details (429)

POST /api/v1/retention/policies

Create a retention policy

Needs `retention:manage` (the superadmin and security administrators by default). Never touches mail a legal hold covers, sign-in and security mail, mail waiting to be sent, or drafts unless the policy names Drafts. Enabled policies run hourly.

Scope: account · Idempotency-Key · retention.create_policy

Request body application/json
action * "delete" | "archive"
after_days * integer Age in days
enabled boolean
folder_role "inbox" | "sent" | "archive" | "spam" | "trash" | "drafts" | "snoozed" | "custom" | nil
label string | null Only mail with this label
name * string
scope_id string | null The workspace or mailbox (not for `account`)
scope_type * "account" | "workspace" | "mailbox" What the policy covers; the most specific enabled policy wins
Responses 201 · 401 · 402 · 403 · 409 · 422 · 429

201 Success

policy * RetentionPolicy
fields

RetentionPolicy

action "delete" | "archive"
after_days integer
enabled boolean
folder_role string | null
id * string (uuid)
label string | null
last_result object | null
last_run_at string | null
name string
preview object Listing only
fields
held integer Kept by a legal hold
matching integer Messages it would act on now
scope_id string | null
scope_type "account" | "workspace" | "mailbox"

401 Problem details (401)

402 Problem details (402)

403 Problem details (403)

409 Problem details (409)

422 Problem details (422)

429 Problem details (429)

DELETE /api/v1/retention/policies/{id}

Delete a retention policy

Needs `retention:manage` (the superadmin and security administrators by default).

Scope: account · retention.delete_policy

ParameterInTypeDescription
id *pathstring (uuid)
Responses 204 · 401 · 402 · 403 · 404 · 422 · 429

204 Done (no content)

401 Problem details (401)

402 Problem details (402)

403 Problem details (403)

404 Problem details (404)

422 Problem details (422)

429 Problem details (429)

PATCH /api/v1/retention/policies/{id}

Change a retention policy

Needs `retention:manage` (the superadmin and security administrators by default).

Scope: account · retention.update_policy

ParameterInTypeDescription
id *pathstring (uuid)
Request body application/json
action "delete" | "archive"
after_days integer Age in days
enabled boolean
folder_role "inbox" | "sent" | "archive" | "spam" | "trash" | "drafts" | "snoozed" | "custom" | nil
label string | null Only mail with this label
name string
scope_id string | null The workspace or mailbox (not for `account`)
scope_type "account" | "workspace" | "mailbox" What the policy covers; the most specific enabled policy wins
Responses 200 · 401 · 402 · 403 · 404 · 422 · 429

200 Success

policy * RetentionPolicy
fields

RetentionPolicy

action "delete" | "archive"
after_days integer
enabled boolean
folder_role string | null
id * string (uuid)
label string | null
last_result object | null
last_run_at string | null
name string
preview object Listing only
fields
held integer Kept by a legal hold
matching integer Messages it would act on now
scope_id string | null
scope_type "account" | "workspace" | "mailbox"

401 Problem details (401)

402 Problem details (402)

403 Problem details (403)

404 Problem details (404)

422 Problem details (422)

429 Problem details (429)

POST /api/v1/retention/policies/{id}/run

Run a retention policy now

Needs `retention:manage` (the superadmin and security administrators by default). Audit-logged; deleted mail leaves sync tombstones.

Scope: account · Idempotency-Key · retention.run_policy

ParameterInTypeDescription
id *pathstring (uuid)
Responses 200 · 401 · 402 · 403 · 404 · 409 · 422 · 429

200 Success

result * object
fields
action "delete" | "archive"
affected integer
held integer Kept by a legal hold
ran_at string (date-time)

401 Problem details (401)

402 Problem details (402)

403 Problem details (403)

404 Problem details (404)

409 Problem details (409)

422 Problem details (422)

429 Problem details (429)