Skip to main content
Version: 2.2.0

API Guide

This document provides an overview of all available endpoints in the Attachment Management Module (AMM) API.

Authentication

All endpoints (except /health) require Bearer token authentication (JWT) in the Authorization header, please refer to Authentication for more details.

Health Check

GET /health/livez

Description: Returns liveness status of the service.

Request

  • Headers: None
  • Body: None

Response Body

NameTypeDescription
statusstringLiveness status (e.g., OK)
......... (implementation detail)

GET /health/readyz

Description: Returns readiness status of the service.

Request

  • Headers: None
  • Body: None

Response Body

NameTypeDescription
statusstringReadiness status (e.g., OK)
......... (implementation detail)

Attachments

POST /attachments

Description: Upload one or more attachments.

  • Functional Access Level:
    • Resource: amm.attachment
    • Scope: edit
  • Data Access level: none

Request

  • Headers:
    • Authorization: Bearer <token>
    • Content-Type: multipart/form-data
  • Body:
    NameTypeRequiredDescription
    filesfile[]YesFile(s) to upload
    descriptionstringNoDescription of the file(s)
    tagsstringNoComma-separated tag UUIDs
    modulestringYesModule name
    entity_typestringNoEntity type
    entity_idUUIDNoEntity ID
    checksumstringYesFile checksum (see Checksum Generation below)

Response

Response code
CodeDescription
201Upload successful
400Invalid request
401Unauthorized
500Internal server error
Response body
NameTypeDescription
attachmentsarrayList of uploaded attachments
└─ idUUIDAttachment ID
└─ file_namestringFile name
└─ file_sizeint64File size in bytes
└─ mime_typestringMIME type
└─ descriptionstringDescription
└─ entity_idUUIDEntity ID
└─ entity_typestringEntity type
└─ tenant_idstringTenant ID

GET /attachments/{id}

Description: Get metadata for a specific attachment.

  • Functional Access Level:
    • Resource: amm.attachment
    • Scope: view
  • Data Access level: based on resource_name value in Data Access entity with the view scope.

Request

  • Headers:
    • Authorization: Bearer <token>
  • Body: None

Response

Response code
CodeDescription
200Success
401Unauthorized
404Not found
500Internal server error
Response body
NameTypeDescription
idUUIDAttachment ID
file_namestringFile name
file_sizeint64File size in bytes
mime_typestringMIME type
descriptionstringDescription
entity_idUUIDEntity ID
entity_typestringEntity type
tenant_idstringTenant ID
created_atstringCreation timestamp (RFC3339)
updated_atstringLast update timestamp
created_bystringCreator user ID
updated_bystringLast updater user ID
data_accessarrayData access list (only user has edit scope)
└─ attachment_idUUIDAttachment ID
└─ resource_namestringResource name
└─ scopestringAccess scope
tagsarrayList of tags
└─ attachment_idUUIDAttachment ID
└─ tag_idUUIDTag ID

PUT /attachments/{id}

Description: Update attachment metadata (description, tags, data access).

  • Functional Access Level:
    • Resource: amm.attachment
    • Scope: edit
  • Data Access level: based on resource_name value in Data Access entity with the edit scope.

Request

  • Headers:
    • Authorization: Bearer <token>
    • Content-Type: application/json
  • Body:
    NameTypeRequiredDescription
    descriptionstringNoDescription
    tag_idsUUID[]NoList of tag IDs
    data_accessobject[]NoData access list
    └─ resource_namestringYesResource name
    └─ scopestringYesAccess scope

Response

Response code
CodeDescription
200Success
401Unauthorized
404Not found
500Internal server error
Response body
NameTypeDescription
idUUIDAttachment ID
descriptionstringDescription
tagsarrayList of tags
data_accessarrayData access list

GET /attachments/{id}/download-id

Description: Generate a secure download ID for an attachment.

  • Functional Access Level:
    • Resource: amm.attachment
    • Scope: view
  • Data Access level: based on resource_name value in Data Access entity with the view scope.

Request

  • Headers:
    • Authorization: Bearer <token>
  • Body: None

Response

Response code
CodeDescription
200Success
401Unauthorized
404Not found
500Internal server error
Response body
NameTypeDescription
download_idUUIDDownload ID
expires_atstringExpiry timestamp (RFC3339)
download_pathstringDownload path

GET /downloads/{id}

Description: Download the attachment file using a secure download ID.

  • Functional Access Level:
    • Resource: amm.attachment
    • Scope: view
  • Data Access level: based on resource_name value in Data Access entity with the view scope.

Request

  • Headers:
    • Authorization: Bearer <token>
  • Body: None

Response

Response code
CodeDescription
200Success
401Unauthorized
404Not found
500Internal server error
Response body
  • File stream with appropriate headers:
    • Content-Type: MIME type of the file
    • Content-Disposition: Attachment with filename
    • Content-Length: File size

GET /attachments/modules/{module_id}

Description: List attachments by module, only attachments that user has access to will be returned.

  • Functional Access Level:
    • Resource: amm.attachment
    • Scope: view
  • Data Access level: based on resource_name value in Data Access entity with the view scope.

