Uncanned Axum API Documentation

A secure API for user authentication and S3 file uploads built with Rust, Axum, and Diesel.

Authentication Endpoints

POST /register

Register a new user account

Request Body:

{
  "email": "user@example.com",
  "password": "securepassword123"
}

Response (200):

{
  "user_id": "550e8400-e29b-41d4-a716-446655440000",
  "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
}

Error Responses:

POST /login

Authenticate with existing credentials

Request Body:

{
  "email": "user@example.com",
  "password": "securepassword123"
}

Response (200):

{
  "user_id": "550e8400-e29b-41d4-a716-446655440000",
  "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
}

Error Responses:

Testing the API

You can test these endpoints using curl:

Register:

curl -X POST http://localhost:3000/register \
  -H "Content-Type: application/json" \
  -d '{"email": "test@example.com", "password": "password123"}'

Login:

curl -X POST http://localhost:3000/login \
  -H "Content-Type: application/json" \
  -d '{"email": "test@example.com", "password": "password123"}'

Upload Endpoints

POST /api/v1/uploads/presign-batch

Generate presigned URLs for batch file uploads to S3

Request Body:

{
  "files": [
    {
      "client_path": "Music/track01.mp3",
      "size": 7340032,
      "content_type": "audio/mpeg",
      "checksum_sha256": "optional-base64url",
      "last_modified": 1731000000000
    }
  ],
  "multipart_threshold_bytes": 5242880,
  "part_size_bytes": 8388608
}

Response (200):

{
  "entries": [
    {
      "upload_id": "uuid",
      "s3_key": "uploads/user/2024/12/01/uuid_track01.mp3",
      "mode": "single",
      "put_url": "https://bucket.s3.amazonaws.com/...presigned...",
      "ttl_seconds": 1800,
      "headers": {
        "Content-Type": "audio/mpeg",
        "x-amz-meta-client-path": "Music/track01.mp3"
      }
    }
  ]
}

Error Responses:

POST /api/v1/uploads/complete

Complete a file upload and finalize multipart uploads if applicable

Request Body (Single):

{
  "file": {
    "upload_id": "uuid",
    "s3_key": "uploads/.../track01.mp3",
    "mode": "single",
    "etag": "\"2f8c...\""
  }
}

Request Body (Multipart):

{
  "file": {
    "upload_id": "uuid",
    "s3_key": "uploads/.../bigfile.wav",
    "mode": "multipart",
    "aws_upload_id": "aws-upload-id",
    "parts": [
      { "part_number": 1, "etag": "\"etag1\"" }
    ]
  }
}

Response (200):

{ "ok": true }

Error Responses:

POST /api/v1/uploads/abort

Abort an in-progress multipart upload

Request Body:

{
  "upload_id": "uuid",
  "s3_key": "uploads/.../bigfile.wav",
  "aws_upload_id": "aws-upload-id"
}

Response (200):

{ "ok": true }

Error Responses:

Security Features

← Back to API