CI/CD integration

Prev Next

The CI/CD flow keeps your API documentation in sync with your spec file. Instead of uploading a new spec every time your API changes, you add the Document360 CLI (d360) to your existing pipeline. When your spec changes, the pipeline runs and your documentation updates automatically.

Requirements

Before you set up the CI/CD flow, make sure you have:

  • Node.js 18 or later installed on the system that runs the pipeline. For installation steps, see the Node.js documentation.
  • Your API key, user ID, workspace ID, and API reference ID. To find them, see the next section.
  • A spec file that the pipeline can reach, either as a local file path or a hosted URL.

Find your API key and IDs

Document360 shows these values in a ready-to-run CLI command, so you can copy them from there:

  • For a new API reference: In the New API reference window, select the CI/CD Flow option.
  • For an existing API reference: Open the API reference, click Edit API reference, then click Show details on the "You can also update and resync the API Reference using our D360 npm package" banner.

The command includes your --apiKey, --userId, and either --versionId (your workspace ID) or --apiReferenceId.

IMPORTANT!

Use the --apiKey value from the prefilled command. [TO CONFIRM: whether the v3 API keys created in Settings > Knowledge base portal > API keys (starting with d360_sk_) work with the apidocs:* commands. If not, keep this warning and update the link.]

Install the CLI

Install the CLI globally: npm install -g d360

NOTE

You only need to install the CLI once on each system. If it's already installed, skip this step.

Choose a CLI command family

The Document360 CLI supports two command families: apiref (V3) and apidocs (v2). Use apiref submit if you're setting up a new integration, since it works with the newer Customer API V3 and accepts a V3 scoped API key created under Settings > Knowledge base portal > API keys. Use apidocs:submit if your pipeline already uses the apidocs family, since it continues to work with your existing CI/CD key.

The rest of this article documents the apidocs (v2) family. If you're starting a new integration and want to use apiref submit (V3) instead, see the full command reference, credential requirements, and pipeline examples in the Migrating to asynchronous API reference import and resync article.

IMPORTANT!

apiref import, apiref resync, apidocs, and apidocs:resync are deprecated. Document360 plans to remove the old synchronous endpoints and CLI commands around the end of November 2026, but this date has not been confirmed, and Document360 will announce the final removal date before anything is removed. See the Migrating to asynchronous API reference import and resync article for migration steps.

Validate your spec file

Before you import or resync, check your spec file for errors:

d360 apidocs:validate --apiKey=<api-key> --path=<path-to-spec-file>

Validation reports errors and warnings without changing your API reference. It needs only --apiKey and --path. Run it as the first step in your pipeline to catch spec issues early.

Create an API reference from the CLI

If you're setting up the CI/CD flow for a new API reference, create it from the CLI:

  1. In the Knowledge base portal, go to API documentation { } in the left navigation bar.

  2. Click the Create dropdown and select New API.

  3. In the New API reference window, select the CI/CD Flow option.

  4. Copy the values from the command shown in the window.

  5. Run the import with your spec file path or URL:

    d360 apidocs:submit --apiKey=<api-key> --userId=<user-id> --versionId=<workspace-id> --path=<path-to-spec-file>

    For example, --path=/Users/yourname/projects/api/openapi.yaml for a local file, or --path=https://example.com/api/openapi.yaml for a hosted file.

  6. The CLI prints a task ID and returns immediately while the import runs in the background. To see the result, run:

    d360 apidocs:status <task-id> --wait

By default, imported articles are saved as drafts. To publish them after import, add --publish.

Resync an existing API reference

When your spec changes, resync the API reference. This is the command your pipeline runs:

d360 apidocs:submit --apiKey=<api-key> --userId=<user-id> --apiReferenceId=<api-reference-id> --path=<path-to-spec-file>

Option What to enter
--apiKey Your API key from the prefilled command
--userId Your Document360 user ID
--apiReferenceId The ID of the API reference to update. Passing it makes the command a resync instead of an import.
--path The path to your spec file, or a URL to it
--apihubUrl Optional. Your region's API host, if your project isn't hosted in the EU. For example, https://apihub.us.document360.io.
--force Optional. Resyncs even if the spec has errors or warnings.
--publish Optional. Publishes the updated articles after the resync.
NOTE

A resync keeps any custom content you added to individual endpoint articles. It updates only the content generated from the spec.

Check whether the import or resync succeeded

