# Delete caches by key

> Delete every cache entry whose key is exactly key, or only ref's when you give ref.

<div class="g1t-endpoint"><span class="g1t-method" data-method="delete">DELETE</span><code>/repos/{owner}/{name}/actions/caches</code></div>

Answers with the entries deleted, in list_caches' shape. Their bytes go at once, and a run that restores the key finds nothing until one saves it again. Needs the Write role.

The key is matched exactly. Without `ref`, the key's entries on every ref are deleted.

- **Authentication:** Required. Send an [access token](/reference/api/#authentication) as `Authorization: Bearer`.
- **MCP tool:** [`workflow`](/reference/mcp/#workflow) with `action` `delete_caches`, and the same inputs
- **Scope:** An access token needs [`workflows:write`](/guides/authentication/#scopes).

## Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `owner` | string | Yes | The workspace that owns the repository. |
| `name` | string | Yes | The repository's name. |

## Body parameters

Send a JSON object. Names are `snake_case`, as in responses; the `camelCase` spelling is accepted too.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `key` | string | Yes | The key, exactly. |
| `ref` | string | No | A full ref, e.g. refs/heads/main or refs/pull/7/merge. |

## Example request

```sh
curl -X DELETE "https://api.g1t.sh/repos/flagon-io/g1t/actions/caches?key=cargo-test-Linux-rustc-1.99.0-5f1c3a9e7b2d&ref=refs%2Fpull%2F412%2Fmerge" \
  -H "Authorization: Bearer $G1T_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "key": "key"
  }'
```

## Example response

A successful request answers `200` with:

```json
{
  "total_count": 1,
  "actions_caches": [
    {
      "id": 9102,
      "key": "cargo-test-Linux-rustc-1.99.0-5f1c3a9e7b2d",
      "ref": "refs/pull/412/merge",
      "version": "",
      "size_in_bytes": 702545920,
      "created_at": "2026-10-12T11:02:44.930Z",
      "last_accessed_at": "2026-10-12T11:02:44.930Z"
    }
  ]
}
```

## Errors

A failed request answers with one of these statuses and a body like `{"error": {"code": "not_found", "message": "Repository not found."}}`. See [errors](/reference/api/#errors).

| Status | Code | When |
| --- | --- | --- |
| 401 | `unauthenticated` | A token is required, or the one sent is not valid. |
| 403 | `forbidden` | The token is valid but not allowed to do this, such as a member-only change, or a token without the scope it needs. |
| 404 | `not_found` | It does not exist, or you cannot see it. |
| 409 | `conflict` | The request conflicts with the current state. |
| 422 | `invalid` | The input is not valid. `message` says which field and why. |
