# Create Upload Task

> Common

Create file upload task, automatically determines whether to use normal upload or multipart upload based on file size.
- ≤10MB: Returns normal upload URL
- >10MB: Returns multipart upload information

## Endpoint

`POST https://api.modelverse.cn/v1/chanjing/files/create_upload`

## Request Body

## Responses

- **200** — Upload task created successfully
- **400** — 
- **401** — 

## OpenAPI Definition

```json
{
  "openapi": "3.0.3",
  "info": {
    "title": "ModelVerse Chanjing File Management API",
    "description": "Chanjing file management API for uploading and managing file resources required for digital humans, lip sync videos, etc.\n\n**File Upload Workflow:**\n1. Call `POST /v1/chanjing/files/create_upload` to create upload task\n2. Upload based on returned `upload_type`:\n   - `single`: Direct PUT upload using `upload_url`\n   - `multipart`: PUT upload to each part's `upload_url` in sequence\n3. After multipart upload completes, call `POST /v1/chanjing/files/complete` to complete merge\n4. Use returned `chanjing_file_id` to submit tasks\n\n**Service Types:**\n- `customised_person` - Custom digital human\n- `prompt_audio` - Accent conversion voice material\n- `make_video_audio` - Lip sync audio\n- `make_video_background` - Video composition background material\n- `lip_sync_video` - Lip sync video\n- `lip_sync_audio` - Lip sync audio\n- `ai_creation` - AI creation\n",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.modelverse.cn",
      "description": "ModelVerse API Server"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/v1/chanjing/files/create_upload": {
      "post": {
        "summary": "Create Upload Task",
        "description": "Create file upload task, automatically determines whether to use normal upload or multipart upload based on file size.\n- ≤10MB: Returns normal upload URL\n- >10MB: Returns multipart upload information\n",
        "operationId": "createChanjingUploadTask",
        "tags": [
          "Chanjing File Management"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateUploadRequest"
              },
              "examples": {
                "singleUpload": {
                  "summary": "Normal Upload (≤10MB)",
                  "value": {
                    "service": "lip_sync_video",
                    "filename": "test_video.mp4",
                    "file_size": 5242880
                  }
                },
                "multipartUpload": {
                  "summary": "Multipart Upload (>10MB)",
                  "value": {
                    "service": "lip_sync_video",
                    "filename": "large_video.mp4",
                    "file_size": 52428800
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Upload task created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/SingleUploadResponse"
                    },
                    {
                      "$ref": "#/components/schemas/MultipartUploadResponse"
                    }
                  ]
                },
                "examples": {
                  "singleUpload": {
                    "summary": "Normal upload response",
                    "value": {
                      "id": "5a31046b0df853c6eb972e24ef5fe6f2",
                      "upload_type": "single",
                      "upload_url": "https://chanjing-prod.oss-cn-shanghai.aliyuncs.com/xxx?OSSAccessKeyId=...",
                      "chanjing_file_id": "ea10fde334914dd4ba2ac3cd4d3ac4dc",
                      "full_path": "https://res.chanjing.cc/chanjing/res/37/person/trained/customised_person_example.mp4",
                      "headers": {
                        "Content-Type": "video/mp4"
                      },
                      "mime_type": "video/mp4",
                      "expires_at": 1704070800
                    }
                  },
                  "multipartUpload": {
                    "summary": "Multipart upload response",
                    "value": {
                      "id": "5a31046b0df853c6eb972e24ef5fe6f2",
                      "upload_type": "multipart",
                      "upload_id": "0002-4F6B3A4B8A7D",
                      "chanjing_file_id": "921d1db5355c4ccb84d9dbe787d10095",
                      "full_path": "https://res.chanjing.cc/chanjing/res/37/person/trained/customised_person_example.mp4",
                      "mime_type": "video/mp4",
                      "headers": {
                        "Content-Type": "video/mp4"
                      },
                      "part_size": 10485760,
                      "part_count": 3,
                      "parts": [
                        {
                          "part_number": 1,
                          "size": 10485760,
                          "upload_url": "https://chanjing-prod.oss-cn-shanghai.aliyuncs.com/part1?..."
                        },
                        {
                          "part_number": 2,
                          "size": 10485760,
                          "upload_url": "https://chanjing-prod.oss-cn-shanghai.aliyuncs.com/part2?..."
                        },
                        {
                          "part_number": 3,
                          "size": 5242880,
                          "upload_url": "https://chanjing-prod.oss-cn-shanghai.aliyuncs.com/part3?..."
                        }
                      ],
                      "expires_at": 1784196000
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/v1/chanjing/files/complete": {
      "post": {
        "summary": "Complete Multipart Upload",
        "description": "Call this interface to notify the server to merge parts after all parts are uploaded.\nOnly required for multipart upload mode.\n",
        "operationId": "completeChanjingMultipartUpload",
        "tags": [
          "Chanjing File Management"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompleteUploadRequest"
              },
              "example": {
                "upload_id": "2BE130641D284A2C90A277E7732DAFA2"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Parts merged successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompleteUploadResponse"
                },
                "example": {
                  "id": "df71e8a5189bc2908497c5ef2b0ba254",
                  "chanjing_file_id": "e284db4d95de4220afe78132158156b5",
                  "full_path": "https://res.chanjing.cc/chanjing/res/37/person/trained/customised_person_example.mp4",
                  "status": 0
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/v1/chanjing/files/{id}": {
      "get": {
        "summary": "Get File Details",
        "description": "Query detailed information and status of specified file",
        "operationId": "getChanjingFileDetail",
        "tags": [
          "Chanjing File Management"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "File ID (chanjing_file_id)",
            "schema": {
              "type": "string"
            },
            "example": "ea10fde334914dd4ba2ac3cd4d3ac4dc"
          }
        ],
        "responses": {
          "200": {
            "description": "File details retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FileDetailResponse"
                },
                "example": {
                  "id": "5a31046b0df853c6eb972e24ef5fe6f2",
                  "chanjing_file_id": "ea10fde334914dd4ba2ac3cd4d3ac4dc",
                  "service": "lip_sync_video",
                  "bytes": 5242880,
                  "create_time": 1704067200,
                  "file_path": "https://res.chanjing.cc/chanjing/res/35551/lip_sync/video/xxx.mp4",
                  "status": 1,
                  "msg": ""
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "delete": {
        "summary": "Delete File",
        "description": "Delete specified file",
        "operationId": "deleteChanjingFile",
        "tags": [
          "Chanjing File Management"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "File ID (chanjing_file_id)",
            "schema": {
              "type": "string"
            },
            "example": "ea10fde334914dd4ba2ac3cd4d3ac4dc"
          }
        ],
        "responses": {
          "200": {
            "description": "File deleted successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteFileResponse"
                },
                "example": {
                  "id": "746355542a2e96c1e8a56b8b91f561b6",
                  "chanjing_file_id": "ea10fde334914dd4ba2ac3cd4d3ac4dc",
                  "deleted": true
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/v1/chanjing/files": {
      "get": {
        "summary": "List Files",
        "description": "Paginated query of file list for specified service type",
        "operationId": "listChanjingFiles",
        "tags": [
          "Chanjing File Management"
        ],
        "parameters": [
          {
            "name": "service",
            "in": "query",
            "required": true,
            "description": "File purpose filter",
            "schema": {
              "type": "string",
              "enum": [
                "customised_person",
                "prompt_audio",
                "make_video_audio",
                "make_video_background",
                "lip_sync_video",
                "lip_sync_audio",
                "ai_creation"
              ]
            },
            "example": "lip_sync_video"
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "description": "Page number, default 1",
            "schema": {
              "type": "integer",
              "default": 1
            }
          },
          {
            "name": "size",
            "in": "query",
            "required": false,
            "description": "Items per page, default 20",
            "schema": {
              "type": "integer",
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "File list retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FileListResponse"
                },
                "example": {
                  "id": "df71e8a5189bc2908497c5ef2b0ba254",
                  "data": [
                    {
                      "chanjing_file_id": "e284db4d95de4220afe78132158156b5",
                      "service": "customised_person",
                      "bytes": 0,
                      "create_time": 1753239619,
                      "file_path": "https://www.chanjing.cc/chanjing/res/37/person/trained/customised_person_1753239619_ea65d88474ba4501b8f72903cdf5d3af.mp4",
                      "status": 1,
                      "msg": ""
                    }
                  ],
                  "total_count": 1,
                  "page": 1,
                  "size": 10,
                  "has_more": false
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "API Key authentication, format: Bearer {api_key}"
      }
    },
    "schemas": {
      "CreateUploadRequest": {
        "type": "object",
        "required": [
          "service",
          "filename",
          "file_size"
        ],
        "properties": {
          "service": {
            "type": "string",
            "description": "File purpose",
            "enum": [
              "customised_person",
              "prompt_audio",
              "make_video_audio",
              "make_video_background",
              "lip_sync_video",
              "lip_sync_audio",
              "ai_creation"
            ]
          },
          "filename": {
            "type": "string",
            "description": "File name with extension"
          },
          "file_size": {
            "type": "integer",
            "format": "int64",
            "description": "File size in bytes, ≤10MB uses normal upload, >10MB uses multipart upload"
          }
        }
      },
      "SingleUploadResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Chanjing request trace_id"
          },
          "upload_type": {
            "type": "string",
            "enum": [
              "single"
            ],
            "description": "Upload type"
          },
          "upload_url": {
            "type": "string",
            "description": "Normal upload URL (PUT request)"
          },
          "chanjing_file_id": {
            "type": "string",
            "description": "Chanjing file ID (used when submitting tasks)"
          },
          "full_path": {
            "type": "string",
            "description": "Final accessible file URL"
          },
          "headers": {
            "type": "object",
            "description": "Request headers required for upload"
          },
          "mime_type": {
            "type": "string",
            "description": "File MIME type"
          },
          "expires_at": {
            "type": "integer",
            "description": "Upload URL expiration time (Unix timestamp)"
          }
        }
      },
      "MultipartUploadPart": {
        "type": "object",
        "properties": {
          "part_number": {
            "type": "integer",
            "description": "Part sequence number"
          },
          "size": {
            "type": "integer",
            "format": "int64",
            "description": "Part size in bytes"
          },
          "upload_url": {
            "type": "string",
            "description": "Part upload URL"
          }
        }
      },
      "MultipartUploadResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Chanjing request trace_id"
          },
          "upload_type": {
            "type": "string",
            "enum": [
              "multipart"
            ],
            "description": "Upload type"
          },
          "upload_id": {
            "type": "string",
            "description": "Multipart upload task ID"
          },
          "chanjing_file_id": {
            "type": "string",
            "description": "Chanjing file ID"
          },
          "full_path": {
            "type": "string",
            "description": "Final accessible file URL"
          },
          "mime_type": {
            "type": "string",
            "description": "File MIME type"
          },
          "headers": {
            "type": "object",
            "description": "Request headers required for upload"
          },
          "part_size": {
            "type": "integer",
            "description": "Part size in bytes"
          },
          "part_count": {
            "type": "integer",
            "description": "Number of parts"
          },
          "parts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MultipartUploadPart"
            },
            "description": "Parts list"
          },
          "expires_at": {
            "type": "integer",
            "description": "Upload URL expiration time (Unix timestamp)"
          }
        }
      },
      "CompleteUploadRequest": {
        "type": "object",
        "required": [
          "upload_id"
        ],
        "properties": {
          "upload_id": {
            "type": "string",
            "description": "Upload ID returned when creating upload"
          }
        }
      },
      "CompleteUploadResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Chanjing request trace_id"
          },
          "chanjing_file_id": {
            "type": "string",
            "description": "Chanjing file ID"
          },
          "full_path": {
            "type": "string",
            "description": "Final accessible file URL"
          },
          "status": {
            "type": "integer",
            "description": "File status:\n- 0: Merge complete, waiting for async content review\n- 1: File available\n- 98: Content security check failed\n- 99: Marked for deletion\n- 100: Cleaned up\n"
          }
        }
      },
      "FileDetailResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Chanjing request trace_id"
          },
          "chanjing_file_id": {
            "type": "string",
            "description": "Chanjing file ID"
          },
          "service": {
            "type": "string",
            "description": "File purpose"
          },
          "bytes": {
            "type": "integer",
            "format": "int64",
            "description": "File size in bytes"
          },
          "create_time": {
            "type": "integer",
            "description": "Creation time (Unix timestamp)"
          },
          "file_path": {
            "type": "string",
            "description": "File access URL"
          },
          "status": {
            "type": "integer",
            "description": "File status:\n- 0: Merge complete, waiting for async content review\n- 1: File available\n- 98: Content security check failed\n- 99: Marked for deletion\n- 100: Cleaned up\n"
          },
          "msg": {
            "type": "string",
            "description": "Status message"
          }
        }
      },
      "DeleteFileResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Chanjing request trace_id"
          },
          "chanjing_file_id": {
            "type": "string",
            "description": "Chanjing file ID"
          },
          "deleted": {
            "type": "boolean",
            "description": "Whether deletion was successful"
          }
        }
      },
      "FileListItem": {
        "type": "object",
        "properties": {
          "chanjing_file_id": {
            "type": "string",
            "description": "Chanjing file ID"
          },
          "service": {
            "type": "string",
            "description": "File purpose"
          },
          "bytes": {
            "type": "integer",
            "format": "int64",
            "description": "File size in bytes"
          },
          "create_time": {
            "type": "integer",
            "description": "Creation time (Unix timestamp)"
          },
          "file_path": {
            "type": "string",
            "description": "File access URL"
          },
          "status": {
            "type": "integer",
            "description": "File status"
          },
          "msg": {
            "type": "string",
            "description": "Status message"
          }
        }
      },
      "FileListResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Chanjing request trace_id"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FileListItem"
            },
            "description": "File list"
          },
          "total_count": {
            "type": "integer",
            "description": "Total file count"
          },
          "page": {
            "type": "integer",
            "description": "Current page number"
          },
          "size": {
            "type": "integer",
            "description": "Items per page"
          },
          "has_more": {
            "type": "boolean",
            "description": "Whether there are more items"
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "description": "Error code"
              },
              "message": {
                "type": "string",
                "description": "Error message"
              }
            }
          }
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Invalid request parameters",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "error": {
                "code": "invalid_request",
                "message": "service is required"
              }
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Authentication failed",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "error": {
                "code": "unauthorized",
                "message": "missing token"
              }
            }
          }
        }
      },
      "NotFound": {
        "description": "Resource not found",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "error": {
                "code": "not_found",
                "message": "file not found"
              }
            }
          }
        }
      },
      "InternalError": {
        "description": "Internal server error",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "error": {
                "code": "internal_error",
                "message": "complete multipart upload failed"
              }
            }
          }
        }
      }
    }
  }
}
```
