Files
Files are where most of the cards on Vault come from. These are stored on the server in an s3 bucket. On this page, we’ll dive into the different conversation routes you can use to manage files programmatically. We'll look at how to create, update, and delete files.
The file model
The conversation model contains all the information about the files you upload. They can be linked to a specific collection and you can access the file itself from each card in it.
Properties
- Name
id
- Type
- string
- Description
Unique identifier for the conversation.
- Name
user_id
- Type
- string
- Description
Unique identifier for uploader of the file.
- Name
file_name
- Type
- string
- Description
The name of the file.
- Name
mime_type
- Type
- string
- Description
The mime_tyoe of the file. (Only accepts .docx, .doc, .odt, .pdf)
- Name
private
- Type
- boolean
- Description
Whether or not the file is visible to other users.
- Name
created_at
- Type
- timestamp
- Description
Timestamp of when the file was created.
- Name
updated_at
- Type
- timestamp
- Description
Timestamp of when the file was last updated.
- Name
size
- Type
- integer
- Description
The size of the file in bytes.
- Name
base64url_content
- Type
- string
- Description
The base64url encoded content of the file.
Get a file
This route allows you to retrieve a file by providing the file id. Refer to the list at the top of this page to see which properties are included with file objects. (Must be authenticated if private)
Response
If the response is successful it will return a 200 status code with the file.
- Name
file
- Type
- File
- Description
A file object.
Request
curl -L 'https://api.arguflow.ai/api/file/9a981834-b12a-49cc-afec-4ce88a2b2456' \
-H 'Cookie: ai-editor=your_cookie_value_here'
Response
{
"id": "9a981834-b12a-49cc-afec-4ce88a2b2456",
"user_id": "c9379ab0-389d-4204-8602-5ba1bf99d441",
"file_name": "AI Affirmative - Northwestern 2018.docx",
"mime_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"private": false,
"created_at": "2023-07-20T11:55:18.880672",
"updated_at": "2023-07-20T11:55:18.880739",
"size": 497097,
"base64url_content": "UEsDBBQABgAIAAAAIQDQWMtnkQEAAI8GAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAACAAAAAAAAAAAAAAAAAAAAAAAAAAAA..."
}
Create a file
This route allows you to add a file to your collection. The file must be a .docx, .doc, .odt, or .pdf. The file will be stored in an s3 bucket and the file object will be stored in the database. (Must be authenticated)
Required attributes
- Name
base64_docx_file
- Type
- string
- Description
The file you want to upload in base64url format.
- Name
file_name
- Type
- string
- Description
The name of the file you want to upload.
- Name
file_mime_type
- Type
- string
- Description
The mime type of the file you want to upload.
- Name
private
- Type
- boolean
- Description
Whether or not the file is visible to other users.
Optional attributes
- Name
tag_set
- Type
- string
- Description
The tags you want assocaiated with the cards in the file.
Response
If the response is successful it will return a 200 status code with the created file.
- Name
file
- Type
- File
- Description
A file object.
Request
curl -L 'http://api.arguflow.ai/api/file' \
-H 'Content-Type: application/json' \
-H 'Cookie: ai-editor=your_cookie_value_here' \
--data '{
"base64_docx_file": UEsDBBQABgAIAAAAIQDQWMtnkQEAAI8GAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAACAAAAAAAAAAAAAAAAAAAAAAAAAAAA...,
"file_name": "AI Affirmative - Northwestern 2018.docx",
"file_mime_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"private": false"
}'
Response
{
"id": "9a981834-b12a-49cc-afec-4ce88a2b2456",
"user_id": "c9379ab0-389d-4204-8602-5ba1bf99d441",
"file_name": "AI Affirmative - Northwestern 2018.docx",
"mime_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"private": false,
"created_at": "2023-07-20T11:55:18.880672",
"updated_at": "2023-07-20T11:55:18.880739",
"size": 497097,
"base64url_content": "UEsDBBQABgAIAAAAIQDQWMtnkQEAAI8GAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAACAAAAAAAAAAAAAAAAAAAAAAAAAAAA..."
}
Delete a file
This route allows you to delete a file by providing the file id. (Must be authenticated)
Response
If the response is successful it will return a 204 status code with no body.
Request
curl http://api.arguflow.ai/api/file/9a981834-b12a-49cc-afec-4ce88a2b2456 \
-H 'Cookie: ai-editor=your_cookie_value_here'
Update a file
This route allows you to update a file by providing the file id. (Must be authenticated)
Required attributes
- Name
file_id
- Type
- string
- Description
The id of the file you want to edit.
- Name
private
- Type
- boolean
- Description
Whether or not the file is visible to other users.
Response
If the response is successful it will return a 204 status code with no body.
Request
curl -X PUT https://api.protocol.chat/api/file \
-H 'Cookie: ai-editor=your_cookie_value_here' \
-H 'Content-Type: application/json' \
-d "{
"file_id": "9a981834-b12a-49cc-afec-4ce88a2b2456",
"private": true
}"