Request

  • Headers:
    • Authorization: Bearer <token>
  • Query Parameters:
    NameTypeRequiredDescription
    entity_typestringNoEntity type filter
    pageintNoPage number
    sizeintNoPage size
    sortstringNoSort order
  • Body: None

Response

Response code
CodeDescription
200Success
400Invalid request
401Unauthorized
500Internal server error
Response body
NameTypeDescription
attachmentsarrayList of attachments
└─ idUUIDAttachment ID
└─ file_namestringFile name
└─ file_sizeint64File size in bytes
└─ mime_typestringMIME type
└─ descriptionstringDescription
└─ entity_idUUIDEntity ID
└─ entity_typestringEntity type
└─ tenant_idstringTenant ID
paginationobjectPagination info
└─ total_recordsintTotal records
└─ numberintCurrent page number
└─ sizeintPage size
└─ countintNumber of records in page
└─ sortstringSort order

GET /attachments/modules/{module_id}/entities/{entity_id}

Description: List attachments by entity, only attachments that user has access to will be returned.

  • Functional Access Level:
    • Resource: amm.attachment
    • Scope: view
  • Data Access level: based on resource_name value in Data Access entity with the view scope.

Request

  • Headers:
    • Authorization: Bearer <token>
  • Query Parameters: Same as above
  • Body: None

Response

Response code
CodeDescription
200Success
400Invalid request
401Unauthorized
500Internal server error
Response body
NameTypeDescription
attachmentsarrayList of attachments
└─ idUUIDAttachment ID
└─ file_namestringFile name
└─ file_sizeint64File size in bytes
└─ mime_typestringMIME type
└─ descriptionstringDescription
└─ entity_idUUIDEntity ID
└─ entity_typestringEntity type
└─ tenant_idstringTenant ID
paginationobjectPagination info
└─ total_recordsintTotal records
└─ numberintCurrent page number
└─ sizeintPage size
└─ countintNumber of records in page
└─ sortstringSort order

DELETE /attachments/{id}/logical-delete

Description: Soft-delete (logical delete) an attachment.

  • Functional Access Level:
    • Resource: amm.attachment
    • Scope: edit
  • Data Access level: based on resource_name value in Data Access entity with the edit scope.

Request

  • Headers:
    • Authorization: Bearer <token>
  • Body: None

Response

Response code
CodeDescription
204Success
401Unauthorized
404Not found
500Internal server error

DELETE /attachments/{id}/physical-delete

Description: Hard-delete (permanent delete) an attachment.

  • Functional Access Level:
    • Resource: amm.attachment
    • Scope: edit
  • Data Access level: based on resource_name value in Data Access entity with the edit scope.

Request

  • Headers:
    • Authorization: Bearer <token>
  • Body: None

Response

Response code
CodeDescription
204Success
401Unauthorized
404Not found
500Internal server error

POST /attachments/{id}/restore

Description: Restore a logically deleted attachment.

  • Functional Access Level:
    • Resource: amm.admin
    • Scope: edit
  • Data Access level: none

Request

  • Headers:
    • Authorization: Bearer <token>
  • Body: None

Response

Response code
CodeDescription
200Success
401Unauthorized
404Not found
500Internal server error

Checksum Generation

The AMM module uses SHA256 checksums to validate request integrity. Checksums are generated from request metadata to ensure data consistency and prevent tampering.

How Checksums Work

  1. Metadata Collection: The checksum is generated from the following request fields:

    • description (string)
    • tags (array of UUIDs)
    • module (string)
    • entity_type (string)
    • entity_id (UUID, optional)
  2. Data Processing:

    • Empty values are excluded from the checksum calculation
    • Keys are sorted alphabetically for consistent ordering
    • The data is formatted as: key_1=value_1;key_2=value_2
  3. Checksum Generation:

    • The formatted string is converted to bytes
    • SHA256 hash is applied to the bytes
    • The result is encoded as a hexadecimal string

Example Checksum Generation

Given the following request metadata:

{
"description": "Sample document",
"tags": ["550e8400-e29b-41d4-a716-446655440000"],
"module": "documents",
"entity_type": "invoice",
"entity_id": "123e4567-e89b-12d3-a456-426614174000"
}

The checksum generation process:

  1. Format data: description=Sample document;entity_id=123e4567-e89b-12d3-a456-426614174000;entity_type=invoice;module=documents;tags=["550e8400-e29b-41d4-a716-446655440000"]
  2. Apply SHA256: sha256(formatted_string)
  3. Hex encode: a1b2c3d4e5f6...

Configuration

Checksum validation can be controlled via the CHECKSUM_ENABLED environment variable:

  • CHECKSUM_ENABLED=true: Checksums are required and validated
  • CHECKSUM_ENABLED=false: Checksums are optional (default)

Error Handling

If checksum validation fails, the API returns a 400 Bad Request error with details about the checksum mismatch.


All error responses follow this format:

NameTypeDescription
errorstringError message
detailsstring[]Error details array