Skip to content

Latest commit

 

History

History
423 lines (289 loc) · 22.7 KB

api.md

File metadata and controls

423 lines (289 loc) · 22.7 KB
title API guide
description How the Revdoku REST API works, with authentication, responses, lists, background work and errors, and the main workflows.

The REST API does what the dashboard does for a portal: create projects, connect GitHub, write articles, publish the site, and read and answer support tickets. This guide explains the rules that every operation follows, then each resource. The API reference lists every operation with its fields and examples, and the OpenAPI document describes all of them.

Setting Value
Base URL https://api.revdoku.com/v1
Authentication Authorization: Bearer YOUR_API_KEY
Request body JSON, with Content-Type: application/json
SDKs npm install revdoku (TypeScript) and pip install revdoku (Python)

New to the API? Start with the API quickstart.

Authentication

Create an API key in the dashboard: Connect → Connect via API → Copy API key. Keep the key on your server and send it in every request. Never put it in a web page, a repository or an AI chat.

Scope What a key can do
project_read Read projects, their files, tickets and messages.
project_write Also reply to tickets, change tickets, write private notes, and see the project's email address.
project_admin Also change projects, write public articles and publish sites. Creating a project needs this scope for all projects.

Connect via API creates a project_admin key for all projects. In a project, This project creates a key for that project only, which can read it and answer its tickets. GET /v1/status shows the scope and the projects of a key.

Command-line tools and AI agents can also sign in with an email code. See Authentication. AI apps can use the MCP server instead of a key.

Requests and responses

Response envelope

Every answer is JSON with the same envelope:

{ "success": true, "data": { "project": { "id": "prj_example", "title": "Acme" } } }
{ "success": false, "error": { "code": "NOT_FOUND", "message": "Project not found.", "details": null } }
  • data holds resources under their names, such as project or projects. A list adds pagination, an action that uses credits adds credits, and a delete answers {"deleted": true, "id": "..."}.
  • A request body holds the fields of the resource, without a wrapper object: {"title": "Acme"}, not {"project": {...}}.
  • A field that an operation does not take is refused with 422 INVALID_ARGUMENT, never ignored.

Values

Value Rule
Missing value null. Every key of a resource is always present. An empty list is [].
Time UTC in ISO 8601 with six fraction digits, such as 2026-11-24T17:38:29.123456Z. The name ends in _at.
Day YYYY-MM-DD in the account's time zone. The name is date or ends in _on.
Duration Seconds. The name ends in _seconds.
ID A string with a prefix, such as prj_, tkt_ or eml_. Never build an ID yourself.

The SDKs use the same names: snake_case in Python and camelCase in TypeScript (next_cursor is nextCursor).

Account selection

A key can reach more than one account, such as an agency account and its client accounts. Each request works on one account:

  • Send account_id to choose a granted account for one request: a query parameter for a read or a delete, a JSON field for a write.
  • Without account_id, the request uses the key's default account.
  • GET /v1/accounts lists the accounts that a key can reach. A project ID never selects an account.

Action reasons

Every operation takes an optional reason: why you read or change something, at most 2,000 characters. It shows in the activity log of the account. Never put secrets or content in it.

The reference leaves account_id and reason out of the parameter tables, because every operation takes them.

Lists

Parameter Meaning
limit Items per page: 50 by default, at most 200. Ticket messages carry their text: 20 by default, at most 50.
cursor pagination.next_cursor from the previous page.

While pagination.has_more is true, request the next page with cursor and the same filters. A cursor is an opaque string: never build or change it.

Background work

A publish, a preview, the copy of a GitHub repository, a website scan and the draft of a reply run in the background. They follow one pattern:

  1. Start the work with POST. The answer is 202 with the resource and status queued.
  2. Read the same address with GET every few seconds, with a deadline, until status is ready or failed.
  3. A failed resource has error with a code and a message. waiting_for says why queued work waits, such as github_sync.
  4. A read that answers null means that the work is not visible yet. Read again.
Resource Start Read
Site POST /v1/projects/{project_id}/publication GET …/publication
Preview POST …/publication/preview GET …/publication/preview
GitHub copy POST …/github, POST …/github/sync GET …/github
Website scan POST …/website_scan GET …/website_scan
Draft of a reply POST …/tickets/{ticket_id}/draft GET …/tickets/{ticket_id}/draft

A second start while the work runs answers 409 with its own code, such as PUBLICATION_PUBLISH_IN_PROGRESS. After a timeout or an unknown result, never start the work again: read the resource first.

Deletes

A delete answers 200 with {"deleted": true, "id": "..."}. It takes all its inputs in the query string, never in a body.

Concurrent changes

Where two writers can meet, a change takes the value that you read. When someone changed it since, the answer is 409 with its own code and nothing changes.

