This repository holds the OpenAPI description and hosted API reference for the Sinch Engage API.
The source of truth is a multi-file OpenAPI tree under /spec. Edit path and component files directly; CI and local builds bundle them, inject code samples, and publish static ReDoc documentation to GitHub Pages.
OpenAPI specification for Sinch Engage (split across an entry file, paths, and components).
| Path | Purpose |
|---|---|
/spec/openapi.yaml |
Entry document: info, tags, servers, path $refs, and selected component $refs. |
/spec/paths/ |
One YAML file per API path (operations live here). |
/spec/components/ |
Shared schemas/, responses/, and headers/. (securitySchemes stay inline in openapi.yaml.) |
/spec/code_samples/ |
Per-language request samples, mapped onto operations at build time. |
/spec/README.md |
Notes about the spec layout. |
Example layout:
spec/
openapi.yaml
paths/
contacts/
messages/
delivery-reports/
replies/
source-address/
dedicated-numbers/
number-authorisation/
webhooks/
signature-keys/
short-trackable-links-reports/
messaging-reports/
components/
schemas/
contacts/
messages/
delivery-reports/
replies/
source-address/
dedicated-numbers/
number-authorisation/
webhooks/
signature-keys/
short-trackable-links-reports/
messaging-reports/
_format-schemas.yaml # shared; case-safe Format/format
Number.yaml # shared across tags
... # other shared schemas stay at this level
responses/
headers/
code_samples/
JavaScript/v1@messages/post.js
How to edit: change the relevant file under spec/paths/ or spec/components/. Do not hand-edit a bundled single-file copy. Lint/build resolve $refs and produce the published docs.
Samples follow the folder convention <lang>/<path>/<HTTP verb>.<extension> under /spec/code_samples/, where:
<lang>— one ofcurl,C#,Java,JavaScript,PHP,Python,Ruby<path>— API path with/replaced by@<HTTP verb>— HTTP method of the target operation (extension must match the language)
e.g.:
/spec/code_samples/curl/v1@messages/post.sh→POST /v1/messages/spec/code_samples/JavaScript/v1@messages@{messageId}/get.js→GET /v1/messages/{messageId}/spec/code_samples/Python/v1@messages/post.py→POST /v1/messages
At build time the pipeline first bundles the multi-file spec, then scripts/inject-code-samples.mjs walks the samples tree and attaches each file as an x-codeSamples entry on the matching operation. Source files under /spec are never mutated; intermediates are written under /.tmp.
Samples are pure-language HTTP (no MessageMedia/Sinch SDKs). After bundling, regenerate with node scripts/generate-code-samples.mjs.
See /spec/code_samples/README.md for the full convention.
To smoke-test that samples execute against a real host (matrix or all ops), see /local/sample-smoke/README.md.
The ReDoc page shows four extra operations, Send SMS, Send MMS, Send TTS and Send RCS, each with only the fields, examples and cURL sample for that message type. They are all POST /v1/messages; they exist only in the HTML build. web_deploy/openapi.yaml|json and the llms files are generated from .tmp/openapi.injected.yaml and do not contain them.
- Config:
spec/doc-variants/message-types.yaml(not referenced fromopenapi.yaml). Each entry listsfields,required,examples(keys from theSendMessagesrequest examples),responsesand a description. - Script:
scripts/add-doc-variants.mjsreads.tmp/openapi.injected.yamland writes.tmp/openapi.docs.yaml, whichbuild-docsrenders. Internally the paths are/v1/messages#smsetc.;web/llm-actions.jshides the#...suffix on the page. - To add a field or example: add the field to
components/schemas/Message.yamlor the example tospec/paths/messages/v1_messages.yamlfirst, then list it in the config for the types that accept it. - The build fails (exit 1, with a message) if the config names a field, example or response that does not exist in the source operation, a required field that is not listed in
fields, a duplicateoperationId, or a missing Markdown file.
Static assets and the Handlebars HTML template used by redocly build-docs.
| Path | Purpose |
|---|---|
/web/index.html |
ReDoc HTML template ({{{redocHead}}} / {{{redocHTML}}}). Loads the page-actions widget styles (inline) and llm-actions.js. |
/web/llm-actions.js |
"Copy for LLM / View as Markdown" page-actions widget script (see below). |
/web/logo.png, /web/logo.svg |
Brand logo (x-logo in the spec points at ./logo.png). |
/web/favicon.png |
Favicon linked from the template. |
/web/message-flow.png |
Image referenced from the API description. |
Human- and LLM-readable Markdown mirror of the API reference. scripts/copy-docs.mjs
publishes this tree into web_deploy/docs/ at build time so the page-actions widget can
serve raw Markdown.
| Path | Purpose |
|---|---|
/docs/api/index.md |
Top-level "all services" index. |
/docs/api/webhooks-management/index.md |
Webhooks Management service overview. |
/docs/api/webhooks-management/*.md |
One page per operation (create / retrieve / update / delete). |
/docs/guides/*.md |
Cross-cutting guides (Basic Authentication, HMAC Authentication, Sub-accounts, AI Integration) that aren't tied to a single endpoint. |
/docs/llms-curation.yaml |
Hand-maintained allow list (curated llms.txt links) and deny list (globs excluded from llms-full.txt) — see below. |
scripts/generate-llms-txt.mjs runs at the end of npm run build and writes two files straight into web_deploy/:
llms.txt— a curated, token-budgeted (1k–3k) index: H1 (API title) → blockquote summary (fromspec/openapi.yamlinfo.description) → H2 sections (Authentication, Endpoints, Code Samples, Guides) driven entirely bydocs/llms-curation.yaml.llms-full.txt— every page under/docs/apiand/docs/guides(minusdocs/llms-curation.yaml'sdenyglobs, e.g.docs/superpowers/**) inlined in full, each behind a stable<a id="...">anchor.
The script fails the build (non-zero exit) if a curated link points at a missing file, a required section is missing, or llms.txt falls outside the token budget — so a bad edit to the curation file or the docs tree can't silently ship. There's currently only one supported (non-preview) API major version — almost everything is /v1/..., aside from a handful of /v2-preview/... Messaging Reports endpoints that don't warrant their own variant while still pre-release — so only the root files are published; a /v2/ variant is a small addition to the script once a version is promoted out of preview.
ReDoc Community Edition (@redocly/cli + redocly build-docs) has no built-in page
actions — navigation.actions in redocly.yaml is a Redocly Realm/Reunite feature and does
nothing here. Instead, a small dependency-free widget lives in web/llm-actions.js (loaded
by web/index.html; its styles stay inline in the template):
- Two simple text links are added inline with each section's heading, on the light
description panel (they scroll with the content — they are not a floating overlay):
- Copy for LLM copies the current section as Markdown to the clipboard.
- View as Markdown opens the raw
.mdin a new tab (external-link icon).
- The widget reads each section's ReDoc
data-section-id(operation/<operationId>ortag/<Tag-Name>), maps it to the matching file underdocs/api/…, and resolves the URL against the site root, so it works both locally (npm run preview-docs) and on GitHub Pages. The links are anchored to the heading's panel and vertically centred on the heading. AMutationObserverre-runs injection after ReDoc hydrates (guarded so bars are never duplicated). - Markdown is fetched at click time. If the fetch fails (offline,
file://, missing file), Copy falls back to a short Markdown summary with the page title and URL.
Where Markdown is served from: scripts/copy-docs.mjs mirrors /docs/**/*.md into
web_deploy/docs/** during npm run build (and copies web/llm-actions.js into
web_deploy/), so the published site serves, for example,
https://developers.app.sinch.com/docs/api/webhooks-management/create-webhook.md.
Images a page references with a relative path (such as ./message-flow.png, which ReDoc
resolves at the site root) are copied next to the published Markdown, so the same link
works in both places.
To add coverage for more sections, add the Markdown under docs/api/… and register the
operationId (or tag slug) in the OP_TO_MD / TAG_TO_MD maps in web/llm-actions.js.
Headings in the spec's info.description render as section/<Heading> rows and are mapped
the same way via SECTION_TO_MD — only for headings whose content has a canonical Markdown
page (currently just AI Integration); the rest are intentionally left without page actions.
Build helpers used by npm scripts.
| Path | Purpose |
|---|---|
/scripts/inject-code-samples.mjs |
Injects /spec/code_samples/ into x-codeSamples on the bundled spec. |
/scripts/generate-code-samples.mjs |
Regenerates pure-language samples for all operations × languages from the bundled OpenAPI. |
/scripts/copy-assets.mjs |
Copies /web assets into /web_deploy and publishes openapi.yaml + openapi.json for ReDoc downloads. |
/scripts/copy-docs.mjs |
Mirrors /docs/**/*.md (plus images each page references) into /web_deploy/docs/ and copies web/llm-actions.js, so the site can serve raw Markdown and the page-actions widget. |
/scripts/generate-llms-txt.mjs |
Generates /web_deploy/llms.txt and /web_deploy/llms-full.txt from spec/openapi.yaml + docs/llms-curation.yaml + /docs/api, /docs/guides. |
Changelog entries for documentation or API updates.
e.g.:
/changelog/2026-06-16-MAPI-2218.md
CI workflows. The main workflow installs dependencies, lints the OpenAPI entry (resolving $refs), builds static docs into /web_deploy, and deploys that folder to GitHub Pages.
| Path | Purpose |
|---|---|
redocly.yaml |
Redocly CLI config: API root (spec/openapi.yaml), lint ruleset/extends, custom plugins, and ReDoc theme. |
vocabulary.yaml |
Controlled vocabulary (banned terms + preferred replacements) enforced by plugins/vocabulary.mjs. |
package.json |
Dependencies and npm scripts (lint, build, preview-docs, and so on). |
| Path | Purpose |
|---|---|
/web_deploy |
Static site output: index.html, llms.txt, llms-full.txt, plus copied assets. Deployed by CI. |
/.tmp |
Intermediate files: openapi.bundled.yaml (resolved $refs) and openapi.injected.yaml (bundle + code samples). |
- Install Node JS
- Clone repo and run
npm installin the repo root
Validates the OpenAPI spec with Redocly lint rules (follows $refs across the split files).
Builds the static docs (bundle → inject code samples → ReDoc) and serves web_deploy at http://localhost:8080 so you can preview the same output CI deploys.
Bundles the multi-file spec, injects code samples, builds static ReDoc HTML into web_deploy, copies web assets (logo, favicon, etc.), mirrors the /docs Markdown into web_deploy/docs/ (via scripts/copy-docs.mjs) for the page-actions widget, and generates web_deploy/llms.txt + web_deploy/llms-full.txt (via scripts/generate-llms-txt.mjs).
Regenerates just web_deploy/llms.txt and web_deploy/llms-full.txt from the current spec/openapi.yaml, docs/llms-curation.yaml, /docs/api, and /docs/guides — useful when iterating on curation without a full rebuild.
Bundles the OpenAPI spec to web_deploy/openapi.yaml.
Alias for npm run lint.
After changing the spec layout or build pipeline, open the local preview (npm run preview-docs) or the Pages preview for the PR and confirm ReDoc looks the same as the published docs at https://developers.app.sinch.com/ (sidebar tags, operations, and code samples).