---
title: Create a File Upload
url: https://runapi.ai/docs/api/files/create.md
canonical: https://runapi.ai/docs/api/files/create
locale: en
---

# Create a File Upload

Upload one local file, remote HTTPS URL, or base64 source and receive a temporary URL.

## Endpoint

POST /api/v1/files

Base URL: https://runapi.ai

API version: v1

Authentication: Authorization: Bearer YOUR_API_KEY

## Request

Send values only in the listed request location.

### application/json - Base64 source

```json
{
  "file_name": {
    "description": "Optional filename for the created File Upload.",
    "required": false,
    "type": "string"
  },
  "source": {
    "description": "Base64-encoded source bytes.",
    "properties": {
      "data": {
        "description": "Base64 data",
        "required": true,
        "type": "string"
      },
      "type": {
        "description": "Selects the base64 source representation.",
        "required": true,
        "type": "string"
      }
    },
    "required": true,
    "type": "object"
  }
}
```

### application/json - URL source

```json
{
  "file_name": {
    "description": "Optional filename for the created File Upload.",
    "required": false,
    "type": "string"
  },
  "source": {
    "description": "Remote HTTPS source to download.",
    "properties": {
      "type": {
        "description": "Selects the URL source representation.",
        "required": true,
        "type": "string"
      },
      "url": {
        "description": "Public HTTPS URL to download.",
        "format": "uri",
        "required": true,
        "type": "string"
      }
    },
    "required": true,
    "type": "object"
  }
}
```

### multipart/form-data

```json
{
  "file": {
    "description": "Local file bytes to upload.",
    "format": "binary",
    "required": true,
    "type": "string"
  },
  "file_name": {
    "description": "Optional filename for the created File Upload.",
    "required": false,
    "type": "string"
  }
}
```

## Success response

HTTP 201 - POST /api/v1/files

```json
{
  "created_at": "2026-07-27T10:00:00.000Z",
  "expires_at": "2026-07-27T11:00:00.000Z",
  "file_name": "mask.png",
  "mime_type": "image/png",
  "size_bytes": 204800,
  "url": "https://file.runapi.ai/temp/user-uploads/mask.png"
}
```

## Error response (401)

HTTP 401

```json
{
  "error": {
    "code": "authentication_required",
    "message": "Authentication required"
  }
}
```

## Error response (403)

HTTP 403

```json
{
  "error": {
    "code": "standard_api_key_required",
    "message": "Standard API key required"
  }
}
```

## Error response (400)

HTTP 400

```json
{
  "error": {
    "code": "invalid_source",
    "message": "Only HTTPS URLs are allowed"
  }
}
```

## Error response (408)

HTTP 408

```json
{
  "error": {
    "code": "invalid_source",
    "message": "Download timeout"
  }
}
```

## Error response (413)

HTTP 413

```json
{
  "error": {
    "code": "file_too_large",
    "message": "File size exceeds the maximum allowed size"
  }
}
```

## Error response (415)

HTTP 415

```json
{
  "error": {
    "code": "unsupported_media_type",
    "message": "This content type is not supported"
  }
}
```

## Error response (422)

HTTP 422

```json
{
  "error": {
    "code": "upload_failed",
    "message": "File upload failed. Please try again."
  }
}
```

## Error response (429)

HTTP 429

```json
{
  "error": {
    "code": "rate_limited",
    "message": "Too many file uploads for this account. Please retry later."
  }
}
```

## cURL example



### curl

```curl
curl -X POST https://runapi.ai/api/v1/files \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{"source":{"type":"url","url":"https://cdn.runapi.ai/public/samples/mask.png"},"file_name":"mask.png"}'
```

## Related reference

- [Files](/docs/api/files)
- [File Upload object](/docs/api/files/object)
