logo

Reports API

Overview

The Reports API enables creation, retrieval, updating, and deletion of Swiftor reports.

Endpoints

List Reports (GET /reports)

Returns a summary list of all reports owned by the authenticated user. Note that the full content and hash are omitted in this list view.

Response

json
{
  "reports": [
    {
      "id": "generated-uuid-1",
      "reportlabel": "My First Report",
      "theme": "dark",
      "protected": false,
      "date_created": 1678886400000, // Unix timestamp in milliseconds
      "last_updated": 1678886405000  // Unix timestamp in milliseconds
    },
    {
      "id": "generated-uuid-2",
      "reportlabel": "Another Analysis",
      "theme": "light",
      "protected": true,
      "date_created": 1678886410000,
      "last_updated": 1678886410000
    }
    // ... other reports
  ]
}

Create Report (POST /reports)

Creates a new report entry in the database.

Request Body

json
{
  "label": "New Analysis Report",
  "hash": "optional-identifier-hash",
  "protected": false,
  "theme": "dark",
  "logo": "base64_encoded_image_data_or_url",
  "content": "Initial report content as a string (can be markdown, HTML, etc.)"
}
  • label (string, required): The display name for the report.
  • hash (string, required): An identifier hash (usage context may vary).
  • protected (boolean, required): Whether the report requires authentication/password for public access.
  • theme (string, required): Theme identifier (e.g., "dark", "light").
  • logo (string, required): Base64 encoded image data or a URL for the report logo.
  • content (string, optional): The initial content of the report. Defaults to an empty string.

Response (Success - 201 Created)

Returns the newly created report object, including the generated id and timestamps.

json
{
  "message": "Report created successfully",
  "report": {
    "id": "generated-uuid-3",
    "user_id": "user-supabase-id",
    "reportlabel": "New Analysis Report",
    "theme": "dark",
    "protected": false,
    "hash": "optional-identifier-hash",
    "content": "Initial report content...",
    "created_at": "2023-03-15T12:00:01.123456+00:00", // ISO 8601 format
    "updated_at": "2023-03-15T12:00:01.123456+00:00"  // ISO 8601 format
  }
}

Get Report Details (GET /reports/get/{report_id})

Retrieves the full details for a specific report, including its content and hash.

  • Path Parameter:
    • {report_id}: The UUID of the report to retrieve.

Response (Success)

Returns an object where the key is the report ID, and the value contains the report details.

json
{
  "generated-uuid-1": {
    "label": "My First Report",
    "hash": "optional-identifier-hash",
    "theme": "dark",
    "protected": false,
    "content": "Detailed report content here...",
    "date_created": 1678886400000, // Unix timestamp in milliseconds
    "last_updated": 1678886405000  // Unix timestamp in milliseconds
  }
}

Update Report Content (PUT /reports/{report_id})

Updates only the content of an existing report and sets its updated_at timestamp to the current time.

  • Path Parameter:
    • {report_id}: The UUID of the report to update.

Request Body

json
{
  "content": "Updated report content goes here."
}
  • content (string, required): The new content for the report.

Response (Success)

json
{
  "message": "Report published successfully"
}

Delete Report (DELETE /reports/{report_id})

Permanently deletes a specific report.

  • Path Parameter:
    • {report_id}: The UUID of the report to delete.

Irreversible Action

Report deletion cannot be undone.

Response (Success)

json
{
  "message": "Report deleted successfully"
}