# DWN Requests

<figure><img src="/files/CAFs6pfLpT9uDU5E6kPp" alt=""><figcaption><p>Zion Aggregator Framework</p></figcaption></figure>

In the Zion Aggregator, [DWN](/architecture/decentralized-web-nodes.md)s feed messages that the user designates through the use of handlers. Data that meets certain conditions set by the user and aggregator is sent to the aggregator for indexing, and unlike traditional aggregators, permission for data can be revoked by [DWN ](/architecture/decentralized-web-nodes.md)owners at any time thus removing the aggregator's access to that data.

Currently Zion [DWN](/architecture/decentralized-web-nodes.md)s have three types of requests. These requests are formatted as Messages. Currently, Zion DWNs utilize three types of Messages: CollectionsWrite, CollectionsCommit and CollectionsDelete.&#x20;

### CollectionsWrite

CollectionWrite requests are for posting a new item in a collection. The format for a CollectionsWrite request is:

```json
{  // Request Object
  "target": "did:zion:123",// Community DID
  "messages": [  // Message Objects
    {
      "data": {
        "image": "...",
        "text": "Some stuff I ate for lunch",
        ... 
      }, // Base64URL String Representation of this object
      "descriptor": {
        "nonce": "9b9c7f1fcabfc471ee2682890b58a427ba2c8db59ddf3c2d5ad16ccc84bb3106",
        "method": "CollectionsWrite",
        "recordId": "b6464162-84af-4aab-aff5-f1f8438dfc1e", // the record ID you are creating
        "dataCid": "", //CID V1 of the data field
        "dataFormat": "application/json",
        "dateCreated": 123456789,
        "schema": "https://schema.org/SocialMediaPosting", // Can be a key for a hardcoded custom ZION schema
        "protocol": "zion.fyi/social-protocol/v1"
      },
        "attestation": {
        "protected": {
          "alg": "ES256K",
          "kid": "did:example:123#key-1"
        },
        "payload": "", // CID V1 of the descriptor,
        "signature": "" //JWS of (protected + payload)
      } // JWS Compact Object string
    },
  ]
}
```

### CollectionsCommit

CollectionsCommit requests are for updating an existing item in a collection. This will effectively replace that item. The format for a CollectionsCommit request is:

```json
{  // Request Object
  "target": "did:zion:123",// Community DID
  "messages": [  // Message Objects
    {
      "data": {
        "image": "...",
        "text": "Some stuff I ate for lunch, and a snack",
        ... 
      }, // Base64URL String Representation of this object
      "descriptor": {
        "nonce": "9b9c7f1fcabfc471ee2682890b58a427ba2c8db59ddf3c2d5ad16ccc84bb3106",
        "method": "CollectionsCommit",
        "recordId": "b6464162-84af-4aab-aff5-f1f8438dfc1e", // ID for the record looking to update
        "dataCid": "", //CID V1 of the data field
        "dataFormat": "application/json",
        "dateCreated": 123456789, // Should be the time of the original creation
        "datePublished": 123456789, // Should be now
        "schema": "https://schema.org/SocialMediaPosting", // Can be a key for a hardcoded custom ZION schema
        "protocol": "zion.fyi/social-protocol/v1"
      },
        "attestation": {
        "protected": {
          "alg": "ES256K",
          "kid": "did:example:123#key-1"
        },
        "payload": "", // CID V1 of the descriptor,
        "signature": "" //JWS of (protected + payload)
      } // JWS Compact Object string
    },
  ]
}
```

### CollectionsDelete

CollectionsDelete requests are for removing an item of a collection. Once deleted an item will be unrecoverable. The format for a CollectionsDelete request is:

```json
{  // Request Object
  "target": "did:zion:123",// Community DID
  "messages": [  // Message Objects
    {
      "descriptor": {
        "nonce": "9b9c7f1fcabfc471ee2682890b58a427ba2c8db59ddf3c2d5ad16ccc84bb3106",
        "method": "CollectionsDelete",
        "recordId": "b6464162-84af-4aab-aff5-f1f8438dfc1e", // the record for deletion
        "schema": "https://schema.org/SocialMediaPosting", // Can be a key for a hardcoded custom ZION schema
        "protocol": "zion.fyi/social-protocol/v1"
      },
        "attestation": {
        "protected": {
          "alg": "ES256K",
          "kid": "did:example:123#key-1"
        },
        "payload": "", // CID V1 of the descriptor,
        "signature": "" //JWS of (protected + payload)
      } // JWS Compact Object string
    },
  ]
}
```


---

# 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.zion.fyi/architecture/decentralized-web-nodes/dwn-requests.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.