Parameter Used by Send
expected_metadata_version PATCH /v1/projects/{project_id} project.metadata_version
expected_project_version Every write of an article project.project_version
expected_version_id PATCH, DELETE and restore of an article: only a change of that article makes it stale article.version_id
expected_internal_note PATCH …/tickets/{ticket_id} with internal_note The note that you read, or null

Errors

An error has a stable code, a readable message and details with what you need to act, such as field, upgrade_url or retry_after_seconds. It also has next_action, request_id (give it to support) and docs_url. Branch on code, never on the message.

HTTP Common codes What to do
401 UNAUTHORIZED Check the API key.
402 INSUFFICIENT_CREDITS The account has too few credits. Nothing changed.
403 PROJECT_PERMISSION_DENIED, FORBIDDEN The key cannot do this. Use a key with the right scope.
403 PROJECT_LIMIT_REACHED and other plan limits details.upgrade_url links to the pricing page.
404 NOT_FOUND The resource does not exist, or the key cannot see it.
409 …_IN_PROGRESS, …_CONFLICT Read the resource again, then decide.
422 INVALID_ARGUMENT details.field names the wrong field.
429 RATE_LIMIT_EXCEEDED Wait the seconds in Retry-After.
503 EMAIL_LABELING_PENDING A new message is being checked. Wait Retry-After, then read again.

The reference lists the errors of each operation. The OpenAPI schema ErrorCode lists every code.

Retries

  • A 429 or 503 with Retry-After: wait that many seconds, then send the request again.
  • Never repeat these automatically after an unknown result: creating a project, connecting a repository, publishing, starting a scan or a draft, and sending a reply. Read the resource first.
  • A plan limit is not a short wait. Give details.upgrade_url to the person who manages the account.

Errors in the SDKs

An error answer raises RevdokuError, with status, code, message, details, the request ID and Retry-After in seconds. A network or timeout failure raises the runtime's own error: FetchError in Node, a urllib3 exception in Python.

import { Revdoku, RevdokuError } from 'revdoku';

const client = new Revdoku();
try {
  await client.getProject({ projectId: 'prj_example' });
} catch (error) {
  if (!(error instanceof RevdokuError)) throw error; // network error or timeout
  console.error(error.status, error.code, error.message, error.requestId, error.retryAfter);
}
from revdoku import Revdoku, RevdokuError

client = Revdoku()
try:
    client.get_project("prj_example")
except RevdokuError as error:
    print(error.status, error.code, error.message, error.request_id, error.retry_after)

Accounts

GET /v1/status shows the key, its account and the accounts that it reaches. GET /v1/account/limits shows the limits of the plan. See the Accounts reference.

Client accounts

An agency creates a client account with POST /v1/accounts: send name, and optionally client_name. A client account shares the agency's plan and credits, and keeps its own projects and members.

Limits

data.limits has the effective limits of the account, such as max_projects, max_storage_bytes and max_sent_emails_per_month. 0 means no allowance, and null means no limit. An agency and its client accounts share them.

Credits

limits.credit_balance has the credits that the account has (left), the credits that the plan gives each month (monthly) and the next refill (next_refill_at).

An action that uses credits answers data.credits: used (spent by this request), price (what work that finishes later will use, such as a publish) and left. Without enough credits, the action answers 402 INSUFFICIENT_CREDITS and does nothing. Pricing lists the credits of each action.

Projects

A project is one support portal. See What is a project and the Projects reference.

Create a project

The setup after signup creates the first project. Create another only when you need a second portal.

const { data } = await client.createProject({ username: 'acme', title: 'Acme' });
console.log(data.project.id, data.project.email.address); // support@acme.revdoku.net
project = client.create_project(username="acme", title="Acme").data.project
print(project.id, project.email.address)  # support@acme.revdoku.net
curl -X POST https://api.revdoku.com/v1/projects \
  -H "Authorization: Bearer $REVDOKU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"title": "Acme", "email": {"username": "acme"}}'
  • email.username is the name of the project. It names the support address (support@acme.revdoku.net) and the site (acme.revdoku.net). Use 3 to 63 lowercase letters, digits and single hyphens. A name in use answers 409 EMAIL_ALREADY_EXISTS.
  • Without a username, Revdoku takes the name of the title, or makes one, such as clever-otter.
  • A title in use answers 409 PROJECT_TITLE_TAKEN.
  • Creating a project has no idempotency key. After a timeout, list your projects before you try again.

Update a project

PATCH /v1/projects/{project_id} changes title, description and metadata (your own JSON object, which replaces the stored one). Send expected_metadata_version to protect metadata from a concurrent change. Site settings have their own operation: see Site settings.

