# Storage

The `@aziontech/storage` package is the Azion Lib library for [Object Storage](/en/documentation/platform/object-storage/). Its functions create, list, read, update, and delete buckets and the objects inside them through Azion API v4. Each function takes one object argument and returns a response envelope instead of throwing.

Install the package:

```bash
npm install @aziontech/storage
```

The samples on this page are TypeScript ES modules that use top-level `await`, and they run in Node.js. They import types with `import type`, which keeps them loadable when the type annotations are stripped.

---

## Authentication

The functions read your [personal token](/en/documentation/fundamentals/personal-tokens/) from the `AZION_TOKEN` environment variable. A client created with [createClient](#createclient) takes the token in its `token` field instead.

| Variable      | Description                                                         |
| ------------- | ------------------------------------------------------------------- |
| `AZION_TOKEN` | Your Azion personal token.                                          |
| `AZION_DEBUG` | With `true`, the functions log the response bodies the API returns. |

For how the Azion Lib packages resolve the token and the debug setting, refer to [How Azion Lib works](/en/documentation/devtools/azion-lib/how-it-works/).

---

## Response envelope

Every function returns an [AzionStorageResponse](#azionstorageresponse) object, `{ data?, error? }`. On success, `data` holds the bucket, the object, or the list. On failure, `error` holds `{ message, operation }`, where `operation` names the call that failed, such as `create bucket` or `get object by key`.

A successful [deleteBucket](#deletebucket) or [deleteObject](#deleteobject) returns no `data`: the envelope holds only `error`, set to `undefined`. Check `error` after a delete, not `data`.

---

## createClient

Creates a client that holds a token and request options and exposes the bucket functions as methods. `createClient` is also the default export of the package.

```typescript
function createClient(config?: Partial<{
  token: string;
  options?: AzionClientOptions;
}>): AzionStorageClient;
```

| Parameter | Type                                        | Required | Description                                      |
| --------- | ------------------------------------------- | -------- | ------------------------------------------------ |
| `token`   | `string`                                    | No       | Your Azion personal token.                       |
| `options` | [`AzionClientOptions`](#azionclientoptions) | No       | Request options for every call the client makes. |

Returns an [AzionStorageClient](#azionstorageclient). Its methods take the same object as the matching function on this page, without `options`. The client has no object methods: read and write objects with the object functions or the [bucket methods](#bucket-methods).

This sample creates a client and a bucket with it:

```typescript
import { createClient } from '@aziontech/storage';
import type { AzionStorageClient } from '@aziontech/storage';

const client: AzionStorageClient = createClient({ token: process.env.AZION_TOKEN, options: { debug: false } });

const { data, error } = await client.createBucket({ name: 'my-client-bucket', workloads_access: 'read_only' });
if (data) {
  console.log(`Bucket created with name: ${data.name}`);
} else {
  console.error('Failed to create bucket', error);
}
```

Output:

```text
Bucket created with name: my-client-bucket
```

---

## setupStorage

Returns a bucket by its name, and creates it first when it does not exist. The function reads the bucket, and only when that read finds nothing does it create one with the `workloads_access` you pass.

```typescript
function setupStorage(params: {
  name: string;
  workloads_access: EdgeAccessType;
  options?: AzionClientOptions;
}): Promise<AzionStorageResponse<AzionBucket>>;
```

| Parameter          | Type                                        | Required | Description                                                |
| ------------------ | ------------------------------------------- | -------- | ---------------------------------------------------------- |
| `name`             | `string`                                    | Yes      | The name of the bucket to return or create.                |
| `workloads_access` | [`EdgeAccessType`](#edgeaccesstype)         | Yes      | The access level of the bucket if the function creates it. |
| `options`          | [`AzionClientOptions`](#azionclientoptions) | No       | Request options.                                           |

Returns `data` as an [AzionBucket](#azionbucket), existing or created. The bucket carries the [bucket methods](#bucket-methods), so you can write to it right away.

This sample gets a bucket that exists and writes a JSON object to it:

```typescript
import { setupStorage } from '@aziontech/storage';
import type { AzionStorageResponse, AzionBucket } from '@aziontech/storage';

const { data: bucket, error }: AzionStorageResponse<AzionBucket> = await setupStorage({
  name: 'my-app-bucket',
  workloads_access: 'read_write',
});
if (bucket) {
  console.log(`Storage ready: ${bucket.name}`);
  // Now you can safely use the bucket for operations
  const { data: object, error: objectError } = await bucket.createObject({
    key: 'config.json',
    content: '{}',
    params: { content_type: 'application/json' },
  });
  console.log(object ? `Object created: ${object.key}` : objectError);
} else {
  console.error('Failed to setup storage', error);
}
```

Output:

```text
Storage ready: my-app-bucket
Object created: config.json
```

---

## createBucket

Creates a bucket.

```typescript
function createBucket(params: {
  name: string;
  workloads_access: EdgeAccessType;
  options?: AzionClientOptions;
}): Promise<AzionStorageResponse<AzionBucket>>;
```

| Parameter          | Type                                        | Required | Description                     |
| ------------------ | ------------------------------------------- | -------- | ------------------------------- |
| `name`             | `string`                                    | Yes      | The name of the bucket.         |
| `workloads_access` | [`EdgeAccessType`](#edgeaccesstype)         | Yes      | The access level of the bucket. |
| `options`          | [`AzionClientOptions`](#azionclientoptions) | No       | Request options.                |

Returns `data` as the created [AzionBucket](#azionbucket). A bucket has no `id`: every other function finds it by `name`.

```typescript
import { createBucket } from '@aziontech/storage';
import type { AzionStorageResponse, AzionBucket } from '@aziontech/storage';

const { data, error }: AzionStorageResponse<AzionBucket> = await createBucket({
  name: 'my-new-bucket',
  workloads_access: 'read_only',
});
if (data) {
  console.log(`Bucket created with name: ${data.name}`);
} else {
  console.error('Failed to create bucket', error);
}
```

Output:

```text
Bucket created with name: my-new-bucket
```

---

## getBuckets

Lists the buckets of the account, one page at a time.

```typescript
function getBuckets(params: {
  params?: AzionBucketCollectionParams;
  options?: AzionClientOptions;
}): Promise<AzionStorageResponse<AzionBucketCollection>>;
```

| Parameter | Type                                                          | Required | Description                                        |
| --------- | ------------------------------------------------------------- | -------- | -------------------------------------------------- |
| `params`  | [`AzionBucketCollectionParams`](#azionbucketcollectionparams) | No       | Pagination, search, ordering, and field selection. |
| `options` | [`AzionClientOptions`](#azionclientoptions)                   | No       | Request options.                                   |

Returns `data` as an [AzionBucketCollection](#azionbucketcollection): `buckets` holds the page, and `count` holds the number of buckets in the account, not the length of the page.

```typescript
import { getBuckets } from '@aziontech/storage';
import type { AzionStorageResponse, AzionBucketCollection } from '@aziontech/storage';

const { data: buckets, error }: AzionStorageResponse<AzionBucketCollection> = await getBuckets({
  params: { page: 1, page_size: 10 },
});
if (buckets) {
  console.log(`Retrieved ${buckets.buckets.length} of ${buckets.count} buckets`);
} else {
  console.error('Failed to retrieve buckets', error);
}
```

Output:

```text
Retrieved 10 of 25 buckets
```

---

## getBucket

Returns one bucket by its name.

```typescript
function getBucket(params: {
  name: string;
  options?: AzionClientOptions;
}): Promise<AzionStorageResponse<AzionBucket>>;
```

| Parameter | Type                                        | Required | Description             |
| --------- | ------------------------------------------- | -------- | ----------------------- |
| `name`    | `string`                                    | Yes      | The name of the bucket. |
| `options` | [`AzionClientOptions`](#azionclientoptions) | No       | Request options.        |

Returns `data` as an [AzionBucket](#azionbucket), with the [bucket methods](#bucket-methods). A name that matches no bucket returns `error` with the message `The specified bucket does not exist.`.

```typescript
import { getBucket } from '@aziontech/storage';
import type { AzionStorageResponse, AzionBucket } from '@aziontech/storage';

const { data: bucket, error }: AzionStorageResponse<AzionBucket> = await getBucket({ name: 'my-new-bucket' });
if (bucket) {
  console.log(`Retrieved bucket: ${bucket.name} (${bucket.workloads_access})`);
} else {
  console.error('Bucket not found', error);
}
```

Output:

```text
Retrieved bucket: my-new-bucket (read_only)
```

---

## updateBucket

Changes the access level of a bucket.

```typescript
function updateBucket(params: {
  name: string;
  workloads_access: EdgeAccessType;
  options?: AzionClientOptions;
}): Promise<AzionStorageResponse<AzionBucket>>;
```

| Parameter          | Type                                        | Required | Description                            |
| ------------------ | ------------------------------------------- | -------- | -------------------------------------- |
| `name`             | `string`                                    | Yes      | The name of the bucket to update.      |
| `workloads_access` | [`EdgeAccessType`](#edgeaccesstype)         | Yes      | The access level to set on the bucket. |
| `options`          | [`AzionClientOptions`](#azionclientoptions) | No       | Request options.                       |

Returns `data` as the updated [AzionBucket](#azionbucket).

```typescript
import { updateBucket } from '@aziontech/storage';
import type { AzionStorageResponse, AzionBucket } from '@aziontech/storage';

const { data: updatedBucket, error }: AzionStorageResponse<AzionBucket> = await updateBucket({
  name: 'my-new-bucket',
  workloads_access: 'read_write',
});
if (updatedBucket) {
  console.log(`Bucket updated: ${updatedBucket.name} (${updatedBucket.workloads_access})`);
} else {
  console.error('Failed to update bucket', error);
}
```

Output:

```text
Bucket updated: my-new-bucket (read_write)
```

---

## deleteBucket

Deletes a bucket by its name. The API deletes a bucket only while it holds no objects, and not within 24 hours of the last object deletion in it. A bucket that never held an object is deleted at once.

```typescript
function deleteBucket(params: {
  name: string;
  options?: AzionClientOptions;
}): Promise<AzionStorageResponse<AzionDeletedBucket>>;
```

| Parameter | Type                                        | Required | Description                       |
| --------- | ------------------------------------------- | -------- | --------------------------------- |
| `name`    | `string`                                    | Yes      | The name of the bucket to delete. |
| `options` | [`AzionClientOptions`](#azionclientoptions) | No       | Request options.                  |

On success, the envelope holds no `data`, so the sample checks `error`. A refused delete fills `error`; the messages are in [Errors](#errors).

```typescript
import { deleteBucket } from '@aziontech/storage';

const { error } = await deleteBucket({ name: 'my-new-bucket' });
if (error) {
  console.error('Failed to delete bucket', error);
} else {
  console.log('Bucket my-new-bucket deleted');
}
```

Output:

```text
Bucket my-new-bucket deleted
```

---

## createObject

Creates an object in a bucket.

```typescript
function createObject(params: {
  bucket: string;
  key: string;
  content: ContentObjectStorage;
  params?: { content_type?: string };
  options?: AzionClientOptions;
}): Promise<AzionStorageResponse<AzionBucketObject>>;
```

| Parameter | Type                                            | Required | Description                                                                                     |
| --------- | ----------------------------------------------- | -------- | ----------------------------------------------------------------------------------------------- |
| `bucket`  | `string`                                        | Yes      | The name of the bucket to create the object in.                                                 |
| `key`     | `string`                                        | Yes      | The key (name) of the object.                                                                   |
| `content` | [`ContentObjectStorage`](#contentobjectstorage) | Yes      | The content of the object: a `string`, an `ArrayBuffer`, a `ReadableStream`, or a `Uint8Array`. |
| `params`  | `{ content_type?: string }`                     | No       | Object settings. `content_type` sets the content type of the object.                            |
| `options` | [`AzionClientOptions`](#azionclientoptions)     | No       | Request options.                                                                                |

Returns `data` as an [AzionBucketObject](#azionbucketobject) with `key`, `content_type`, and `state`. The created object carries no `content`; read it back with [getObjectByKey](#getobjectbykey).

```typescript
import { createObject } from '@aziontech/storage';
import type { AzionStorageResponse, AzionBucketObject } from '@aziontech/storage';

const { data: newObject, error }: AzionStorageResponse<AzionBucketObject> = await createObject({
  bucket: 'my-bucket',
  key: 'new-file.txt',
  content: 'File content',
  params: { content_type: 'text/plain' },
});
if (newObject) {
  console.log(`Object created with key: ${newObject.key}`);
  console.log(`Content type: ${newObject.content_type}`);
} else {
  console.error('Failed to create object', error);
}
```

Output:

```text
Object created with key: new-file.txt
Content type: text/plain
```

---

## getObjectByKey

Returns one object, with its content, by its key.

```typescript
function getObjectByKey(params: {
  bucket: string;
  key: string;
  options?: AzionClientOptions;
}): Promise<AzionStorageResponse<AzionBucketObject>>;
```

| Parameter | Type                                        | Required | Description                                   |
| --------- | ------------------------------------------- | -------- | --------------------------------------------- |
| `bucket`  | `string`                                    | Yes      | The name of the bucket that holds the object. |
| `key`     | `string`                                    | Yes      | The key of the object.                        |
| `options` | [`AzionClientOptions`](#azionclientoptions) | No       | Request options.                              |

Returns `data` as an [AzionBucketObject](#azionbucketobject) with `key` and `content`. A key that matches no object returns `error` with the message `The specified bucket object does not exist.`.

```typescript
import { getObjectByKey } from '@aziontech/storage';
import type { AzionStorageResponse, AzionBucketObject } from '@aziontech/storage';

const { data: object, error }: AzionStorageResponse<AzionBucketObject> = await getObjectByKey({
  bucket: 'my-bucket',
  key: 'new-file.txt',
});
if (object) {
  console.log(`Retrieved object: ${object.key}`);
  console.log(`Content: ${object.content}`);
} else {
  console.error('Object not found', error);
}
```

Output:

```text
Retrieved object: new-file.txt
Content: File content
```

---

## getObjects

Lists the objects of a bucket.

```typescript
function getObjects(params: {
  bucket: string;
  params?: AzionObjectCollectionParams;
  options?: AzionClientOptions;
}): Promise<AzionStorageResponse<AzionBucketObjects>>;
```

| Parameter | Type                                                          | Required | Description                                                                                          |
| --------- | ------------------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------- |
| `bucket`  | `string`                                                      | Yes      | The name of the bucket to list.                                                                      |
| `params`  | [`AzionObjectCollectionParams`](#azionobjectcollectionparams) | No       | The maximum number of objects to return. Without it, the function requests `max_object_count=10000`. |
| `options` | [`AzionClientOptions`](#azionclientoptions)                   | No       | Request options.                                                                                     |

Returns `data` as an [AzionBucketObjects](#azionbucketobjects): `objects` and `count`. Each listed object carries `key`, `size`, and `last_modified`. The API also returns `is_folder` on each object, which the type does not declare.

```typescript
import { getObjects } from '@aziontech/storage';
import type { AzionStorageResponse, AzionBucketObjects } from '@aziontech/storage';

const { data: objectResult, error }: AzionStorageResponse<AzionBucketObjects> = await getObjects({
  bucket: 'my-bucket',
});
if (objectResult) {
  console.log(`Retrieved ${objectResult.count} objects from the bucket`);
  for (const object of objectResult.objects) console.log(object.key, object.size, object.last_modified);
} else {
  console.error('Failed to retrieve objects', error);
}
```

Output:

```text
Retrieved 1 objects from the bucket
new-file.txt 12 2026-01-01T12:00:00.000000Z
```

---

## updateObject

Replaces the content of an object.

```typescript
function updateObject(params: {
  bucket: string;
  key: string;
  content: ContentObjectStorage;
  params?: { content_type?: string };
  options?: AzionClientOptions;
}): Promise<AzionStorageResponse<AzionBucketObject>>;
```

| Parameter | Type                                            | Required | Description                                                                                                     |
| --------- | ----------------------------------------------- | -------- | --------------------------------------------------------------------------------------------------------------- |
| `bucket`  | `string`                                        | Yes      | The name of the bucket that holds the object.                                                                   |
| `key`     | `string`                                        | Yes      | The key of the object to update.                                                                                |
| `content` | [`ContentObjectStorage`](#contentobjectstorage) | Yes      | The content that replaces the current one: a `string`, an `ArrayBuffer`, a `ReadableStream`, or a `Uint8Array`. |
| `params`  | `{ content_type?: string }`                     | No       | Object settings. `content_type` sets the content type of the object.                                            |
| `options` | [`AzionClientOptions`](#azionclientoptions)     | No       | Request options.                                                                                                |

Returns `data` as the updated [AzionBucketObject](#azionbucketobject), with `key` and `content`.

```typescript
import { updateObject } from '@aziontech/storage';
import type { AzionStorageResponse, AzionBucketObject } from '@aziontech/storage';

const { data: updatedObject, error }: AzionStorageResponse<AzionBucketObject> = await updateObject({
  bucket: 'my-bucket',
  key: 'new-file.txt',
  content: 'Updated content',
});
if (updatedObject) {
  console.log(`Object updated: ${updatedObject.key}`);
  console.log(`New content: ${updatedObject.content}`);
} else {
  console.error('Failed to update object', error);
}
```

Output:

```text
Object updated: new-file.txt
New content: Updated content
```

---

## deleteObject

Deletes an object from a bucket.

```typescript
function deleteObject(params: {
  bucket: string;
  key: string;
  options?: AzionClientOptions;
}): Promise<AzionStorageResponse<AzionDeletedBucketObject>>;
```

| Parameter | Type                                        | Required | Description                                   |
| --------- | ------------------------------------------- | -------- | --------------------------------------------- |
| `bucket`  | `string`                                    | Yes      | The name of the bucket that holds the object. |
| `key`     | `string`                                    | Yes      | The key of the object to delete.              |
| `options` | [`AzionClientOptions`](#azionclientoptions) | No       | Request options.                              |

On success, the envelope holds no `data`, so the sample checks `error`. A key that matches no object fills `error` with `The specified bucket object does not exist.`. Deleting an object also blocks [deleteBucket](#deletebucket) on that bucket for 24 hours.

```typescript
import { deleteObject } from '@aziontech/storage';

const { error } = await deleteObject({
  bucket: 'my-bucket',
  key: 'new-file.txt',
});
if (error) {
  console.error('Failed to delete object', error);
} else {
  console.log('Object new-file.txt deleted');
}
```

Output:

```text
Object new-file.txt deleted
```

---

## Bucket methods

A bucket that [getBucket](#getbucket), [setupStorage](#setupstorage), or [createBucket](#createbucket) returns carries five methods that act on that bucket. Each takes one object and returns the same envelope as the matching function:

| Method           | Argument                                                                             | Returns `data` as                           |
| ---------------- | ------------------------------------------------------------------------------------ | ------------------------------------------- |
| `getObjects`     | `{ params: AzionObjectCollectionParams }` (`params` is required)                     | [`AzionBucketObjects`](#azionbucketobjects) |
| `getObjectByKey` | `{ key: string }`                                                                    | [`AzionBucketObject`](#azionbucketobject)   |
| `createObject`   | `{ key: string; content: ContentObjectStorage; params?: { content_type?: string } }` | [`AzionBucketObject`](#azionbucketobject)   |
| `updateObject`   | `{ key: string; content: ContentObjectStorage; params?: { content_type?: string } }` | [`AzionBucketObject`](#azionbucketobject)   |
| `deleteObject`   | `{ key: string }`                                                                    | none on success; check `error`              |

This sample reads a bucket, then lists, reads, updates, and deletes an object through its methods:

```typescript
import { getBucket } from '@aziontech/storage';

const { data: bucket, error } = await getBucket({ name: 'my-app-bucket' });
if (!bucket) throw new Error(error?.message);

const { data: list } = await bucket.getObjects({ params: { max_object_count: 10 } });
console.log('getObjects:', list?.objects.map((o) => o.key));

const { data: object } = await bucket.getObjectByKey({ key: 'config.json' });
console.log('getObjectByKey:', object?.key, object?.content);

const { data: updated } = await bucket.updateObject({
  key: 'config.json',
  content: '{"theme":"dark"}',
  params: { content_type: 'application/json' },
});
console.log('updateObject:', updated?.key, updated?.content);

const { error: deleteError } = await bucket.deleteObject({ key: 'config.json' });
console.log('deleteObject:', deleteError ? deleteError : 'deleted');
```

Output:

```text
getObjects: [ 'config.json' ]
getObjectByKey: config.json {}
updateObject: config.json {"theme":"dark"}
deleteObject: deleted
```

---

## Errors

A failed call returns these messages in `error.message`. `error.operation` names the call, such as `get all buckets` or `delete bucket`.

| Message                                                                                                                          | Cause                                                                                | What to do                                                                                                                                                                                             |
| -------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `Authentication credentials were not provided.`                                                                                  | No token reached the call: `AZION_TOKEN` is unset and no client `token` was passed.  | Set `AZION_TOKEN`, or pass `token` to [createClient](#createclient).                                                                                                                                   |
| `Invalid authentication credentials.`                                                                                            | The token is not valid.                                                              | Use a valid [personal token](/en/documentation/fundamentals/personal-tokens/).                                                                                                                         |
| `This field is required.`                                                                                                        | The create request has no `workloads_access`.                                        | Pass both `name` and `workloads_access`.                                                                                                                                                               |
| `The specified bucket does not exist.`                                                                                           | No bucket in the account has that name.                                              | Check the name with [getBuckets](#getbuckets).                                                                                                                                                         |
| `The specified bucket object does not exist.`                                                                                    | The bucket holds no object with that key.                                            | Check the key with [getObjects](#getobjects).                                                                                                                                                          |
| `Unable to delete a non-empty bucket. Additionally, objects deleted within the last 24 hours are also taken into consideration.` | The bucket holds objects, or an object was deleted from it within the last 24 hours. | Delete every object, then wait 24 hours after the last deletion. For more information, refer to [Buckets and objects](/en/documentation/platform/object-storage/buckets-and-objects/#delete-a-bucket). |

---

## Types

The package exports these types. Import them with `import type`.

### AzionStorageClient

The client that [createClient](#createclient) returns. Every method takes one object.

| Method         | Argument                                              | Returns                                                |
| -------------- | ----------------------------------------------------- | ------------------------------------------------------ |
| `getBuckets`   | `{ params?: AzionBucketCollectionParams }` (optional) | `Promise<AzionStorageResponse<AzionBucketCollection>>` |
| `getBucket`    | `{ name: string }`                                    | `Promise<AzionStorageResponse<AzionBucket>>`           |
| `createBucket` | `{ name: string; workloads_access: EdgeAccessType }`  | `Promise<AzionStorageResponse<AzionBucket>>`           |
| `updateBucket` | `{ name: string; workloads_access: EdgeAccessType }`  | `Promise<AzionStorageResponse<AzionBucket>>`           |
| `deleteBucket` | `{ name: string }`                                    | `Promise<AzionStorageResponse<AzionDeletedBucket>>`    |
| `setupStorage` | `{ name: string; workloads_access: EdgeAccessType }`  | `Promise<AzionStorageResponse<AzionBucket>>`           |

### AzionClientOptions

Request options that every function takes in `options`, and [createClient](#createclient) takes for all its calls.

| Property   | Type                                    | Required | Description                                                    |
| ---------- | --------------------------------------- | -------- | -------------------------------------------------------------- |
| `debug`    | `boolean`                               | No       | Logs the response bodies the API returns.                      |
| `force`    | `boolean`                               | No       | Forces the operation, even when it can destroy data.           |
| `env`      | [`AzionEnvironment`](#azionenvironment) | No       | The environment the calls go to.                               |
| `external` | `boolean`                               | No       | Forces the REST API instead of the API built into the runtime. |

### AzionEnvironment

The environment a client calls.

```typescript
type AzionEnvironment = 'development' | 'staging' | 'production';
```

### AzionStorageResponse

The envelope every function returns. For how to read it, refer to [Response envelope](#response-envelope).

| Property | Type                                     | Required | Description                                               |
| -------- | ---------------------------------------- | -------- | --------------------------------------------------------- |
| `data`   | `T`                                      | No       | The result of the call. Absent after a successful delete. |
| `error`  | `{ message: string; operation: string }` | No       | The error message and the operation that failed.          |

### AzionBucket

A bucket.

| Property                                                                       | Type                                            | Required | Description                            |
| ------------------------------------------------------------------------------ | ----------------------------------------------- | -------- | -------------------------------------- |
| `name`                                                                         | `string`                                        | Yes      | The name of the bucket.                |
| `workloads_access`                                                             | [`EdgeAccessType`](#edgeaccesstype)             | Yes      | The access level of the bucket.        |
| `state`                                                                        | `'executed' \| 'executed-runtime' \| 'pending'` | No       | The state of the bucket.               |
| `last_editor`                                                                  | `string`                                        | No       | The user who last edited the bucket.   |
| `last_modified`                                                                | `string`                                        | No       | When the bucket was last modified.     |
| `product_version`                                                              | `string`                                        | No       | The product version.                   |
| `getObjects`, `getObjectByKey`, `createObject`, `updateObject`, `deleteObject` | functions                                       | Yes      | The [bucket methods](#bucket-methods). |

### AzionBucketCollection

A page of buckets.

| Property  | Type                            | Required | Description                           |
| --------- | ------------------------------- | -------- | ------------------------------------- |
| `buckets` | [`AzionBucket[]`](#azionbucket) | Yes      | The buckets on the page.              |
| `count`   | `number`                        | Yes      | The number of buckets in the account. |

### AzionBucketCollectionParams

Pagination and filtering for [getBuckets](#getbuckets).

| Property    | Type     | Required | Description                            |
| ----------- | -------- | -------- | -------------------------------------- |
| `page`      | `number` | No       | The page number.                       |
| `page_size` | `number` | No       | The number of buckets per page.        |
| `search`    | `string` | No       | Matches part of a bucket name.         |
| `ordering`  | `string` | No       | The field that orders the results.     |
| `fields`    | `string` | No       | The fields to return, comma-separated. |

### AzionBucketObject

An object in a bucket.

| Property        | Type                                            | Required | Description                        |
| --------------- | ----------------------------------------------- | -------- | ---------------------------------- |
| `key`           | `string`                                        | Yes      | The key of the object.             |
| `state`         | `'executed' \| 'executed-runtime' \| 'pending'` | No       | The state of the object.           |
| `size`          | `number`                                        | No       | The size of the object, in bytes.  |
| `last_modified` | `string`                                        | No       | When the object was last modified. |
| `content_type`  | `string`                                        | No       | The content type of the object.    |
| `content`       | [`ContentObjectStorage`](#contentobjectstorage) | No       | The content of the object.         |

### AzionBucketObjects

A list of objects.

| Property  | Type                                        | Required | Description                        |
| --------- | ------------------------------------------- | -------- | ---------------------------------- |
| `objects` | [`AzionBucketObject[]`](#azionbucketobject) | Yes      | The objects in the bucket.         |
| `count`   | `number`                                    | Yes      | The number of objects in the list. |

### AzionObjectCollectionParams

The limit for [getObjects](#getobjects).

| Property           | Type     | Required | Description                                |
| ------------------ | -------- | -------- | ------------------------------------------ |
| `max_object_count` | `number` | No       | The maximum number of objects per request. |

### AzionDeletedBucket

The type [deleteBucket](#deletebucket) declares for `data`. A successful delete returns no `data`.

| Property | Type                                            | Required | Description              |
| -------- | ----------------------------------------------- | -------- | ------------------------ |
| `name`   | `string`                                        | Yes      | The name of the bucket.  |
| `state`  | `'executed' \| 'executed-runtime' \| 'pending'` | No       | The state of the bucket. |

### AzionDeletedBucketObject

The type [deleteObject](#deleteobject) declares for `data`. A successful delete returns no `data`.

| Property | Type                                            | Required | Description                    |
| -------- | ----------------------------------------------- | -------- | ------------------------------ |
| `key`    | `string`                                        | Yes      | The key of the deleted object. |
| `state`  | `'executed' \| 'executed-runtime' \| 'pending'` | No       | The state of the deletion.     |

### ContentObjectStorage

The content an object takes.

```typescript
type ContentObjectStorage = ArrayBuffer | ReadableStream | Uint8Array | string;
```

### EdgeAccessType

The access level of a bucket: what the Azion platform may do with it when an application serves it. For what each value allows, refer to [Access levels](/en/documentation/platform/object-storage/buckets-and-objects/#access-levels).

```typescript
type EdgeAccessType = 'read_only' | 'read_write' | 'restricted';
```

---

## Related resources

- [Azion Lib](/en/documentation/devtools/azion-lib.md): The libraries Azion Lib ships and the package that carries each one.
- [Client](/en/documentation/devtools/azion-lib/client.md): One client for Storage, SQL, Purge, Domains, Applications, and AI.
- [Object Storage](/en/documentation/platform/object-storage.md): What a bucket stores and how an application serves it.
- [Buckets and objects](/en/documentation/platform/object-storage/buckets-and-objects.md): Bucket names, object keys, access levels, and the API calls these functions make.
