# cURL examples

> Practical command-line examples using cURL to interact with the MMW Cloud REST API.

The following examples demonstrate standard command-line interactions with the storage REST API.

## Listing files

Retrieve the first 10 files matching a search query:

```bash
curl -s -H "Authorization: Bearer mmwc_0123456789abcdef_secretkeyhere" \
  "https://api.mmwcloud.tech/v1/files?limit=10&search=report"
```

## Checking storage quota

Query quota utilization for the active account:

```bash
curl -s -H "Authorization: Bearer mmwc_0123456789abcdef_secretkeyhere" \
  https://api.mmwcloud.tech/v1/quota
```

## Uploading a small file

Uploading a single file under 8 MiB requires three steps:

### 1. Request an upload ticket

```bash
SIZE=$(stat -c %s document.pdf)
SHA=$(sha256sum document.pdf | cut -d" " -f1)

curl -s -X POST https://api.mmwcloud.tech/v1/files/upload-ticket \
  -H "Authorization: Bearer mmwc_0123456789abcdef_secretkeyhere" \
  -H "Content-Type: application/json" \
  -d "{\"name\": \"document.pdf\", \"size_bytes\": $SIZE, \"sha256\": \"$SHA\"}"
```

### 2. Upload binary payload to upload_url

```bash
curl -s -X PUT "https://storage.mmwcloud.tech/v1/upload/file_01h8upload123?capability=token" \
  -H "Content-Type: application/octet-stream" \
  --data-binary @document.pdf
```

### 3. Complete the transfer

```bash
curl -s -X POST https://api.mmwcloud.tech/v1/files/complete \
  -H "Authorization: Bearer mmwc_0123456789abcdef_secretkeyhere" \
  -H "Content-Type: application/json" \
  -d '{"id": "file_01h8upload123"}'
```

### 4. Inspect file processing status

```bash
curl -s -H "Authorization: Bearer mmwc_0123456789abcdef_secretkeyhere" \
  https://api.mmwcloud.tech/v1/files/file_01h8upload123
```

## Downloading a file

### 1. Request a temporary signed link

```bash
curl -s -H "Authorization: Bearer mmwc_0123456789abcdef_secretkeyhere" \
  https://api.mmwcloud.tech/v1/files/file_01h8upload123/download
```

### 2. Download file contents

```bash
curl -s -o document.pdf \
  "https://storage.mmwcloud.tech/v1/download/file_01h8upload123?capability=token"
```

## Deleting a file

Perform soft deletion of a stored object:

```bash
curl -s -X DELETE https://api.mmwcloud.tech/v1/files/file_01h8upload123 \
  -H "Authorization: Bearer mmwc_0123456789abcdef_secretkeyhere"
```
