# Delete builder cache


[API catalog](/reference/api/) · [Docker Engine overview](/reference/api/engine/version/v1.57/) · [Product manual](https://docs.docker.com/engine/) · [OpenAPI specification](/reference/api/engine/version/v1.57.yaml)

API version: 1.57





`POST /build/prune`



## Connection and access

[API connection and authentication guidance](/reference/api/engine/version/v1.57/#connection)


Server: `/v1.57`

Effective security: alternatives are OR; schemes within an alternative are AND. An empty array declares no HTTP authentication requirement.

```json
null
```

## Example request

Replace placeholders and provide the required credentials or request body.

```console
curl \
  --request POST \
  --unix-socket "${DOCKER_SOCKET:-/var/run/docker.sock}" \
  --header 'Accept: application/json' \
  'http://localhost/v1.57/build/prune'
```



## Parameters

### reserved-space

Location: query. Required: no.

Amount of disk space in bytes to keep for cache

```json
{
  "description": "Amount of disk space in bytes to keep for cache",
  "in": "query",
  "name": "reserved-space",
  "pointer": "/paths/~1build~1prune/post/parameters/0",
  "schema": {
    "format": "int64",
    "type": "integer"
  }
}
```

### max-used-space

Location: query. Required: no.

Maximum amount of disk space allowed to keep for cache

```json
{
  "description": "Maximum amount of disk space allowed to keep for cache",
  "in": "query",
  "name": "max-used-space",
  "pointer": "/paths/~1build~1prune/post/parameters/1",
  "schema": {
    "format": "int64",
    "type": "integer"
  }
}
```

### min-free-space

Location: query. Required: no.

Target amount of free disk space after pruning

```json
{
  "description": "Target amount of free disk space after pruning",
  "in": "query",
  "name": "min-free-space",
  "pointer": "/paths/~1build~1prune/post/parameters/2",
  "schema": {
    "format": "int64",
    "type": "integer"
  }
}
```

### all

Location: query. Required: no.

Remove all types of build cache

```json
{
  "description": "Remove all types of build cache",
  "in": "query",
  "name": "all",
  "pointer": "/paths/~1build~1prune/post/parameters/3",
  "schema": {
    "type": "boolean"
  }
}
```

### filters

Location: query. Required: no.

A JSON encoded value of the filters (a `map[string][]string`) to
process on the list of build cache objects.

Available filters:

- `until=<timestamp>` remove cache older than `<timestamp>`. The `<timestamp>` can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed relative to the daemon's local time.
- `id=<id>`
- `parent=<id>`
- `type=<string>`
- `description=<string>`
- `inuse`
- `shared`
- `private`


```json
{
  "description": "A JSON encoded value of the filters (a `map[string][]string`) to\nprocess on the list of build cache objects.\n\nAvailable filters:\n\n- `until=\u003ctimestamp\u003e` remove cache older than `\u003ctimestamp\u003e`. The `\u003ctimestamp\u003e` can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed relative to the daemon's local time.\n- `id=\u003cid\u003e`\n- `parent=\u003cid\u003e`\n- `type=\u003cstring\u003e`\n- `description=\u003cstring\u003e`\n- `inuse`\n- `shared`\n- `private`\n",
  "in": "query",
  "name": "filters",
  "pointer": "/paths/~1build~1prune/post/parameters/4",
  "schema": {
    "type": "string"
  }
}
```

## Request and responses

### Response 200 application/json

No error


Schema:

```json
{
  "properties": {
    "CachesDeleted": {
      "items": {
        "description": "ID of build cache object",
        "type": "string"
      },
      "type": "array"
    },
    "SpaceReclaimed": {
      "description": "Disk space reclaimed in bytes",
      "format": "int64",
      "type": "integer"
    }
  },
  "title": "BuildPruneResponse",
  "type": "object"
}
```










### Response 500 application/json

Server error


Schema:

```json
{
  "$ref": "#/components/schemas/ErrorResponse"
}
```









Schema example:
```json
{
  "message": "Something went wrong."
}
```


## Complete operation contract

```json
{
  "operationId": "BuildPrune",
  "parameters": [
    {
      "description": "Amount of disk space in bytes to keep for cache",
      "in": "query",
      "name": "reserved-space",
      "schema": {
        "format": "int64",
        "type": "integer"
      }
    },
    {
      "description": "Maximum amount of disk space allowed to keep for cache",
      "in": "query",
      "name": "max-used-space",
      "schema": {
        "format": "int64",
        "type": "integer"
      }
    },
    {
      "description": "Target amount of free disk space after pruning",
      "in": "query",
      "name": "min-free-space",
      "schema": {
        "format": "int64",
        "type": "integer"
      }
    },
    {
      "description": "Remove all types of build cache",
      "in": "query",
      "name": "all",
      "schema": {
        "type": "boolean"
      }
    },
    {
      "description": "A JSON encoded value of the filters (a `map[string][]string`) to\nprocess on the list of build cache objects.\n\nAvailable filters:\n\n- `until=\u003ctimestamp\u003e` remove cache older than `\u003ctimestamp\u003e`. The `\u003ctimestamp\u003e` can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed relative to the daemon's local time.\n- `id=\u003cid\u003e`\n- `parent=\u003cid\u003e`\n- `type=\u003cstring\u003e`\n- `description=\u003cstring\u003e`\n- `inuse`\n- `shared`\n- `private`\n",
      "in": "query",
      "name": "filters",
      "schema": {
        "type": "string"
      }
    }
  ],
  "responses": {
    "200": {
      "content": {
        "application/json": {
          "schema": {
            "properties": {
              "CachesDeleted": {
                "items": {
                  "description": "ID of build cache object",
                  "type": "string"
                },
                "type": "array"
              },
              "SpaceReclaimed": {
                "description": "Disk space reclaimed in bytes",
                "format": "int64",
                "type": "integer"
              }
            },
            "title": "BuildPruneResponse",
            "type": "object"
          }
        }
      },
      "description": "No error"
    },
    "500": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "Server error"
    }
  },
  "summary": "Delete builder cache",
  "tags": [
    "Image"
  ]
}
```

## Referenced schemas

- [#/components/schemas/ErrorResponse](/reference/api/engine/version/v1.57/schemas/ErrorResponse/)




