# Upload one part through the API (web app path)

URL: https://neattrim.com/docs/api/upload-part

PUT /v1/uploads/{id}/parts/{n}: Upload one part through the API (web app path).

Endpoint: `PUT /v1/uploads/{id}/parts/{n}`

Who can call it: An API key, or an OAuth token for an app.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes |  |
| `n` | path | integer | yes |  |
| `Content-Digest` | header | string | yes |  |

## Examples

Set NEATTRIM_API_KEY to your key, then copy an example. A tool that draws from your allowance reads an uploaded file: upload a sample file as in the quickstart and set VIDEO_FILE_ID (or AUDIO_FILE_ID, IMAGE_FILE_ID, SUBTITLES_FILE_ID) to its file_id. Any other id in an example, such as JOB_ID, is read from a variable of the same name.

### curl

```bash
curl -X PUT "https://api.neattrim.com/v1/uploads/$UPLOAD_ID/parts/1" \
  -H "Authorization: Bearer $NEATTRIM_API_KEY" \
  -H "Content-Type: application/octet-stream" \
  --data-binary @sample.mp4
```

### TypeScript

```ts
import { readFile } from "node:fs/promises";
// @neattrim/sdk is not on npm yet: it arrives with the first client release. Use the curl example today.
import { api, Neattrim, unwrap } from "@neattrim/sdk";

const client = new Neattrim({ apiKey: process.env.NEATTRIM_API_KEY });
const result = unwrap(
  await api.uploadPart({
    client: client.client,
    path: { id: process.env.UPLOAD_ID ?? "", n: 1 },
    body: new Blob([await readFile("sample.mp4")]),
  }),
);
console.log(result);
```

### Python

```python
# neattrim is not on PyPI yet: it arrives with the first client release. Use the curl example today.
import os

from neattrim import Neattrim
from neattrim_generated.api.uploads import upload_part

with Neattrim(api_key=os.environ["NEATTRIM_API_KEY"], base_url="https://api.neattrim.com") as client:
    result = upload_part.sync(os.environ["UPLOAD_ID"], 1, client=client.client, body=open("sample.mp4", "rb").read())
    print(result)
```

## Response 200

Part stored

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `etag` | string | no |  |

## Errors

- `401`: UNAUTHENTICATED or INACTIVE
- `404`: NOT_FOUND (also for other accounts' ids)
- `413`: TOO_BIG or TOO_LONG for the caller's plan
- `422`: SOURCE_REFUSED, PART_CORRUPT, CONTENT_REFUSED, NOT_HEARD, TOO_SHORT or CHECKOUT_UNAVAILABLE
- `429`: RATE_LIMITED
