---
title: "Create an uploaded file"
method: POST
path: "/ext/v2/uploaded-files/"
tags: ["File Uploads"]
---

# Create an uploaded file

`POST /ext/v2/uploaded-files/`

## Request

- Base URL: `https://connect.vetcove.com`
- URL: `https://connect.vetcove.com/ext/v2/uploaded-files/`
- Auth: HTTP bearer

Create an uploaded file after uploading the raw file to our file server.

The entire flow for uploaded files to us is as follows:
1. Call the `generate-upload-url` endpoint to initiate an upload.
2. POST your file to the returned URL, including the returned form data.
3. Call this endpoint to register your uploaded file with our system.

It would look something like this in python:
```
import requests
api_session = requests.Session()
api_session.headers.update({"Authorization": f"Bearer {API_KEY}"})
s3_session = requests.Session()

# Step 1: Get an upload URL.
response = api_session.post(
    f"{VETCOVE_API_SERVER}/ext/v2/uploaded-files/generate-upload-url/",
    json={
        "filename": "example.jpg",
        "content_type": "image/jpg"
    }
)
response.raise_for_status()

# Step 2: Extract the necessary values from the response.
key = response.json()["key"]
upload_url = response.json()["url"]
upload_post_data = response.json()["post_data"]

# Step 3: Upload the file to our file server (Amazon S3).
with open(LOCAL_PATH_TO_FILE_UPLOAD, "rb") as f:
    response = s3_session.post(upload_url, data=upload_post_data, files={"file": f})
response.raise_for_status()

# Step 4: Register the uploaded file with Vetcove.
response = api_session.post(
    f"{VETCOVE_API_SERVER}/ext/v2/uploaded-files/",
    json={
        "filename": "example.jpg",
        "key": key,
    }
)
response.raise_for_status()
print(f"Created uploaded file with id {response.json()['id']}")
```

## Request body

- ExternalUploadedFileCreateSchema
  - `filename` string, required: The filename of the file that was uploaded
  - `key` string, required: The key to which the file was uploaded

## Response `201`

Created

- ExternalUploadedFileSchema
  - `filename` string, required: The filename of the file that was uploaded
  - `filesize` integer, required: The size of the uploaded file in bytes
  - `id` integer, required: The unique identifier of the file that was uploaded
  - `url` string, required: A pre-signed URL good for 1 hour which can be used to download this file

---

[API](https://skmtc.dev/vetcove/apis/ninjaapi.md) - [All operations](https://skmtc.dev/vetcove/apis/ninjaapi/llms.txt) - [OpenAPI document](https://skmtc.dev/vetcove/apis/ninjaapi/revisions/4ceaed956e15?raw)
