ChatDOC
  1. Documents
ChatDOC
  • Documents
    • Upload Document
      POST
    • Upload Document
      POST
    • Get Document
      GET
    • Delete Document
      DELETE
    • Download Document
      GET
  • Collections
    • Create Collection
      POST
    • Clone Document To Collection
      POST
  • Questions
    • Get Suggested Questions
      GET
    • Ask Question
      POST
    • Get Question
      GET
    • Ask Question With Multiple Documents
      POST
  • Users
    • Get Quota
      GET
  1. Documents

Upload Document

Develop Env
https://dev.your-api-server.com
Develop Env
https://dev.your-api-server.com
POST
/documents/upload
Upload a document
Response:
id: document id, also called upload_id, you can use it to get the document by GET /documents/{upload_id}. It's of uuid format.
Please note: you should store id in your database, because we don't have a GET /documents/list API to list all documents for now.
status: Once uploaded, the status is UN_PARSED, after a series of processing, the
status would change by time, and finally to be one of the following two cases:
UN_PARSED = 1              file uploaded or collection has no document
# final statuses
ELEMENT_PARSED = 300       analysis of the document has succeeded
ERROR_STATUSES (< 0)       error occurred during analysis
So before the document status finalized, you can poll the status by
GET /documents/{upload_id} at interval of 10s , generally it takes 1-2 minutes to
finish depending on content length of the document. If error occurred, it doesn't consume your quota.
Please note:
Uploading files consumes your pages quota, and uploading same files again will still consume quota.
We'll keep your uploaded file for one year. If you do not make another payment for the API after one year, the file will be permanently deleted.
Usage instructions for the OCR field:
OCR Pages Package must be used in conjunction with PDF Pages Package; both packages are deducted equally.
Three parameters are available: defaults to disable, with optional values auto or force.
When OCR is set to force, it allows OCR Pages Package usage for Word documents. However, for other document types like ePub and Markdown, it won't take effect.
For reference, other statuses are as follows:
UN_PARSED = 1                      file uploaded or collection has no document
LINK_UN_PARSED = 10                file link submitted
PARSING = 12                       parsing, mainly used for collection
LINK_DOWNLOADING = 15              file link downloading
PDF_CONVERTING = 20                docx to pdf converting
PDF_CONVERTED = 30                 docx to pdf success
TEXT_PARSING = 40                  text embedding(when element parse timeout 2min)
ELEMENT_PARSING = 50               element embedding
INSIGHT_CALLBACK = 70              element parse success
TEXT_PARSED = 210                  text embedding success
ELEMENT_PARSED = 300               element embedding success
TEXT_PARSE_ERROR = -1              text embedding failed
ELEMENT_PARED_ERROR = -2           element embedding failed
PDF_CONVERT_ERROR = -3             docx to pdf failed
LINK_DOWNLOAD_ERROR = -4           file link download failed
EXCEED_SIZE_ERROR = -5             file size exceed limit
EXCEED_TOKENS_ERROR = -6           exceed tokens limit
PAGE_PACKAGE_NOT_ENOUGH_ERROR = -9 page package not enough
PAGE_LIMIT_ERROR = -10             page limit error
TITLE_COMPLETE_ERROR = -11         complete title failed
READ_TMP_FILE_ERROR = -12          read tmp file error
OCR_PAGE_LIMIT_ERROR = -13         ocr page limit error
CONTENT_POLICY_ERROR = -14         content security check did not pass
CONTENT_DECODE_ERROR = -15         file content decode error
HTML_CONVERT_ERROR = -16           html convert error
HTML_EMPTY_BODY_ERROR = -17        content is empty
HTML_PARSE_ERROR = -18             html parse error
HTML_DOWNLOAD_ERROR = -19          html download error from website
PACKAGE_NOT_ENOUGH_ERROR = -25     package not enough
Request Request Example
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://dev.your-api-server.com/documents/upload' \
--form 'file=@""'
Response Response Example
200 - Example 1
{
    "id": "string",
    "status": 1,
    "name": "string",
    "created_at": 0,
    "type": "collection"
}

Request

Body Params multipart/form-data
package_type
Package Type
optional
if provided, use this package(lite, basic, elite) to upload, this parameter is only effective for PDF file. if upload file type is (md,epub,txt), this parameter will be ignore
Any of
An enumeration.
Allowed values:
elitelitebasic
Default:
elite
Example:
elite
collection_id
string 
Collection Id
optional
if provided, add document to the collection, collection can be created by POST /collections
ocr
enum<string> 
optional
if provided, use this OCR type to upload
Allowed values:
disableautoforce
Default:
disable
Example:
disable
file
file 
required

Responses

🟢200Successful Response
application/json
Body
id
string 
Id
required
status
enum<integer> 
required
An enumeration.
Allowed values:
17101215202530405070120902103000-1-2-3-4-5-6-9-10-11-12-13-14-15-16-17-18-19-25
name
string 
Name
required
created_at
integer 
Created At
required
type
enum<string> 
required
An enumeration.
Allowed values:
collectionsingle_docdoc_of_collection
🟠422Validation Error
Modified at 2024-07-26 06:57:23
Next
Upload Document
Built with