Skip to content

Preview auto-delete rules

Viewing v2, the current version

POST
/v2/workspaces/{workspace_id}/storage/auto-delete/preview
curl --request POST \
--url https://api.app.layer.ai/api/v2/workspaces/:workspace_id/storage/auto-delete/preview \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"rules": [
{
"older_than_days": 0,
"origin": "generated",
"content_categories": [
"image"
],
"keep_labeled": true,
"keep_in_folder": true,
"keep_liked": true,
"keep_pinned": true
}
]
}'

Unchanged from v1. This endpoint’s documented request and response schemas are identical in v1 and v2 — change the /v1 prefix to /v2. Schema equality is not a promise about behavior, so keep your usual smoke tests.

What the given rules would delete from the workspace if they ran now, with the largest of those files. Deletes nothing. Enterprise only. Requires settings admin.

workspace_id
required
Workspace ID

ID of the workspace that owns the resource.

string format: uuid

ID of the workspace that owns the resource.

Idempotency-Key
string
<= 255 characters

Opaque key making a retry of this request return the first result. A 2xx response is replayed for 24 hours with Idempotent-Replayed: true. A 4xx releases the key. A 5xx, or a request still running, holds the key for 120 seconds, during which a retry gets 409; after that a retry executes again. The key covers the method, path, query, and byte-identical body it was first used with; reusing it for a different request is rejected with 422. Protection is best effort: if the key store is unavailable, or a record is lost early, a retry can execute again even after an earlier 409. See the Idempotency section of the API description.

Media typeapplication/json
AutoDeletePreviewInput
object
rules
required
Rules

The rules to preview.

Array<object>
<= 10 items
AutoDeleteRuleIO
object
older_than_days
required
Older Than Days

Delete files created at least this many days ago (7 or more).

integer
>= 7 <= 3650
origin
Any of:
StoredFileOrigin

Whether a file is the output of a generation, or something a person put in the workspace.

string
Allowed values: generated uploaded
content_categories
Content Categories

Only these content categories; every category when empty.

Array<string>
Allowed values: image video mesh audio pose safetensors playable spine font world pbr_materials landing_page other
keep_labeled
Keep Labeled

Keep files with a label.

boolean
default: true
keep_in_folder
Keep In Folder

Keep files filed in a folder.

boolean
default: true
keep_liked
Keep Liked

Keep files someone liked.

boolean
default: true
keep_pinned
Keep Pinned

Keep files someone pinned.

boolean
default: true

Successful Response

Media typeapplication/json
AutoDeletePreviewOutput
object
files
required
Files

Files the rules would delete now.

integer
bytes
required
Bytes

Bytes those files hold.

integer
is_at_least
required
Is At Least

Whether counting stopped at 20,000 files, so the run would delete at least this many.

boolean
sample
required
Sample

The largest of those files.

Array<object>
StoredFileOutput
object
file_id
required
File ID

ID of the file.

string format: uuid
name
required
Name

The file’s name.

string
content_type
required
Content Type

The file’s MIME type.

string
content_category
required
FileContentCategory

What kind of asset the file is.

string
Allowed values: image video mesh audio pose safetensors playable spine font world pbr_materials landing_page other
origin
required
StoredFileOrigin

Whether a generation produced the file or a person uploaded it.

string
Allowed values: generated uploaded
size_bytes
required
Size Bytes

Bytes the file holds.

integer
created_at
required
Created At

When the file was created.

string format: date-time
created_by_name
required
Created By Name

Who created the file, when known.

string
nullable
deleted_at
required
Deleted At

When the file was deleted; set in the trash only.

string format: date-time
nullable
deleted_by_name
required
Deleted By Name

Who deleted the file; null for an automatic delete.

string
nullable
Example
{
"sample": [
{
"content_category": "image",
"origin": "generated"
}
]
}

Unauthenticated — missing or invalid Bearer token.

Media typeapplication/problem+json
object
type
required
string
title
required
string
status
required
integer
detail
required
string
error_code
required

Machine-readable error code: the last path segment of type.

string
field

The request field the error is about, by its name in the body (on a tool run, in input), on the errors that name one: so far the value a Layer tool fixes on an INFERENCE_TOOL_PIN_MISMATCH, and the scale factor on an INFERENCE_TOOL_UPSCALE_COPIES_SOURCE. Absent otherwise, even when detail names a field.

string
Example
{
"type": "https://api.layer.ai/errors/ERROR_CODE",
"title": "Error Title",
"status": 400,
"detail": "Human-readable description.",
"error_code": "ERROR_CODE",
"field": "tileability"
}

Forbidden — insufficient permissions, or the access token lacks the scope the operation requires.