apidocs:submit returns as soon as the task starts. To get the result, run d360 apidocs:status <task-id>:

  • While the task is running, the command reports its status and exits with code 0.
  • When the task finishes, the command shows any alerts, errors, and deleted endpoints. It exits with a non-zero code if the task failed.

In a pipeline, add --wait so the command keeps checking until the task finishes. The step then passes or fails based on the actual result.

NOTE

A project runs one import or resync at a time. If another one is already running, the CLI rejects the new request and names the task to wait for.

Sync multiple spec files

--path accepts one spec file or URL per command. To sync several services from one repository, run a separate apidocs:submit command for each service, each with its own --apiReferenceId and --path.

IMPORTANT!

Always pass --path when your repository has more than one spec file. If you leave it out, the CLI uses the first spec file it finds, which might not be the one you want.

Protect your API key

Your API key is a secret. Don't add it to your pipeline configuration files or commit it to source control. Store it as a secret or masked variable in your CI platform and reference it in the command:

d360 apidocs:submit --apiKey=$DOCUMENT360_API_KEY --userId=$DOCUMENT360_USER_ID --apiReferenceId=$API_REFERENCE_ID --path=./openapi.yaml

IMPORTANT!

If you regenerate your API key in the Document360 portal, the old key stops working immediately. Update the secret in your CI platform before the next pipeline run, or the resync fails.

Pipeline examples

GitHub Actions

Create .github/workflows/api-docs.yml:

name: Sync API docs to Document360
on:
  push:
    branches: [main]
    paths: ['openapi.yaml']
jobs:
  resync:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 'lts/*'
      - run: npm install -g d360
      - name: Validate the spec
        run: d360 apidocs:validate --apiKey="${{ secrets.DOCUMENT360_API_KEY }}" --path=./openapi.yaml
      - name: Resync to Document360
        run: |
          TASK_ID=$(d360 apidocs:submit \
            --apiKey="${{ secrets.DOCUMENT360_API_KEY }}" \
            --userId="${{ secrets.DOCUMENT360_USER_ID }}" \
            --apiReferenceId="${{ secrets.API_REFERENCE_ID }}" \
            --path=./openapi.yaml)
          d360 apidocs:status "$TASK_ID" --apiKey="${{ secrets.DOCUMENT360_API_KEY }}" --wait

Store DOCUMENT360_API_KEY, DOCUMENT360_USER_ID, and API_REFERENCE_ID as repository secrets, using the values from the prefilled command.

GitLab CI

Add the following to .gitlab-ci.yml:

stages:
  - sync

sync-api-docs:
  stage: sync
  image: node:lts
  rules:
    - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
      changes: [openapi.yaml]
  script:
    - npm install -g d360
    - d360 apidocs:validate --apiKey="$DOCUMENT360_API_KEY" --path=./openapi.yaml
    - |
      TASK_ID=$(d360 apidocs:submit \
        --apiKey="$DOCUMENT360_API_KEY" \
        --userId="$DOCUMENT360_USER_ID" \
        --apiReferenceId="$API_REFERENCE_ID" \
        --path=./openapi.yaml)
      d360 apidocs:status "$TASK_ID" --apiKey="$DOCUMENT360_API_KEY" --wait

Store DOCUMENT360_API_KEY, DOCUMENT360_USER_ID, and API_REFERENCE_ID as masked CI/CD variables in Settings > CI/CD > Variables.

NOTE

GitLab can't mask values that contain hyphens, so the user ID and API reference ID are stored unmasked.

image: node:lts

pipelines:
branches:
main:
- step:
name: Sync API docs to Document360
script:
- npm install -g d360
- d360 apidocs:validate --apiKey="(d360 apidocs:submit --apiKey="DOCUMENT360_USER_ID" --apiReferenceId="TASK_ID" --apiKey="$DOCUMENT360_API_KEY" --wait

Webhook support

The CI/CD flow supports webhooks defined in OpenAPI 3.1 specs. When a resync runs, webhook definitions are updated along with the rest of the spec.

Update pipelines that use older commands

apidocs and apidocs:resync are deprecated. If your pipeline uses them, update it:

Deprecated command Use instead
d360 apidocs d360 apidocs:submit with --versionId
d360 apidocs:resync d360 apidocs:submit with --apiReferenceId

The older commands exit with code 0 even when an import or resync fails, so pipelines had to search the console output for failure messages. With apidocs:submit followed by apidocs:status <task-id> --wait, the exit code reflects the result, and you can remove that workaround.

Helpful links