Skip to main content

Integrations

AI-powered reader features: translate, text-to-speech, dictionary, and text analysis (explain/expand/summarize). All endpoints use single-tenant mode (require X-Farfalla-Tenant-Id) and require the reader-token header.

All integration endpoints support content encryption via two-layer validation. The encrypted payload is validated first against size limits, then the decrypted content is validated against business rules.


Translate

POST /api/v2/reader/integrations/translate

Translates selected text to a target language.

Request:

curl -X POST https://app.publica.la/api/v2/reader/integrations/translate \
-H "Authorization: Bearer {access_token}" \
-H "X-Farfalla-Tenant-Id: 42" \
-H "reader-token: {session_token}" \
-H "Content-Type: application/json" \
-d '{
"text": "encrypted_text_content",
"target_lang": "en"
}'
ParameterTypeRequiredDescription
textstringYesText to translate (max 1000 chars plaintext, 1900 encrypted)
target_langstringNoTarget language (ISO 639 code)

Response: 200 OK

{
"data": {
"translations": [
{
"translatedText": "The cat sat on the rug",
"detectedSourceLanguage": "es"
}
]
},
"uuid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}

Text-to-Speech (Listen)

POST /api/v2/reader/integrations/listen

Converts text to speech audio using AWS Polly.

Request:

curl -X POST https://app.publica.la/api/v2/reader/integrations/listen \
-H "Authorization: Bearer {access_token}" \
-H "X-Farfalla-Tenant-Id: 42" \
-H "reader-token: {session_token}" \
-H "Content-Type: application/json" \
-d '{
"text": "encrypted_text_content",
"voiceId": "Penelope"
}'
ParameterTypeRequiredDescription
textstringYesText to synthesize (max 500 chars plaintext, 750 encrypted)
voiceIdstringNoAWS Polly voice ID

Response: 200 OK

Content-Type: audio/mpeg
Body: MP3 audio stream
info

The reader splits long text into ~500 character chunks client-side (total limit: 10,000 characters). Each chunk is sent as a separate request.


Dictionary

POST /api/v2/reader/integrations/dictionary

Looks up the definition of a word or short phrase using AI.

Request:

curl -X POST https://app.publica.la/api/v2/reader/integrations/dictionary \
-H "Authorization: Bearer {access_token}" \
-H "X-Farfalla-Tenant-Id: 42" \
-H "reader-token: {session_token}" \
-H "Content-Type: application/json" \
-d '{
"text": "encrypted_text_content",
"lang": "en"
}'
ParameterTypeRequiredDescription
textstringYesWord or short phrase (max 5 words, 150 chars encrypted)
langstringYesLanguage code for the definition

Response: 200 OK — AI-generated definition.


AI Actions

List Available Actions

GET /api/v2/reader/integrations/ai-integrations

Returns the available AI actions with localized labels.

Request:

curl https://app.publica.la/api/v2/reader/integrations/ai-integrations \
-H "Authorization: Bearer {access_token}" \
-H "X-Farfalla-Tenant-Id: 42" \
-H "reader-token: {session_token}" \
-H "Accept: application/json"

Response: 200 OK

{
"explain": "Explain this text",
"expand": "Expand this text",
"summarize": "Summarize this text"
}

Perform AI Action

POST /api/v2/reader/integrations/ai-integrations

Performs an AI action on selected text.

Request:

curl -X POST https://app.publica.la/api/v2/reader/integrations/ai-integrations \
-H "Authorization: Bearer {access_token}" \
-H "X-Farfalla-Tenant-Id: 42" \
-H "reader-token: {session_token}" \
-H "Content-Type: application/json" \
-d '{
"action": "explain",
"text": "encrypted_text_content",
"lang": "en"
}'
ParameterTypeRequiredDescription
actionstringYesexplain, expand, or summarize
textstringYesText to process (10-4000 chars plaintext, 7500 encrypted)
langstringNoResponse language (defaults to tenant language)

Response: 200 OK

{
"uuid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"text": "This passage describes quantum entanglement, a key concept in quantum mechanics where...",
"language": "en"
}

Rate AI Response

PUT /api/v2/reader/integrations/ai-integrations

Submits feedback on an AI response. Each response can only be rated once.

Request:

curl -X PUT https://app.publica.la/api/v2/reader/integrations/ai-integrations \
-H "Authorization: Bearer {access_token}" \
-H "X-Farfalla-Tenant-Id: 42" \
-H "reader-token: {session_token}" \
-H "Content-Type: application/json" \
-d '{
"uuid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"score": true
}'
ParameterTypeRequiredDescription
uuidstringYesUUID from the AI action response
scorebooleanYesPositive (true) or negative (false) feedback

Response: 200 OK with empty body.

Error Responses

CodeCause
422UUID not found
422Feedback does not belong to user
422Response already rated

Content Encryption

All integration endpoints that accept text use two-layer validation for content security:

  1. Layer 1 (encrypted): Validates the raw encrypted payload against size limits. Limits are set higher than the plaintext maximum to account for ~50% encryption overhead.
  2. Layer 2 (decrypted): Decrypts the content using the reader session key, then validates against business rules (character count, word count, etc.).
EndpointPlaintext LimitEncrypted Limit
AI10-4000 chars7500 chars
Translatemax 1000 chars1900 chars
Listenmax 500 chars750 chars
Dictionarymax 5 words150 chars

See Also

  • Reader - Reader sessions, settings, and content download
  • Notes - Highlights and annotations within the reader
X

Graph View