Media typeapplication/problem+json
object
type
required
string
title
required
string
status
required
integer
detail
required
string
error_code
required

Machine-readable error code: the last path segment of type.

string
field

The request field the error is about, by its name in the body (on a tool run, in input), on the errors that name one: so far the value a Layer tool fixes on an INFERENCE_TOOL_PIN_MISMATCH, and the scale factor on an INFERENCE_TOOL_UPSCALE_COPIES_SOURCE. Absent otherwise, even when detail names a field.

string
Example
{
"type": "https://api.layer.ai/errors/ERROR_CODE",
"title": "Error Title",
"status": 400,
"detail": "Human-readable description.",
"error_code": "ERROR_CODE",
"field": "tileability"
}

Resource not found.

Media typeapplication/problem+json
object
type
required
string
title
required
string
status
required
integer
detail
required
string
error_code
required

Machine-readable error code: the last path segment of type.

string
field

The request field the error is about, by its name in the body (on a tool run, in input), on the errors that name one: so far the value a Layer tool fixes on an INFERENCE_TOOL_PIN_MISMATCH, and the scale factor on an INFERENCE_TOOL_UPSCALE_COPIES_SOURCE. Absent otherwise, even when detail names a field.

string
Example
{
"type": "https://api.layer.ai/errors/ERROR_CODE",
"title": "Error Title",
"status": 400,
"detail": "Human-readable description.",
"error_code": "ERROR_CODE",
"field": "tileability"
}

The outcome of the request with this Idempotency-Key is not known yet: it is still running, or it failed without a stored response. Retry after the number of seconds in Retry-After.

Media typeapplication/problem+json
object
type
required
string
title
required
string
status
required
integer
detail
required
string
error_code
required

Machine-readable error code: the last path segment of type.

string
field

The request field the error is about, by its name in the body (on a tool run, in input), on the errors that name one: so far the value a Layer tool fixes on an INFERENCE_TOOL_PIN_MISMATCH, and the scale factor on an INFERENCE_TOOL_UPSCALE_COPIES_SOURCE. Absent otherwise, even when detail names a field.

string
Example
{
"type": "https://api.layer.ai/errors/ERROR_CODE",
"title": "Error Title",
"status": 400,
"detail": "Human-readable description.",
"error_code": "ERROR_CODE",
"field": "tileability"
}

Invalid input parameters, or an Idempotency-Key reused for a different request.

Media typeapplication/problem+json
object
type
required
string
title
required
string
status
required
integer
detail
required
string
error_code
required

Machine-readable error code: the last path segment of type.

string
field

The request field the error is about, by its name in the body (on a tool run, in input), on the errors that name one: so far the value a Layer tool fixes on an INFERENCE_TOOL_PIN_MISMATCH, and the scale factor on an INFERENCE_TOOL_UPSCALE_COPIES_SOURCE. Absent otherwise, even when detail names a field.

string
Example
{
"type": "https://api.layer.ai/errors/ERROR_CODE",
"title": "Error Title",
"status": 400,
"detail": "Human-readable description.",
"error_code": "ERROR_CODE",
"field": "tileability"
}

Rate limited — retry after the number of seconds in Retry-After.

Media typeapplication/problem+json
object
type
required
string
title
required
string
status
required
integer
detail
required
string
error_code
required

Machine-readable error code: the last path segment of type.

string
field

The request field the error is about, by its name in the body (on a tool run, in input), on the errors that name one: so far the value a Layer tool fixes on an INFERENCE_TOOL_PIN_MISMATCH, and the scale factor on an INFERENCE_TOOL_UPSCALE_COPIES_SOURCE. Absent otherwise, even when detail names a field.

string
Example
{
"type": "https://api.layer.ai/errors/ERROR_CODE",
"title": "Error Title",
"status": 400,
"detail": "Human-readable description.",
"error_code": "ERROR_CODE",
"field": "tileability"
}

Internal server error.

Media typeapplication/problem+json
object
type
required
string
title
required
string
status
required
integer
detail
required
string
error_code
required

Machine-readable error code: the last path segment of type.

string
field

The request field the error is about, by its name in the body (on a tool run, in input), on the errors that name one: so far the value a Layer tool fixes on an INFERENCE_TOOL_PIN_MISMATCH, and the scale factor on an INFERENCE_TOOL_UPSCALE_COPIES_SOURCE. Absent otherwise, even when detail names a field.

string
Example
{
"type": "https://api.layer.ai/errors/ERROR_CODE",
"title": "Error Title",
"status": 400,
"detail": "Human-readable description.",
"error_code": "ERROR_CODE",
"field": "tileability"
}