Integrating with Deskcite

Use the HTTPS JSON API to search stored answers, submit feedback, retrieve Q&A records, and import sources. The app uses these same routes. Examples below use a fictional customer question and illustrative response values.

Connect and authenticate

Set BASE to the origin of your Deskcite instance, without /deskcite. HTTPS uses standard port 443. Omit the port in URLs; examples use https://deskcite.example.com as a placeholder for your instance. Use your deployment's trusted TLS certificate or supply its CA with curl's --cacert option.

export BASE='https://deskcite.example.com'

Obtain a session from POST /auth/login using an existing account's user, password, and current otp. Its successful JSON response includes access_token. Send that value as Authorization: Bearer TOKEN on protected requests. For example, the login body is:

{"user":"worker@example.com","password":"YOUR_PASSWORD","otp":"123456"}
# Set TOKEN to the access_token returned by your login client.
export TOKEN='YOUR_ACCESS_TOKEN'
curl --fail-with-body "$BASE/deskcite/similar" \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  --data '{"text":"How do I reset an authenticator?","n":8}'

The supplied configuration makes /deskcite (status), /deskcite/ui, and selected shell assets public. Search, imports, agent operations, and source documents require credentials unless the deployment explicitly configures otherwise. Login sessions and routing grants have different authorization semantics; grants must cover the requested path. Public-path rules apply to all HTTP methods: /deskcite also exposes dispatch in the supplied configuration. Use dedicated routes for integrations and follow your deployment’s access policy.

POST /auth/refresh refreshes a session and POST /auth/logout ends it; both take bearer authorization. Handle expiry by obtaining fresh credentials. Do not automatically replay login or other authenticator-consuming requests with a used code. Account enrollment, recovery, and grant administration are supplied by mesgd; this guide focuses on Deskcite's product API.

Search for answers

POST /deskcite/similar

Send text (a nonempty string) and optional n (an integer from 1 to 100, default 8). question is accepted as an alias for text.

{
  "ok": true,
  "rows": [{
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "question": "How do I reset an authenticator?",
    "answer": "Follow your organization's account recovery procedure.",
    "path": "/deskcite/documents/recovery.md",
    "segment": 2,
    "headings": "Account recovery",
    "distance": 0.18,
    "vote": null
  }]
}

id identifies the stored question record; keep it for feedback or retrieval. path, segment, and headings identify the source location. distance is the feedback-adjusted semantic distance; smaller values rank better. vote is up, down, or null for this query/record. An empty result is 200 with rows: [].

The UI groups identical answer text and displays a match percentage computed as round(max(0, 1 - distance) * 100). API clients receive individual rows. Scores are ranking signals, not calibrated confidence. The first request can take longer while the embedding model starts.

POST /deskcite/ask

Send {"text":"How do I reset an authenticator?"}. This returns the single nearest stored row with ok: true, rather than a rows array. It does not synthesize a new answer. No match returns 404 with {"ok":false,"error":"no matching answer"}.

GET /deskcite/search?q=recovery calls the separate erag document pipeline, rather than the Q&A table used by similar and ask. Optional types is a comma-separated filter such as document,section,image; document restricts the document path. Blank q produces empty results. text and question are aliases for q.

GET /deskcite/search/graph?q=recovery&mode=subgraph&hop=1 requests the graph pipeline. Both routes also accept POST bodies with these fields. Body fields override query-string fields with the same name. Their returned data is supplied by erag; do not treat it as the semantic answer-row schema. Availability and content depend on the deployment's erag index and configuration.

Record feedback

POST /deskcite/rate

Send the result's question id, the original search text, and vote as up, down, or clear.

curl --fail-with-body "$BASE/deskcite/rate" \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  --data '{"id":"a1b2c3d4-e5f6-7890-abcd-ef1234567890","text":"How do I reset an authenticator?","vote":"up"}'

Success returns 200 with {"ok":true,"id":"…","vote":"up"}. Clearing returns vote: null. An unknown record returns 404.

A new rating replaces the previous mark for the same normalized query and record. These marks are shared rather than scoped to the caller. A down-vote reduces that answer's match by a factor of four in later semantic queries; distinct query texts can add further penalties. Up or clear removes that query's negative mark. Rerun a search to observe the new ranking.

Retrieve and create knowledge

GET /deskcite/question/UUID

Returns ok, id, question, answer, path, segment, and headings. Unlike search results, this response has no distance or vote. Invalid UUIDs return 400; missing records return 404.

POST /deskcite/question

Required nonempty strings: question, answer, and path. Optional segment is an integer (default 0); headings defaults to an empty value.

{
  "question": "Where is the recovery procedure?",
  "answer": "Open the account recovery guide.",
  "path": "/deskcite/documents/recovery.md",
  "segment": 0,
  "headings": "Recovery"
}