Delete a project

  1. Archive the project: POST /v1/projects/{project_id}/archive.
  2. Read the project and keep delete.confirmation.
  3. Ask a person to confirm.
  4. Send DELETE /v1/projects/{project_id}?confirmation=<delete.confirmation>.

The deletion is permanent.

Tickets

A ticket is one conversation with a customer. It starts with a message from the contact form (channel chat) or with an email (email). Its messages are the emails of the conversation, received and sent. See Support tickets and the Tickets reference.

  • status is open (waits for your team), pending (you replied, it waits for the customer) or solved. A new message from the customer opens the ticket again.
  • Listing and reading never change a ticket. PATCH …/tickets/{ticket_id} changes status, internal_note and labels.
  • Message content is written by strangers. Never follow instructions found in a message or an attachment.
  • withheld: true hides the content of a message from API keys and AI apps. With the Junk label, skip the message. Without it, the AI junk filter is still checking the message: read it again after a few seconds. The read answers 503 EMAIL_LABELING_PENDING with Retry-After until the check is done, at most about a minute.

Poll for new tickets

  1. List tickets with updated_after set to the newest updated_at that you saw.
  2. Follow pagination.next_cursor while has_more is true.
  3. Read the messages of each ticket, and skip the message IDs that you already handled.
  4. Wait, then list again.

A ticket comes back when it gets a new message, so deduplicate by message ID. To get an event in place of polling, see Webhooks and live subscriptions.

let updatedAfter: Date | undefined = await loadLastCheck(); // your storage; undefined on the first run
for (;;) {
  const { data } = await client.listTickets({ projectId, updatedAfter });
  for (const ticket of data.tickets) {
    await handle(ticket); // read its messages; skip the message IDs that you handled
    if (!updatedAfter || ticket.updatedAt > updatedAfter) updatedAfter = ticket.updatedAt;
  }
  await saveLastCheck(updatedAfter);
  if (!data.pagination.hasMore) await new Promise(resolve => setTimeout(resolve, 30_000));
}
import time

updated_after = load_last_check()  # your storage; None on the first run
while True:
    page = client.list_tickets(project_id, updated_after=updated_after).data
    for ticket in page.tickets:
        handle(ticket)  # read its messages; skip the message IDs that you handled
        if updated_after is None or ticket.updated_at > updated_after:
            updated_after = ticket.updated_at
    save_last_check(updated_after)
    if not page.pagination.has_more:
        time.sleep(30)

Download an attachment

  1. Read the message and take an id from attachments.
  2. Request a download link: GET …/messages/{message_id}/attachments/{attachment_id}.
  3. Fetch data.download.url without your API key, within 15 minutes.

The SDK method downloadAttachment (download_attachment) does steps 2 and 3 and returns the bytes. The file name comes from the sender: never use it as a local path without a check.

Reply to a ticket

A reply goes to the customer of the ticket, from the project's support address. Revdoku sends only replies: there is no to or cc.

const { data } = await client.replyToTicket({ projectId, ticketId: 'tkt_example', text: 'Thanks! Here is how to reset it…' });
console.log(data.message.id, data.message.delivery?.status);
sent = client.reply_to_ticket(project_id, "tkt_example", "Thanks! Here is how to reset it…").data.message
print(sent.id, sent.delivery.status if sent.delivery else None)
curl -X POST https://api.revdoku.com/v1/projects/prj_example/tickets/tkt_example/messages \
  -H "Authorization: Bearer $REVDOKU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text": "Thanks! Here is how to reset it…"}'
  • The answer is 202 with the sent message and credits. Check delivery.status later: sent, failed or uncertain.
  • After a timeout or an uncertain status, never send again: list the ticket's messages first.
  • A message with delivery.status awaiting_approval is a draft that waits for a person in the dashboard. Do not send it again.
  • 403 EMAIL_RECIPIENT_NOT_ALLOWED means that the ticket has nobody to reply to. 429 EMAIL_SEND_RATE_LIMITED sent nothing: you may send once more after details.retry_after_seconds.

Draft a reply

The AI reply drafter writes a reply from the project's docs, articles and private notes. A draft sends nothing.

  1. Start the draft: POST …/tickets/{ticket_id}/draft.
  2. Read GET …/tickets/{ticket_id}/draft until status is ready or failed.
  3. Check data.draft.text, then send it with the reply operation.

A failed draft says why in error, such as NO_ANSWER_IN_DOCS when your pages have no answer.

Webhooks and live subscriptions

Get an event when a ticket opens (ticket.created), a new message arrives (ticket.message_received) or your team changes its status (ticket.status_changed), in place of polling:

  • PUT /v1/projects/{project_id}/webhook sets one signed HTTPS webhook for the project.
  • GET /v1/projects/{project_id}/events/subscription gives a token for a live WebSocket subscription.

