> For the complete documentation index, see [llms.txt](https://docs.silk.us/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.silk.us/api-reference/using-the-api/object-manipulation.md).

# Object manipulation

Create, read, update, and delete objects with POST, GET, PATCH, and DELETE.

The API uses four object operations: create, read, update, and delete (CRUD). These are expressed through HTTP methods (`POST`, `GET`, `PATCH`, and `DELETE`) against object URLs. All request and response payloads must be serialized as JSON.

Each object operation is defined by up to three parameters:

* **Entity:** host, volume, and so on.
* **Operation:** create, read, and so on.
* **Operation payload:** a dictionary of object properties, if required.

## Create an object

To create an object, issue a `POST` request to the entity's collection URL, passing the new object's properties as a JSON dictionary. When the object is created, the server responds with `201 Created`.

The response includes the ID of the new object, which you can use to reference it or access it directly, for example `https://{silk_ip}/api/v2/volumes/38`. The response contains the full object data, even when not all properties were specified in the request.

{% tabs %}
{% tab title="Request" %}

```http
POST /api/v2/volumes
```

```json
{
  "name": "oracleTest",
  "size": 1048576,
  "description": "oracle test db",
  "vmware_enabled": true,
  "volume_group": { "ref": "/volume_groups/21" }
}
```

{% endtab %}

{% tab title="Response (201 Created)" %}

```json
{
  "avg_compressed_ratio": 0,
  "avg_compressed_ratio_timestamp": 0,
  "creation_time": 1440484716,
  "current_replication_stats": null,
  "current_stats": { "ref": "/stats/volumes/7" },
  "description": "oracle test db",
  "id": 7,
  "is_new": true,
  "iscsi_tgt_converted_name": "v2",
  "last_restored_from": null,
  "last_restored_time": null,
  "logical_capacity": 0,
  "marked_for_deletion": false,
  "name": "oracleTest",
  "node_id": 4,
  "replication_peer_volume": null,
  "scsi_sn": "d5030003",
  "scsi_suffix": 3,
  "size": 1048576,
  "snapshots_logical_capacity": 0,
  "vmware_support": false,
  "volume_group": { "ref": "/volume_groups/21" }
}
```

{% endtab %}
{% endtabs %}

## Get an object

If you have both the object type and the ID, construct the object URL and issue a `GET` request to retrieve the object's properties. A `GET` on a collection URL returns all objects in the collection, which you can filter with query parameters. See [URL structure and filtering](/api-reference/using-the-api/url-structure-and-filtering.md).

{% tabs %}
{% tab title="Get by ID" %}

```http
GET /api/v2/volumes/38
```

```json
{
  "avg_compressed_ratio": 0,
  "creation_time": 1440484716,
  "current_stats": { "ref": "/stats/volumes/7" },
  "description": "oracle test db",
  "id": 7,
  "name": "oracleTest",
  "size": 1048576,
  "volume_group": { "ref": "/volume_groups/21" },
  ...
}
```

{% endtab %}

{% tab title="Get a collection" %}

```http
GET /api/v2/volumes
```

```json
{
  "hits": [
    {
      "id": 7,
      "name": "oracleTest",
      "size": 1048576,
      "volume_group": { "ref": "/volume_groups/21" },
      ...
    },
    {
      "current_replication_stats": { "ref": "/replication/stats/volumes/3" },
      "id": 3,
      "logical_capacity": 838860800,
      "name": "volume4",
      "replication_peer_volume": { "ref": "/replication/peer_volumes/1" },
      "size": 838860800,
      "snapshots_logical_capacity": 709214520,
      "volume_group": { "ref": "/volume_groups/2" },
      ...
    }
  ],
  "total": 11,
  "limit": 50,
  "offset": 0
}
```

{% endtab %}
{% endtabs %}

## Modify an object

To modify an object, issue a `PATCH` request to its canonical URL with a dictionary of the new field values. The response contains the full updated object.

{% tabs %}
{% tab title="Request" %}

```http
PATCH /api/v2/volumes/1
```

```json
{
  "description": "Testing on Oracle"
}
```

{% endtab %}

{% tab title="Response (200 OK)" %}

```json
{
  "id": 1,
  "name": "OracleTest",
  "size": 1048576,
  "description": "Testing on Oracle",
  "vms_enabled": false,
  "volume_group": { "ref": "/volume_groups/21" }
}
```

{% endtab %}
{% endtabs %}

## Delete an object

To delete an object, issue a `DELETE` request to its canonical URL.

```http
DELETE /api/v2/volumes/1
```

The server responds with `204 No content`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.silk.us/api-reference/using-the-api/object-manipulation.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
