With the GitHub app, merged pull requests already propose doc edits. For any other code host, or to control when it runs, send the change from your pipeline as a task. usedocs reads the diff against your docs and proposes edits to the articles it affects, new articles it needs, and a changelog entry. Nothing goes live until someone applies it.
You need a workspace API key with content:write (Settings → API and MCP), stored as a secret named USEDOCS_API_KEY. Send an Idempotency-Key so a retried job doesn't run twice.
GitHub Actions
# .github/workflows/docs.yml
on:
pull_request:
types: [closed]
jobs:
docs:
if: github.event.pull_request.merged
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- name: Send the change to usedocs
env:
USEDOCS_API_KEY: ${{ secrets.USEDOCS_API_KEY }}
TITLE: ${{ github.event.pull_request.title }}
URL: ${{ github.event.pull_request.html_url }}
run: |
git diff ${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.merge_commit_sha }} |
jq -Rs --arg t "$TITLE" --arg u "$URL" '{change: {kind: "pr", title: $t, url: $u, diff: .}}' |
curl -sS -X POST "https://usedocs.app/v1/tasks" \
-H "Authorization: Bearer $USEDOCS_API_KEY" -H "Content-Type: application/json" \
-H "Idempotency-Key: ${{ github.sha }}" --data-binary @-GitLab CI
# .gitlab-ci.yml
docs:
rules: [{ if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' }]
script:
- git diff "$CI_COMMIT_BEFORE_SHA...$CI_COMMIT_SHA" |
jq -Rs --arg t "$CI_COMMIT_TITLE" '{change: {kind: "pr", title: $t, diff: .}}' |
curl -sS -X POST "https://usedocs.app/v1/tasks" -H "Authorization: Bearer $USEDOCS_API_KEY"
-H "Content-Type: application/json" -H "Idempotency-Key: $CI_COMMIT_SHA" --data-binary @-See what it proposed
The response is a task. Poll GET /v1/tasks/{id} until it's completed, or subscribe to the task.completed webhook. Its result.draftIds are the proposed edits and new articles; open them in Drafts → To review, or read them with GET /v1/drafts/{id}, which includes a unified diff. See the Docs API.