# Preview a saved solution publication

```http
GET /api/public/v1/competitions/lean-kernel-challenge/playground/solutions/{solutionId}/publication-preview
```

**Scope**: `contributor-network.write`.

Returns the exact private Solution revision, complete Workspace, version provenance, integrity fields, and current publication capacity needed to review a Lean Kernel Contributor Network publication.

The preview creates or reuses an immutable Publication Snapshot for the selected Solution revision. It does not create a Contributor Network item, lock the Solution, reserve capacity, or consume the daily creation quota. Current enrollment and a writable Playground are required; a Competition Team, practice Run, successful Run, and open formal-submission window are not.

## Path and query parameters

| Parameter | Type, requirement, and meaning |
| :--- | :--- |
| `solutionId` | **Required positive integer path parameter.** ID returned by [List saved solutions](./list-playground-solutions.md). |
| `revision` | **Required positive integer query parameter.** Must be the Solution's exact current `revision`. |

## Example request

```bash
export SAIR_API_BASE="https://api.sair.foundation/api/public/v1"

curl \
  "$SAIR_API_BASE/competitions/lean-kernel-challenge/playground/solutions/17/publication-preview?revision=2" \
  -H "Authorization: Bearer $SAIR_API_KEY"
```

## Example response

```json
{
  "ok": true,
  "data": {
    "solutionId": "17",
    "solutionRevision": 2,
    "snapshotId": "24",
    "solutionName": "baseline",
    "problemId": "fib",
    "approvedRevision": "7a0abb4a80d635740a91aed1894f714dfbb82edd",
    "templateVersion": "7a0abb4a80d635740a91aed1894f714dfbb82edd",
    "toolchainVersion": "leanprover/lean4:v4.33.1",
    "manifestVersion": "lean-kernel-user-workspace-v1",
    "fileCount": 2,
    "totalBytes": 241,
    "workspaceSha256": "7d5307e5c809eeb01a95cf0ca6da2d452b5f94bd78e2a2fbc0ea706210e58ea8",
    "files": [
      {
        "path": "Submission.lean",
        "sizeBytes": 177,
        "sha256": "7e6f4ab707c6d0e58d06c95d90ba9b347c8d832f8262f84cdb0b5f5eb6d80963",
        "content": "import Spec\nimport Submission.Helpers\n\nnamespace Submission\n\ndef impl : Nat → Nat := fibSpec\n\ntheorem impl_correct : ∀ n, impl n = fibSpec n := fun _ => rfl\n\nend Submission\n"
      },
      {
        "path": "Submission/Helpers.lean",
        "sizeBytes": 64,
        "sha256": "942cfbb446c6ab3a6b78ecdd11d855dd145b24acdc20ea9b1e3df08008ac3b12",
        "content": "namespace Submission\n\ndef helper (n : Nat) := n\n\nend Submission\n"
      }
    ],
    "contributorNetwork": {
      "capScope": "problem",
      "problemId": "fib",
      "activeItemIds": ["cn_example_1", "cn_example_2"],
      "publishCap": 5,
      "activeCount": 2,
      "capRemaining": 3
    }
  }
}
```

## Response fields

| Field | Type and meaning |
| :--- | :--- |
| `solutionId` | `string` — Exact Solution ID selected for publication. |
| `solutionRevision` | `integer` — Exact current revision represented by this preview. |
| `snapshotId` | `string` — Immutable preview snapshot ID. |
| `solutionName` | `string` — Current Solution name used as the initial public package title. |
| `problemId` | `string` — Problem bound to the Solution. |
| `approvedRevision` | `string` — Approved Problem and rules revision frozen into the snapshot. |
| `templateVersion` | `string` — Development-template version frozen into the snapshot. |
| `toolchainVersion` | `string` — Lean toolchain version frozen into the snapshot. |
| `manifestVersion` | `string` — Canonical Workspace-manifest format. |
| `fileCount` | `integer` — Number of entries in `files`. |
| `totalBytes` | `integer` — Sum of all file content UTF-8 byte lengths. |
| `workspaceSha256` | `string` — Lowercase SHA-256 digest of the canonical Workspace manifest. |
| `files` | `WorkspaceFile[]` — Complete Workspace in canonical path order. Each item contains `path`, `sizeBytes`, `sha256`, and exact `content`. |
| `contributorNetwork` | `object` — Current per-Problem capacity; fields match [Get my participation](./get-my-participation.md#contributor-network-capacity). |

The implemented response exposes confirmation values as top-level fields. It does not return a nested `confirmation` object or a separate `workspaceFiles` array. The matching publish request uses `source.solutionId`, `source.solutionRevision`, and a new idempotency key; the current write contract does not echo these preview hashes back in a confirmation object.

Capacity is a point-in-time snapshot. Eligibility and capacity are checked again when publishing. Successful responses use `Content-Type: application/json`.

## Errors

| HTTP | Code | When |
| :---: | :--- | :--- |
| `400` | `INVALID_SOLUTION_ID` | `solutionId` is not a positive integer. |
| `400` | `REVISION_REQUIRED` | `revision` is missing or is not a positive integer. |
| `403` | `ENROLL_REQUIRED` | The caller has not completed Competition enrollment. |
| `403` | `PLAYGROUND_NOT_STARTED` | The Playground has not opened for new publications. |
| `403` | `PLAYGROUND_READ_ONLY` | The Playground is closed or disabled for new publications. |
| `403` | `PUBLISH_CAP_EXCEEDED` | The caller has reached the active package cap for this Problem. |
| `404` | `NOT_FOUND` | The Competition or owned Solution is unavailable. |
| `404` | `CONTRIBUTOR_NETWORK_UNAVAILABLE` | Contributor Network is unavailable for the Competition. |
| `409` | `REVISION_CONFLICT` | `revision` is no longer the Solution's exact current revision. |
| `409` | `SOLUTION_PUBLICATION_LOCKED` | The Solution already has an active or pending publication. |
| `409` | `SNAPSHOT_INTEGRITY_MISMATCH` | The generated publication snapshot is invalid. |
| `502` | `PLATFORM_UNAVAILABLE` | Competition, lifecycle, enrollment, or capacity state could not be read. |
| `502` | `PLAYGROUND_CONFIGURATION_INVALID` | The Playground lifecycle configuration is invalid. |

After the user reviews the complete preview, [publish the saved solution](./publish-contributor-package.md). See [Errors](../../../errors.md) for shared authentication, scope, and rate-limit errors.
