Delete files

Delete temporary files, which cannot be recovered after deletion.

POST https://moi.matrixorigin.cn/newmoi/connectors/file/delete

Preparation before calling

Prepare a personal access token that has access to the target workspace, the target workspace ID, and the temporary file ID. Make sure the file is no longer needed before deleting it.

The example below uses:

  • $AI_STUDIO_API_KEY: The actual personal access token, passed through the X-API-Key Header.

  • $WORKSPACE_ID: The workspace ID of the file to be deleted, passed through the X-Workspace-ID Header.

  • $CONN_FILE_ID: Temporary file ID to delete, passed via conn_file_id.

Request example

curl -X POST "https://moi.matrixorigin.cn/newmoi/connectors/file/delete" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d "{
    \"conn_file_id\": \"$CONN_FILE_ID\"
  }"

Request body

Field

Type

Is it required

Description

conn_file_id

string

Yes

The ID of the temporary file to be deleted.

Successful response

Returns 200 on success and data is null.

{
  "code": "OK",
  "msg": "OK",
  "data": null
}

The response fields are as follows.

Field

Type

Description

code

string

OK on success.

msg

string

OK on success.

data

null

This interface does not return metadata of deleted files.

Error response

{
  "code": "ErrParamInvalid",
  "msg": "invalid file identifier",
  "data": null
}

Common HTTP errors

HTTP status code

error code

Common causes

Recommended actions

400

ErrParamInvalid

The JSON request body is invalid.

Check the JSON format and try again.

404

ErrNotFound

conn_file_id is empty or the temporary file does not exist.

Confirm the file ID; no need to delete the file again if it has already been deleted.

401

ErrUnauthorized

The access token is invalid or has expired.

Try again after updating the access token.

403

ErrForbidden

The caller does not have permission to delete temporary files.

Check workspace ID and access permissions.

503

ErrServiceUnavailable

The service is temporarily unable to delete files.

Keep the desensitization error message and try again.

Follow-up operations

When you need to confirm the deletion result, keep conn_file_id and Preview file or Download file again. Both interfaces return a non-exist error when the temporary file has been deleted.

Last updated on