# client.files

> The files methods of the morevoice Python SDK: Documents you upload for a later request, such as a port's signed LOA.

Documents you upload for a later request, such as a port's signed LOA. These methods are on `client.files`, where `client` is a `MoreVoice` client (see [the Python SDK](https://docs.morevoice.ai/sdk/python/#connect)). On `AsyncMoreVoice` the same methods are awaited. Each one returns the response object and raises an exception when the API answers with an error.

## `create()`

**Upload a file.** Uploads a document for a later request, as multipart/form-data (a `file` part and `purpose`) or as JSON with the file base64: a PDF, JPEG or PNG of up to 10 MB (the type is read from the file itself). Today's purpose is `port_document`: the signed LOA and the latest invoice of a port (POST /v1/ports). The file is stored encrypted; a file is used by one request, and an unused one is deleted after 7 days. At most 50 unused files at a time. Needs a live key and number porting on.

```python
# client.files
def create(self, body: _m.FileCreateParamsInput | _m.FilesCreateFilesBody | Mapping[str, Any] | Unset = UNSET, *, more_voice_version: str | Unset = UNSET, idempotency_key: str | Unset = UNSET) -> _m.File
```

`client.files.create()` · `await async_client.files.create()` · `POST /files` · [API reference](https://docs.morevoice.ai/api/operations/files_create/)

### Request body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `purpose` | `"port_document"` | yes | What the file is for: `port_document`. |
| `file` | `object` | yes | The document. JSON requests send it base64; multipart/form-data requests send a `file` part. |

### Returns

`File`:

| Field | Type | Description |
| --- | --- | --- |
| `object` | `"file"` | Always `file`. |
| `id` | `string` | A file ID (prefix `file_`). |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `purpose` | `"port_document"` | What the file is for: `port_document` (a port's signed LOA or latest invoice). |
| `filename` | `string` | — |
| `mime_type` | `string` | application/pdf, image/jpeg or image/png (read from the file itself). |
| `size_bytes` | `integer` | — |
| `sha256` | `string` | SHA-256 of the file's bytes (hex). |
| `used` | `boolean` | A request took it (a file is used once). |
| `expires_at` | `string \| null` | An unused file is deleted after this; null once used. |
| `created` | `string` | An ISO-8601 timestamp in UTC. |

### Example

```python
from morevoice import MoreVoice

client = MoreVoice()  # MOREVOICE_API_KEY from the environment

file = client.files.create({
    "file": {
        "content_base64": "JVBERi0xLjQKJcfsj6IK",
        "filename": "loa-signed.pdf",
    },
    "purpose": "port_document",
})
print(file)
```

## `retrieve()`

**Retrieve a file.** An uploaded file's facts (purpose, type, size, SHA-256, whether a request used it). The file itself is never returned.

```python
# client.files
def retrieve(self, id: str, *, more_voice_version: str | Unset = UNSET) -> _m.File
```

`client.files.retrieve()` · `await async_client.files.retrieve()` · `GET /files/{id}` · [API reference](https://docs.morevoice.ai/api/operations/files_retrieve/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `str` | yes | A file ID (`file_…`). |

### Returns

`File`:

| Field | Type | Description |
| --- | --- | --- |
| `object` | `"file"` | Always `file`. |
| `id` | `string` | A file ID (prefix `file_`). |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `purpose` | `"port_document"` | What the file is for: `port_document` (a port's signed LOA or latest invoice). |
| `filename` | `string` | — |
| `mime_type` | `string` | application/pdf, image/jpeg or image/png (read from the file itself). |
| `size_bytes` | `integer` | — |
| `sha256` | `string` | SHA-256 of the file's bytes (hex). |
| `used` | `boolean` | A request took it (a file is used once). |
| `expires_at` | `string \| null` | An unused file is deleted after this; null once used. |
| `created` | `string` | An ISO-8601 timestamp in UTC. |

### Example

```python
from morevoice import MoreVoice

client = MoreVoice()  # MOREVOICE_API_KEY from the environment

file = client.files.retrieve("file_7Hk2Lm9Qp")
print(file)
```
