# Cheatsheets

Manage your private Playground cheatsheet library. A cheatsheet can be referenced from a [Playground run](./playground.md#submit-a-run) (`configurations[].cheatsheet`) and submitted to a `cheatsheet`-kind competition.

You only see and modify cheatsheets owned by the calling account.

## List cheatsheets

```http
GET /api/public/v1/cheatsheets
```

**Scope**: `playground.read`. This endpoint is cursor-paginated.

Lists cheatsheets owned by the calling account. The list view omits `content`; call [Get a cheatsheet](#get-a-cheatsheet) for the body.

### Query parameters

| Parameter | Type    | Required | Description                                   |
| :-------- | :------ | :------: | :-------------------------------------------- |
| `cursor`  | string  | No       | Opaque cursor from the previous `nextCursor`. |
| `limit`   | integer | No       | Page size. Default `25`, maximum `100`.       |

### Response fields

| Field        | Type          | Description                          |
| :----------- | :------------ | :----------------------------------- |
| `items[]`    | [CheatsheetSummary](#cheatsheet-summary-fields)[] | Cheatsheet records without `content`. |
| `nextCursor` | string \| null | Cursor for the next page, or `null`. |

### Cheatsheet summary fields

| Field                               | Type           | Description                                                  |
| :---------------------------------- | :------------- | :----------------------------------------------------------- |
| `id`                                | string         | Cheatsheet ID.                                               |
| `title`                             | string         | Cheatsheet title.                                            |
| `sourceContributorNetworkItemId`    | string \| null | Contributor Network item this cheatsheet was forked from.    |
| `publishedContributorNetworkItemId` | string \| null | Active Contributor Network item published from this sheet.   |
| `createdAt`                         | string         | ISO 8601 UTC creation timestamp.                             |
| `updatedAt`                         | string         | ISO 8601 UTC update timestamp.                               |

### Cheatsheet fields

`Cheatsheet` includes all [CheatsheetSummary](#cheatsheet-summary-fields) fields plus:

| Field     | Type   | Description      |
| :-------- | :----- | :--------------- |
| `content` | string | Cheatsheet body. |

```json
{
  "ok": true,
  "data": {
    "items": [
      {
        "id": "cs_01HXYZ...",
        "title": "Modular tricks v3",
        "sourceContributorNetworkItemId": null,
        "publishedContributorNetworkItemId": null,
        "createdAt": "2026-04-12T08:21:30Z",
        "updatedAt": "2026-05-04T17:02:11Z"
      }
    ],
    "nextCursor": null
  }
}
```

## Get a cheatsheet

```http
GET /api/public/v1/cheatsheets/{cheatsheetId}
```

**Scope**: `playground.read`.

Returns one cheatsheet, including `content`.

### Path parameters

| Parameter      | Type   | Required | Description    |
| :------------- | :----- | :------: | :------------- |
| `cheatsheetId` | string | Yes      | Cheatsheet ID. |

### Response fields

Returns a [Cheatsheet](#cheatsheet-fields), including `content`.

## Create a cheatsheet

```http
POST /api/public/v1/cheatsheets
```

**Scope**: `playground.write`.

Creates a cheatsheet owned by the calling account.

### Request fields

| Field                            | Type   | Required | Description                                               |
| :------------------------------- | :----- | :------: | :-------------------------------------------------------- |
| `title`                          | string | Yes      | Cheatsheet title.                                         |
| `content`                        | string | Yes      | Cheatsheet body.                                          |
| `sourceContributorNetworkItemId` | string | No       | Contributor Network item this cheatsheet was forked from. |

```json
{
  "title": "Modular tricks v3",
  "content": "When the modulus is prime, use Fermat's little theorem...",
  "sourceContributorNetworkItemId": "cn_01HX0PA..."
}
```

### Response fields

Returns the created [Cheatsheet](#cheatsheet-fields), including `content`.

## Update a cheatsheet

```http
PATCH /api/public/v1/cheatsheets/{cheatsheetId}
```

**Scope**: `playground.write`.

Partially updates a cheatsheet. Provide at least one request field. A cheatsheet published on the Contributor Network is read-only; withdraw the published item first.

### Path parameters

| Parameter      | Type   | Required | Description    |
| :------------- | :----- | :------: | :------------- |
| `cheatsheetId` | string | Yes      | Cheatsheet ID. |

### Request fields

| Field     | Type   | Required | Description               |
| :-------- | :----- | :------: | :------------------------ |
| `title`   | string | No       | New cheatsheet title.     |
| `content` | string | No       | New cheatsheet body.      |

### Response fields

Returns the updated [Cheatsheet](#cheatsheet-fields), including `content`.

## Delete a cheatsheet

```http
DELETE /api/public/v1/cheatsheets/{cheatsheetId}
```

**Scope**: `playground.write`.

Deletes a cheatsheet owned by the calling account. A cheatsheet published on the Contributor Network is read-only; withdraw the published item first.

### Path parameters

| Parameter      | Type   | Required | Description    |
| :------------- | :----- | :------: | :------------- |
| `cheatsheetId` | string | Yes      | Cheatsheet ID. |

### Response

Returns `204` with no body.

## Errors

See [Errors](../errors.md). Endpoint-specific:

| Code                | HTTP | When                                                   |
| :------------------ | :--: | :----------------------------------------------------- |
| `CHEATSHEET_LOCKED` | 403  | Cheatsheet is published. Withdraw it first.  |