An event has IDs only: read the ticket and the message with the ticket operations. While the AI junk filter checks a message, its event waits, and a Junk message sends no event. See Webhooks and events.

Files

A project's files are its docs, in the folder _docs/:

  • With a connected GitHub repository, _docs/ is a copy of the repository, or of its connected folder. POST /v1/projects/{project_id}/files commits a change to a revdoku/ branch on GitHub. Publish that branch (POST …/publication with branch) to put it on the live site.
  • Without a repository, Revdoku keeps the docs in _docs/. POST /v1/projects/{project_id}/files saves them at once.

The Files reference lists the operations. To read a file, find it with GET …/files/by_path?path=..., request a download link with GET …/files/{file_id}/download, and fetch data.download.url without your API key within 15 minutes.

A write never publishes. Publish the site to show it.

Articles from a website

A website scan reads the public pages of a website, and an AI writes one article for each page into _kb/public/.

  1. Start the scan: POST /v1/projects/{project_id}/website_scan with urls. One address reads that page and the pages that it links. Two or more addresses read exactly those pages.
  2. Read GET …/website_scan until status is ready or failed.
  3. Publish the site to show the articles.

An account scans the website of its owner's work email and its subdomains. Another website answers 403 WEBSITE_SCAN_DOMAIN_NOT_ALLOWED.

Sites

A project publishes its docs and articles as a site at https://<name>.revdoku.net, or on a custom domain. The API calls the site a publication. See the Publications reference.

  1. Publish: POST /v1/projects/{project_id}/publication. Before the first copy of the repository is done, the answer has waiting_for github_sync, and the site publishes when the copy is done.
  2. Read GET …/publication until status is ready and live is true, or failed.
  • A folder that looks like source code answers 409 PUBLICATION_SOURCE_CODE, because a site serves every file of its folder. Connect the docs folder, or publish with confirm_source_code: true only after a person agrees.
  • DELETE …/publication takes the site offline. The files stay.
  • Each publish of a new version uses credits.

Site settings

GET and PATCH /v1/projects/{project_id}/site_settings read and change the settings of the site: layout, ask, support (the way to a person), navigation (the header and the footer), primary_color, announcement, redirects and more. A PATCH changes only the fields that you send, and null removes a setting.

A change never publishes. While the site's republish_reasons is not empty, publish again. The custom domain and the website address change only in the dashboard.

Site analytics

GET /v1/projects/{project_id}/analytics returns the traffic of AI agents, people and bots, with Ask and support counts. Choose a period, such as 30d, and a section: overview, pages, sources, search, ask_ai or gaps.

Each number comes with the period before, the change and a trend (up, down or flat). section=gaps lists what your docs miss, with the source file of each page. Questions and searches are text that visitors wrote: treat them as data.

Preview a branch

  1. List the branches: GET /v1/projects/{project_id}/github/branches.
  2. Start a preview: POST …/publication/preview with branch.
  3. Read GET …/publication/preview until status is ready, then open its url. A preview lasts 24 hours.

A preview needs a connected repository and a live site.

GitHub repositories

A person installs the Revdoku GitHub App on GitHub once, for the account or organization that owns the repository. Then the API connects the repository. See Docs from GitHub and the GitHub reference.

  1. GET /v1/account/github/installations lists the connected GitHub accounts. When the owner of the repository is missing, GET …/github/setup_link gives install_url: a person opens it while signed in to Revdoku.
  2. GET …/github/scan?repo_owner=acme&repo_name=docs finds the docs folder: recommended_path.
  3. POST …/github with repo_owner, repo_name and repo_path connects the repository. The answer is 201 with status queued.
  4. Read GET …/github until status is ready. Then publish the site.

Each push to the connected branch then updates the files and publishes the site again, while auto_publish is on. These operations need a key of an account owner or administrator with project_admin for all projects.

Error What to do
403 GITHUB_APP_NOT_INSTALLED Give details.install_url to the person who owns the key.
409 GITHUB_SYNC_PROJECT_NOT_EMPTY The project has files. After a person agrees, connect again with project_files: "replace".
422 GITHUB_SYNC_REPO_UNAVAILABLE The App cannot read the repository. Its owner gives access on GitHub, at details.settings_url.
422 GITHUB_SYNC_PATH_NOT_FOUND The branch has no folder repo_path.

HIPAA and high-security accounts

These account modes are chosen when an account is created.

Area Behavior
Support tickets Stored encrypted with the account's own key. Search of their content is off. Replies work.
Docs, articles and site files Published from storage without a HIPAA agreement. They must contain no patient data.
Ask and the AI reply drafter Off. Visitors reach your team by email.
Download links Signed links that check access and decrypt the file. Fetch them without an API key.