Skip to main content
This guide demonstrates how to upload files to an Oxen repository using the HTTP API. We’ll break down the process into simple, manageable steps.

Overview

Uploading a file to Oxen involves three main steps:
  1. Create a repository (if it doesn’t exist)
  2. Upload the file to a specific branch
  3. Optionally create additional branches from the uploaded content

Prerequisites

Before you begin, you’ll need:
  • API Key: Authentication token for your Oxen account
  • Server URL: The Oxen server endpoint (e.g., https://hub.oxen.ai or your local server)
  • File to upload: The local file you want to add to your repository

Configuration

First, set up your configuration variables:

Step 1: Create a Repository

Create a new repository to store your files. If the repository already exists, this step will return a 409 status code and you can continue.

Endpoint

Example

Request Body

Response

Step 2: Upload a File

Upload a file to your repository. This creates a commit on the specified branch with your file.

Endpoint

Path Parameters

Example

Request Body (Multipart Form Data)

Note: You can upload multiple files in a single request by including multiple file fields with different filenames.

Response

Step 3: Create a Branch (Optional)

After uploading files, you can create additional branches from your main branch.

Endpoint

Example

Request Body

Response

Complete Example

Here’s a complete Python script that ties everything together:

Authentication

All API requests require authentication using a Bearer token in the Authorization header:

Getting an API Key

  1. Log in to your Oxen account at hub.oxen.ai
  2. Navigate to your account settings
  3. Generate a new API key

Advanced Usage

Uploading Multiple Files

You can upload multiple files in a single request by including multiple file fields:
Or upload files one at a time:

Uploading to Different Branches

Organizing Files in Directories

Files are automatically organized based on the remote_file_path:

Next Steps