> ## Documentation Index
> Fetch the complete documentation index at: https://developer.vetcove.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create an uploaded file

> 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']}")
```




## OpenAPI

````yaml post /ext/v2/uploaded-files/
openapi: 3.1.0
info:
  description: ''
  title: NinjaAPI
  version: 2.0.0
servers:
  - url: https://connect.vetcove.com/
security: []
paths:
  /ext/v2/uploaded-files/:
    post:
      tags:
        - File Uploads
      summary: Create an uploaded file
      description: |
        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']}")
        ```
      operationId: uploaded_files_create
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExternalUploadedFileCreateSchema'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExternalUploadedFileSchema'
          description: Created
      security:
        - ExternalAPIAuth: []
components:
  schemas:
    ExternalUploadedFileCreateSchema:
      properties:
        filename:
          description: The filename of the file that was uploaded
          title: Filename
          type: string
        key:
          description: The key to which the file was uploaded
          title: Key
          type: string
      required:
        - key
        - filename
      title: ExternalUploadedFileCreateSchema
      type: object
    ExternalUploadedFileSchema:
      properties:
        filename:
          description: The filename of the file that was uploaded
          title: Filename
          type: string
        filesize:
          description: The size of the uploaded file in bytes
          title: Filesize
          type: integer
        id:
          description: The unique identifier of the file that was uploaded
          title: Id
          type: integer
        url:
          description: >-
            A pre-signed URL good for 1 hour which can be used to download this
            file
          title: Url
          type: string
      required:
        - id
        - url
        - filename
        - filesize
      title: ExternalUploadedFileSchema
      type: object
  securitySchemes:
    ExternalAPIAuth:
      scheme: bearer
      type: http

````