{
  "schemaVersion": 1,
  "operation": {
    "operationId": "retainProjectCandidateSource",
    "method": "POST",
    "path": "/api/v1/projects/{project}/candidate-sync/source",
    "summary": "Retain an exact source snapshot without preparing a candidate",
    "description": "This source-only operation stores immutable bytes for a later target-owned delivery plan. It must not create a candidate, acquire physical credentials, or perform catalog work.",
    "tags": [
      "Deployments"
    ],
    "effect": "write",
    "confirmation": "conditional",
    "authorization": {
      "mode": "privilege",
      "privilege": "RESOURCE_EDIT"
    },
    "parameters": [
      {
        "name": "project",
        "in": "path",
        "required": true,
        "description": "",
        "schema": {
          "maxLength": 200,
          "minLength": 1,
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$",
          "type": "string"
        }
      },
      {
        "name": "Idempotency-Key",
        "in": "header",
        "required": true,
        "description": "",
        "schema": {
          "maxLength": 200,
          "minLength": 1,
          "type": "string"
        }
      },
      {
        "name": "Source-Synchronization-Plan",
        "in": "header",
        "required": true,
        "description": "",
        "schema": {
          "type": "string"
        }
      }
    ],
    "requestBody": {
      "required": true,
      "description": "",
      "content": [
        {
          "contentType": "application/json",
          "schema": {
            "$ref": "#/components/schemas/CandidateSynchronizationRequest"
          }
        }
      ]
    },
    "responses": [
      {
        "status": "200",
        "description": "The request has succeeded.",
        "content": [
          {
            "contentType": "application/json",
            "schema": {
              "$ref": "#/components/schemas/CandidateSourceSnapshotResponse"
            }
          }
        ]
      },
      {
        "status": "400",
        "description": "The server could not understand the request due to invalid syntax.",
        "content": [
          {
            "contentType": "application/problem+json",
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        ]
      },
      {
        "status": "401",
        "description": "Access is unauthorized.",
        "content": [
          {
            "contentType": "application/problem+json",
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        ]
      },
      {
        "status": "403",
        "description": "Access is forbidden.",
        "content": [
          {
            "contentType": "application/problem+json",
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        ]
      },
      {
        "status": "404",
        "description": "The server cannot find the requested resource.",
        "content": [
          {
            "contentType": "application/problem+json",
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        ]
      },
      {
        "status": "409",
        "description": "The request conflicts with the current state of the server.",
        "content": [
          {
            "contentType": "application/problem+json",
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        ]
      },
      {
        "status": "412",
        "description": "Precondition failed.",
        "content": [
          {
            "contentType": "application/problem+json",
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        ]
      },
      {
        "status": "413",
        "description": "Client error",
        "content": [
          {
            "contentType": "application/problem+json",
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        ]
      },
      {
        "status": "415",
        "description": "Client error",
        "content": [
          {
            "contentType": "application/problem+json",
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        ]
      },
      {
        "status": "422",
        "description": "Client error",
        "content": [
          {
            "contentType": "application/problem+json",
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        ]
      },
      {
        "status": "429",
        "description": "Client error",
        "content": [
          {
            "contentType": "application/problem+json",
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        ]
      },
      {
        "status": "500",
        "description": "Server error",
        "content": [
          {
            "contentType": "application/problem+json",
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        ]
      },
      {
        "status": "502",
        "description": "Server error",
        "content": [
          {
            "contentType": "application/problem+json",
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        ]
      },
      {
        "status": "503",
        "description": "Service unavailable.",
        "content": [
          {
            "contentType": "application/problem+json",
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        ]
      }
    ]
  },
  "schemas": {
    "CandidateSourceArtifact": {
      "example": {
        "digest": "example",
        "path": "example",
        "sizeBytes": 1
      },
      "properties": {
        "digest": {
          "example": "example",
          "type": "string"
        },
        "path": {
          "example": "example",
          "type": "string"
        },
        "sizeBytes": {
          "example": 1,
          "format": "int64",
          "type": "integer"
        }
      },
      "required": [
        "path",
        "digest",
        "sizeBytes"
      ],
      "type": "object"
    },
    "CandidateSourceRevision": {
      "example": {
        "changeId": "example",
        "ref": "example",
        "repository": "example",
        "revision": "example"
      },
      "properties": {
        "changeId": {
          "example": "example",
          "type": "string"
        },
        "ref": {
          "example": "example",
          "type": "string"
        },
        "repository": {
          "example": "example",
          "type": "string"
        },
        "revision": {
          "example": "example",
          "type": "string"
        }
      },
      "required": [
        "revision"
      ],
      "type": "object"
    },
    "CandidateSourceSnapshotResponse": {
      "example": {
        "environment": "example",
        "projectDigest": "example",
        "projectId": "example",
        "sourceAttestationDigest": "example",
        "sourceDigest": "example",
        "targetId": "example"
      },
      "properties": {
        "environment": {
          "example": "example",
          "type": "string"
        },
        "projectDigest": {
          "example": "example",
          "type": "string"
        },
        "projectId": {
          "example": "example",
          "maxLength": 200,
          "minLength": 1,
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$",
          "type": "string"
        },
        "sourceAttestationDigest": {
          "example": "example",
          "type": "string"
        },
        "sourceDigest": {
          "example": "example",
          "type": "string"
        },
        "targetId": {
          "example": "example",
          "type": "string"
        }
      },
      "required": [
        "projectId",
        "sourceDigest",
        "sourceAttestationDigest",
        "projectDigest",
        "targetId",
        "environment"
      ],
      "type": "object"
    },
    "CandidateSynchronizationRequest": {
      "example": {
        "artifactDigest": "example",
        "artifacts": [
          {
            "digest": "example",
            "path": "example",
            "sizeBytes": 1
          }
        ],
        "candidateKey": "example",
        "sourceOnly": true,
        "sourceRevision": {
          "changeId": "example",
          "ref": "example",
          "repository": "example",
          "revision": "example"
        }
      },
      "properties": {
        "artifactDigest": {
          "example": "example",
          "type": "string"
        },
        "artifacts": {
          "example": [
            {
              "digest": "example",
              "path": "example",
              "sizeBytes": 1
            }
          ],
          "items": {
            "$ref": "#/components/schemas/CandidateSourceArtifact"
          },
          "type": "array"
        },
        "candidateKey": {
          "example": "example",
          "type": "string"
        },
        "sourceOnly": {
          "description": "Retain the exact source snapshot without preparing a candidate or writing physical state. Delivery planning sets this true; Build owns the first writer operation.",
          "example": true,
          "type": "boolean"
        },
        "sourceRevision": {
          "$ref": "#/components/schemas/CandidateSourceRevision"
        }
      },
      "required": [
        "artifactDigest",
        "artifacts"
      ],
      "type": "object"
    },
    "ProblemDetails": {
      "example": {
        "code": "example",
        "detail": "example",
        "errors": [
          {
            "code": "example",
            "detail": "example",
            "field": "example"
          }
        ],
        "instance": "example",
        "requestId": "example",
        "status": 1,
        "title": "example",
        "type": "example"
      },
      "properties": {
        "code": {
          "example": "example",
          "type": "string"
        },
        "detail": {
          "example": "example",
          "type": "string"
        },
        "errors": {
          "example": [
            {
              "code": "example",
              "detail": "example",
              "field": "example"
            }
          ],
          "items": {
            "$ref": "#/components/schemas/ProblemFieldError"
          },
          "type": "array"
        },
        "instance": {
          "example": "example",
          "type": "string"
        },
        "requestId": {
          "example": "example",
          "type": "string"
        },
        "status": {
          "example": 1,
          "format": "int32",
          "type": "integer"
        },
        "title": {
          "example": "example",
          "type": "string"
        },
        "type": {
          "example": "example",
          "type": "string"
        }
      },
      "required": [
        "type",
        "title",
        "status",
        "detail",
        "instance",
        "code",
        "requestId",
        "errors"
      ],
      "type": "object"
    },
    "ProblemFieldError": {
      "example": {
        "code": "example",
        "detail": "example",
        "field": "example"
      },
      "properties": {
        "code": {
          "example": "example",
          "type": "string"
        },
        "detail": {
          "example": "example",
          "type": "string"
        },
        "field": {
          "example": "example",
          "type": "string"
        }
      },
      "required": [
        "field",
        "code",
        "detail"
      ],
      "type": "object"
    }
  }
}
