Thinkeo API
HomeWebsiteDocumentationThinkeo Platform
HomeWebsiteDocumentationThinkeo Platform
  1. Getting Started
  • Getting Started
    • Introduction
    • Authentication
    • Required Elements for Creating a Publication
    • Creating Publications
  • Essentials - Most used
    • /teams
      GET
    • /tokens
      POST
    • /attachments
      POST
    • /publications
      POST
  • Auth
    • /auth/confirm
      PUT
    • /auth/forgot-password
      POST
    • /auth/logout
      POST
    • /auth/password
      PUT
    • /auth/refresh
      POST
    • /auth/register
      POST
    • /auth/sso/providers
      GET
    • /auth/sso/{provider}/login
      POST
    • /auth/sso/verify
      POST
    • /auth/login
      POST
  • Apps
    • /apps
      POST
    • /apps/query
      POST
    • /apps/{app_id}
      GET
    • /apps/{app_id}
      PUT
    • /apps/{app_id}/icon
      GET
    • /apps/{app_id}/icon
      PUT
    • /apps/{app_id}/versions
      GET
    • /apps/{app_id}/versions
      POST
    • /apps/{app_id}/versions/{version}
      GET
    • /apps/{app_id}/wizard
      GET
    • /apps/{app_id}/wizard
      PUT
    • /apps/{app_id}/wizard
      POST
    • /apps/{app_id}/wizard
      DELETE
    • /apps/{app_id}/archive
      POST
  • Assignments
    • /assignments
    • /assignments/{assignment_id}
    • /assignments/{assignment_id}
  • Attachments
    • /attachments/{attachment_id}
    • /attachments/{attachment_id}/meta
  • Attributes
    • /attributes
    • /attributes/query
    • /attributes/{attr_id}
    • /attributes/{attr_id}
    • /attributes/{attr_id}
    • /attributes/views/
    • /attributes/views/
    • /attributes/views/{view_id}
    • /attributes/views/{view_id}
    • /attributes/views/{view_id}
  • Blocks
    • /blocks
    • /blocks/query
    • /blocks/{block_id}
    • /blocks/{block_id}
    • /blocks/{block_id}
    • /blocks/{block_id}/children
    • /blocks/{block_id}/children/{child_id}
    • /blocks/{block_id}/children/{child_id}
    • /blocks/{block_id}/shallow-copy
    • /blocks/{block_id}/deep-copy
    • /blocks/ai-models
    • /blocks/{block_id}/graph
    • /blocks/views
    • /blocks/views
    • /blocks/views/{view_id}
    • /blocks/views/{view_id}
    • /blocks/views/{view_id}
  • Docs
    • /docs/openapi.json
  • Publications
    • /publications/query
    • /publications/{publication_id}
    • /publications/{publication_id}
    • /publications/{publication_id}
    • /publications/{publication_id}/attachments
    • /publications/{publication_id}/data
    • /publications/{publication_id}/data
    • /publications/views
    • /publications/views
    • /publications/views/{view_id}
    • /publications/views/{view_id}
    • /publications/views/{view_id}
  • Teams
    • /teams
    • /teams
    • /teams/current
    • /teams/groups
    • /teams/groups
    • /teams/groups/{group_id}
    • /teams/groups/{group_id}
    • /teams/groups/{group_id}/apps
    • /teams/groups/{group_id}/apps
    • /teams/groups/{group_id}/apps/{app_id}
    • /teams/groups/{group_id}/users
    • /teams/groups/{group_id}/users
    • /teams/groups/{group_id}/users/{user_id}
    • /teams/users
    • /teams/users
    • /teams/users/{user_id}
    • /teams/users/{user_id}
    • /teams/billing
    • /teams/billing/report
    • /teams/logs
  • Tokens
    • /tokens
    • /tokens/{token_id}
  • Users
    • /users/me
    • /users/me
  1. Getting Started

Creating Publications