Success is 201 with ok: true, id, and answer_id. Creation inserts a pair; it does not upload the source file. Creation does not start embedding. Call POST /deskcite/embed afterwards and verify search availability. The normal document import workflow performs extraction and embedding; verify search availability if you insert pairs directly. Repeating a create request can insert another record.

GET /deskcite/documents/PATH

Fetches an original uploaded or mirrored source as bytes with the appropriate content type. Send bearer authorization. The server applies configured folder restrictions and returns 403 for denied access or 404 for missing files. Use the source path returned by the service when it refers to this route; do not append it to /deskcite again.

Import documentation

POST /deskcite/import

For a URL, send {"url":"https://docs.example.com/guide/"}. For a text file, send:

{"name":"recovery.md","content":"# Recovery\nFollow the account recovery procedure."}

For binary content such as PDF, set encoding to base64 and supply valid base64 in content. The optional folder string selects a storage subfolder for file imports. Text defaults to utf8. Supply either the URL form or the file form; if both are present the URL form wins.

The response is 202, for example:

{"ok":true,"status":"queued","source":"recovery.md"}

This acknowledges submission, not completion or successful indexing. There is no durable job ID or per-job polling endpoint in this handler. Submitting again may repeat work. Observe the app's import activity or service events and verify that expected answers become searchable.

POST /deskcite/embed

No request body. Queues one pass of faqerl_embed:backfill/0, which fills vectors for stored questions that do not have one yet. POST /deskcite/question inserts a pair and does not embed it; call this afterwards so similar and ask can find the new row.

The response is 202 with {"ok":true,"status":"queued"}, or "status":"running" when a pass is already in progress. This acknowledges the queue, not a finished embedding. A second call while a pass is running does not start another. Check GET /deskcite and compare questions with embedded, or search for the new text.

The app subscribes to wss://HOST/deskcite/events using WebSocket subprotocols json and the bearer token as a second protocol value. Import events include type, source, and ts; progress, completion, and failure can include msg. Types are import.start, import.progress, import.done, and import.error. Correlate by source; identical concurrent sources are ambiguous. This stream is live, with no replay guarantee.

Agent operations

These routes expose shared operational state and scheduling controls. Use them only when your integration needs to manage team work.

Method and route Request or result
GET /deskcite/agents Snapshot including agent, counts, nodes, and activity; running imports are included.
GET /deskcite/agents/schedules Schedule state including items, runs, occurrences, timezone, cron_status, and cron_running.
POST /deskcite/agents/tasks {"action":"cancel_queued"} cancels queued tasks, not already running imports.
POST /deskcite/agents/schedule Actions save, toggle, propose, and calendar, described below.

Save a recurring schedule with action: "save", name, objective, kind: "cron", five-field cron, and boolean enabled. For a one-off use kind: "once" and an ISO 8601 run_at timestamp instead of cron. To edit, include the existing id and version. The UI submits the full schedule for toggles as well. A stale version returns 409; reload before retrying. Check the returned cron_status to confirm synchronization.

{"action":"propose","prompt":"Every weekday at 9am"} asks the model to suggest timing. Review the proposal before saving and enabling. The result may ask a clarifying question instead of returning a complete proposal. {"action":"calendar","start":1792972800,"end":1793577600} requests occurrences for a range expressed in Unix seconds, with end greater than start and a maximum span of 43 days. Model or agent unavailability can return 503; invalid proposals can return 502.

Status, dispatch, and failures

GET /deskcite returns {"ok":true,"questions":1420,"answers":1402,"embedded":1398} with current counts. Counts indicate stored state, not the success of a particular import.

POST /deskcite also supports JSON dispatch using op: status, similar, ask, rate, question, search, or search_graph. Use dedicated routes in new clients for clarity. PUT aliases POST for forwarded Q&A routes; Deskcite-specific import and agent actions are POST routes. DELETE does not delete knowledge and returns method-not-allowed for recognized forwarded routes.

Status Client action
200, 201, 202 Read the response; distinguish completed reads/creates from accepted imports.
400 Correct JSON, required fields, UUIDs, votes, or number ranges.
401, 403 Check credentials and authorization; source folder access is checked separately.
404 Check the route or record; ask can also mean no answer matched.
405 Use the documented HTTP method.
409 Reload schedule state and reconcile the version.
429 Respect authentication limits and back off.
500, 502, 503 Inspect the error and service health; retry reads with bounded backoff when appropriate.

Deskcite handlers generally return {"ok":false,"error":"…"} for errors. Authentication middleware can return a different shape. Check HTTP status before parsing success fields and tolerate error bodies that are not JSON. Avoid blind retries of imports, record creation, or credential-consuming operations. Search and document access have separate authorization checks; integrations must enforce their own customer-facing disclosure policy before presenting results.