# Documents

The Documents API allows for creating, retrieving, updating, and deleting document records, supporting file uploads. Each document can be associated with a specific category using document_category_id.

# Get Document List

Retrieve a list of all documents.

  • URL: documents/documents/
  • Method: GET
  • Response Example:
    [
      {
        "unique_id": "doc123",
        "document_name": "Financial Report",
        "document_contents": "This is a sample financial report.",
        "document_file": "https://example.com/files/financial_report.pdf",
        "document_category": {
          "unique_id": "cat123",
          "category_name": "Finance",
          "category_description": "Category for financial documents",
          "date_created": "2023-01-01T12:00:00Z",
          "last_updated": "2023-01-01T12:00:00Z"
        },
        "date_created": "2023-01-01T12:00:00Z",
        "last_updated": "2023-01-01T12:00:00Z"
      },
      ...
    ]
    

# Create a Document

Create a new document entry. File uploads must be sent as part of form data, and each document can be linked to a category using document_category_id.

  • URL: documents/documents/

  • Method: POST

  • File Upload Support: Yes

  • Request Example:

    {
      "document_name": "Financial Report",
      "document_contents": "This is a sample financial report.",
      "document_file": "<file>",
      "document_category_id": "cat123"
    }
    

    Note: Use document_category_id to associate the document with an existing category by unique ID. The document_file field is required for uploading files directly through form data.

  • Response Example:

    {
      "unique_id": "doc123",
      "document_name": "Financial Report",
      "document_contents": "This is a sample financial report.",
      "document_file": "https://example.com/files/financial_report.pdf",
      "document_category": {
        "unique_id": "cat123",
        "category_name": "Finance",
        "category_description": "Category for financial documents",
        "date_created": "2023-01-01T12:00:00Z",
        "last_updated": "2023-01-01T12:00:00Z"
      },
      "date_created": "2023-01-01T12:00:00Z",
      "last_updated": "2023-01-01T12:00:00Z"
    }
    

# Get a Document

Retrieve details of a specific document by its unique ID.

  • URL: documents/documents/<str:unique_id>/
  • Method: GET
  • Response Example:
    {
      "unique_id": "doc123",
      "document_name": "Financial Report",
      "document_contents": "This is a sample financial report.",
      "document_file": "https://example.com/files/financial_report.pdf",
      "document_category": {
        "unique_id": "cat123",
        "category_name": "Finance",
        "category_description": "Category for financial documents",
        "date_created": "2023-01-01T12:00:00Z",
        "last_updated": "2023-01-01T12:00:00Z"
      },
      "date_created": "2023-01-01T12:00:00Z",
      "last_updated": "2023-01-01T12:00:00Z"
    }
    

# Update a Document

Update an existing document by its unique ID. File uploads are supported, and you can update the associated category by specifying document_category_id.

  • URL: documents/documents/<str:unique_id>/
  • Method: PUT
  • File Upload Support: Yes
  • Request Example:
    {
      "document_name": "Updated Financial Report",
      "document_contents": "This is the updated financial report.",
      "document_file": "<file>",
      "document_category_id": "cat456"
    }
    
  • Response Example:
    {
      "unique_id": "doc123",
      "document_name": "Updated Financial Report",
      "document_contents": "This is the updated financial report.",
      "document_file": "https://example.com/files/updated_financial_report.pdf",
      "document_category": {
        "unique_id": "cat456",
        "category_name": "Corporate Finance",
        "category_description": "Category for corporate financial documents",
        "date_created": "2023-01-01T12:00:00Z",
        "last_updated": "2023-01-02T08:30:00Z"
      },
      "date_created": "2023-01-01T12:00:00Z",
      "last_updated": "2023-01-02T08:30:00Z"
    }
    

# Delete a Document

Delete a document by its unique ID.

  • URL: documents/documents/<str:unique_id>/
  • Method: DELETE
  • Response: 204 No Content