# PDP v1

## What `pdp_v1` Is For

`pdp_v1` drives PDP dataset and piece lifecycle operations through MK20.

## Struct Definition

```go
type PDPV1 struct {
    CreateDataSet bool    `json:"create_data_set"`
    DeleteDataSet bool    `json:"delete_data_set"`
    AddPiece      bool    `json:"add_piece"`
    DeletePiece   bool    `json:"delete_piece"`
    DataSetID     *uint64 `json:"data_set_id,omitempty"`
    RecordKeeper  string  `json:"record_keeper"`
    PieceIDs      []uint64 `json:"piece_ids,omitempty"`
    ExtraData     []byte   `json:"extra_data,omitempty"`
}
```

## Action Model

Exactly one of these flags must be set in each deal:

* `create_data_set`
* `delete_data_set`
* `add_piece`
* `delete_piece`

## Key Fields

* `data_set_id`: required for all actions except `create_data_set`.
* `record_keeper`: required when creating a dataset.
* `piece_ids`: required for `delete_piece`.
* `extra_data`: verifier/service payload. It is required for `create_data_set`, `add_piece`, and `delete_piece`, and must be absent for `delete_data_set`.

## Validation Rules

* `pdp_v1` must be enabled by provider.
* Provider must have PDP signing key configured (`eth_keys.role = 'pdp'`).
* Only one action flag is allowed per deal.
* `create_data_set`:
  * `data_set_id` must be absent
  * `record_keeper` must be a valid hex address
  * `extra_data` must be present and no larger than 4 KiB
* `delete_data_set` / `add_piece`:
  * `data_set_id` must be present
  * dataset must exist and be active
* `delete_data_set`:
  * `extra_data` must be absent
* `add_piece`:
  * `extra_data` must be present and no larger than 8 KiB
* `delete_piece`:
  * `data_set_id` must be present
  * `piece_ids` must be present
  * all listed pieces must exist and be active in that dataset
  * `extra_data` must be present and no larger than 256 bytes

## Runtime Sanitize Rules

* `add_piece` requires `retrieval_v1`.
* `offline` source is rejected for PDP flows.
* Raw-format data cannot use `announce_payload`.
* Dataset and piece ownership checks are revalidated.

## Processing Behavior

* `add_piece` with HTTP/aggregate data goes directly into PDP processing pipelines.
* `add_piece` with `put` source (or upload-first mode) enters upload-waiting first.
* Create/delete operations enqueue PDP lifecycle actions without upload flow.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.curiostorage.org/market-2.0/products/pdp_v1.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