This section explains how to create publications using the Thinkeo API, including uploading documents and handling responses.

Example Application#

For this example, we'll use an App that analyzes technical documents on multiple aspects and optionally provides a concise summary of the analysis.
The App structure consists of several blocks:
API - Document Block: Processes the input document
API - AI Analysis Block: Executes automatically after document processing
API - Summary Block: Conditional block that appears when the "Summary" attribute is assigned
The App uses the following attributes:
Document: File type attribute for the input document
Analysis: Text type attribute with values "Short" or "Detailed"
Specific: Text type attribute for specifying analysis focus
Summary: Text type attribute (could also be flag type) for enabling summary generation

Creating a Publication via API#

To create a publication, you'll need to follow these steps:

1. Upload Document#

Before creating a publication, you need to provide a URL for any file attributes. There are two ways to handle this:
Option 1: Store your file somewhere with a public URL that you can reference
Option 2 : Upload your file directly to Thinkeo using a POST Attachment request, then use the returned URL in your publication request
Here's how to upload a file using the second option:
Make a POST request to /attachments with these requirements:
Authorization header with your bearer token
Content-Type header matching your file type (see MIME types reference)
filename header with your desired filename
The server will respond with a JSON object containing the file details:
{
  "filename": "document.pdf",
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "sha1": [0],
  "url": "https://api.thinkeo.dev/v0/attachments/uuid"
}
You can now use the returned URL as the value for your file attribute when creating a publication.

2. Create Publication#

To create a publication, send a POST request to /publications. Here's what you need:
Bearer token in the Authorization header
Content-Type: application/json header
App UUID in the request URL
Version parameter (use "latest" for production or "preview" for development)
Attributes and their values in the request body
Example request with our document analysis App:

3. Understanding the Response#

The API returns a JSON object containing a tree structure of blocks. Here's an example response showing the analysis and summary blocks:
{
  "publicationId": "93327d8c-28a6-486e-9efe-56c688756cb2",
  "rootBlockId": "0191ea9f-4791-7d40-9e57-c4510181aee1",
  "blocks": {
    "0191eabd-48cb-7de1-9e2c-ae53281cf173": {
      "kind": "html",
      "content": "Analysis content here..."
    },
    "0191eac1-4674-7721-81ac-6931c345ddf8": {
      "kind": "html",
      "content": "Summary content here..."
    },
    "0191ea9f-4791-7d40-9e57-c4510181aee1": {
      "kind": "concatenation",
      "content": [
        "0191eabd-48cb-7de1-9e2c-ae53281cf173",
        "0191eac1-4674-7721-81ac-6931c345ddf8"
      ]
    }
  }
}
The response contains two types of blocks:
HTML blocks ("kind": "html"): Contain the actual content
Concatenation blocks ("kind": "concatenation"): Define the structure and order of content blocks
To process the response:
Start with the rootBlockId
For HTML blocks: Use the content directly
For concatenation blocks: Combine all child blocks in order
The final result will be properly formatted HTML content that you can use in your application.

JS snippet#

The following JS snippet can be used to perform the request and return the content as an HTML string:
async function thinkeoPublication(token, appId, appVersion, context = {}) {
  const res = await fetch(`https:/api.thinkeo.io/v0/publications?app=${appId}&version=${appVersion}`, {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${token}`,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      attributes: context,
    })
  })

  const { blocks, rootBlockId } = await res.json()

  const concatenated = {}
  function concatenateContent(id) {
    if (concatenated[id]) return concatenated[id]
    const block = blocks[id]
    switch (block.kind) {
      case "concatenation":
        concatenated[id] = block.content.map(concatenateContent).join("")
        break
      case "html":
        concatenated[id] = block.content
        break
    }
    return concatenated[id]
  }

  return concatenateContent(rootBlockId)
}
Modified at 2025-01-02 09:15:28
Previous
Required Elements for Creating a Publication
Next
/teams
Built with