Document management

1. File type document upload interface

Interface Description

  • Only one document can be uploaded at a time;
  • This interface only allows uploading file type documents in pdf / docx / text format;
  • The size of a single document cannot exceed 20MB;

request method

  • Request method: POST
  • Request URL: /v1/ctai/upload_ctai_doc
  • Content-Type: multipart/form-data

request parameters

parameterEnterprise TyperequiredParameter Description
ctai_docjsonStringYesDocument information object json string, the structure is as follows
{ "doc_name": "test_name" }
must be passed, the file name, the duplicate name will be renamed automatically, the maximum length is 128 characters
check_onlystringNoWhether to only verify the validity of the parameters without actually uploading the document, the default is 0.
0:No, 1:Yes
contentfileYesThe original content stream of the document delivered by the standard form-data file upload method only supports documents with extensions in txt / docx / pdf format.When check_only is 1, this parameter can not be passed.

Note:is one of the few interfaces that use multipart/form-data to transmit data, and the content of the post must be a form-data structure.

Response business parameters

{
    "ctdoc_id": "test_id",
    "file_url": "https://test_url"
}
parameterEnterprise TypeParameter Description
ctdoc_idstringdocument id
file_urlstringdocument URL


2 URL type document addition interface

Interface description

  • This interface is only used to add URL type documents;
  • The size of the document content parsed through the URL cannot exceed 20MB;
  • Only allow adding URL in the form of http:// or https://;

Request method

  • Request method: POST
  • Request URL: /v1/ctai/add_ctai_doc_batch
  • Content-Type: application/json

Request Parameter

{
    "ctai_doc_list": [
        {
            "doc_type": "url",
            "doc_url": "https://test.com/test.html"
        },
        // other documents info object
    ]
}

request parameters

parameterEnterprise TyperequiredParameter Description
ctai_doc_listarrayYesAn array of document information objects, each object in the array is a document information object.
doc_typestringYesDocument type, please pass url, please note that it is not the url address of the document, but the 3-byte string of url.
url:Document of type URL.
doc_urlstringYesThe URL address of the document.Only URLs of the form http:// or https:// are allowed.

Response business parameters

{
    "ctai_doc_result_list": [
        {
            "ret": "0",
            "msg": "",
            "ctai_doc": {
                "doc_type": "url",
                "doc_url": "https://test.com/test.html",
                "ctdoc_id": "test_id"
            }
        }
    ]
}
parameterEnterprise TypeParameter Description
ctai_doc_result_listarrayThe document adding result list corresponds to the document information object in the incoming ctai_doc_list list.
retstringThe error code added in this document, 0 means success
msgstringThe error message added by this document, or an empty string if successful.
ctai_docobjectDocument information object.
doc_typestringConsistent with the doc_type passed in.
doc_urlstringConsistent with the incoming doc_url.
ctdoc_idstringDocument id, this parameter will be included only after the document is successfully added.


3 Delete document interface

Interface description

  • This interface is used to delete the uploaded document.

Request method

  • Request method: POST
  • Request URL: /v1/ctai/delete_ctai_doc
  • Content-Type: application/json

Request parameter

{
    "ctdoc_id": "test_id ",
}

request parameters

parameterEnterprise TyperequiredParameter Description
ctdoc_idstringYesThe document id to delete, only one document id can be passed at a time.

Response business parameters

No business response parameters, pay attention to whether ret is 0 in the public response parameters



4 Modify document interface

Interface description

  • You can modify document information through this interface.

Request method

  • Request method: POST
  • Request URL: /v1/ctai/modify_ctai_doc
  • Content-Type: application/json

Request parameter

{
    "ctdoc_id": "test_id ",
    "ctai_doc": {
        "doc_name": "test_name",
    }
}

request parameters

parameterEnterprise TyperequiredParameter Description
ctdoc_idstringYesThe document id to modify, only one document id can be passed at a time.
ctai_docobjectYesthe document info object to modify
doc_namestringNoDocument name, only documents of the file type support modification of the document name, and the document name cannot be repeated.The maximum length is 128 characters.

Response business parameters

No business response parameters, pay attention to whether ret is 0 in the public response parameters



5 Document list interface

Interface description

  • This interface supports multi-page reading, and it is recommended to control the amount of each page within 50.

Request method

  • Request method: POST
  • Request URL: /v1/ctai/ctai_doc_list
  • Content-Type: application/json

Request parameter

{
    "ctdoc_id": "test_doc_id ",
    "doc_type": "doc",
    "filter_keywords": "test",
    "sort_type": "test_id",
    "page": "1",
    "page_rows": "10"
}

request parameters

parameterEnterprise TyperequiredParameter Description
ctdoc_idstringNoMultiple document ids are separated by commas.
doc_typestringNoDocument types, multiples are separated by commas.optional type:
doc:document of type file
url:document of type URL
filter_keywordsstringNoSearch keywords, fuzzy search from the document name of the file type document, or the url of the URL type document.
sort_typestringNoSorting method, the default is create_time_asc
create_time_asc Sort by creation time from old to new
create_time_desc Sort by creation time from new to old
pagestringNoPaging parameter, the number of pages, starting from 1, the default is 1
page_rowsstringNoPagination parameters, how many items per page, the default is 1

Response business parameter

{
    "total_count": "8",
    "ctai_doc_list": [
        {
            "ctdoc_id": "test_doc_id",
            "ctai_doc": {
                "doc_type" : "doc",
                "doc_url": "http://test.com/a.html",
                "doc_name": "test_name",
                "process_status": "end_succ",
                "process_code": "0" ,
                "create_time": "1680010349",
                "update_time": "1680010352"
            },
            // Other document information objects
        }
    ]
}
parameterEnterprise TypeParameter Description
total_countstringTotal number of documents, used for pagination.
ctai_doc_listarraydocument list
ctdoc_idstringdocument id
ctai_docobjectDocument Information Object
doc_typestringDocument type, the values are as follows:
doc:document of document type
url:document of URL type
doc_urlstringOnly documents of type url are valid.The url address of the URL type document
doc_namestringOnly documents of type doc are valid.file name
doc_file_urlstringdocument download url
process_statusstringDocument processing status, the values are as follows:
end_succ:processing complete - success
end_fail:processing complete - failure
other:in process (generating index, etc.)
process_codestringdocument processing error code, 0 is success If it is not 0, it is a failure. For details, see the error code description in the appendix.
create_timestringCreation time, an integer timestamp in seconds
update_timestringLast modification time, an integer timestamp in seconds