openapi: 3.0.3
info:
  title: XPress REST API
  version: 1.0.0
  description: >-
    Export Confluence pages to PDF, HTML or Markdown from scripts, pipelines and other tools. Every
    call is made as the person who authorized the OAuth 2.0 integration, with their Confluence
    permissions, and follows the same templates, locks and required watermarks as an export started in
    Confluence. A site admin turns the API on in Atlassian Administration, Apps, Sites, the site,
    Connected apps, XPress, Details, App REST APIs, where the site's base URL is shown once it is on.
    Each call needs the custom scope listed for it below and `read:forge-app:confluence`; ask for
    `offline_access` too, so the integration gets a refresh token and keeps working on its own (every
    refresh gives a new refresh token: keep the latest).


    XPress's app id is `c49b11db-4e33-4df5-83ed-2036530017dd` and its environment id is
    `324ffb0e-16fd-4b13-bf8a-7bc0202e47aa`; both are part of every base URL below.


    Errors XPress answers have one fixed body per status, `{ "code": "...", "message": "..." }`. A
    page, space, template or export you cannot use is answered exactly like one that does not exist.
    Atlassian answers some calls before they reach XPress, in its own format: 401 for a missing,
    expired or revoked token, 403 while App REST APIs are off on the site, and 404 for a path that is
    not one of these routes.


    Exports started through the API appear in the space's export history in Confluence exactly like
    exports started there: every member of the space sees that it ran, when, who started it and its
    status; its page count, its messages and its file are the person's alone. The space's history shows
    its latest 20 exports, so many API exports in one space push older ones off it. The person's own
    export list in Confluence shows them too.
servers:
  - url: https://{site}.atlassian.net/gateway/api/svc/confluence/apps/c49b11db-4e33-4df5-83ed-2036530017dd_324ffb0e-16fd-4b13-bf8a-7bc0202e47aa
    variables:
      site: { default: your-site }
  - url: https://api.atlassian.com/svc/confluence/{cloudId}/apps/c49b11db-4e33-4df5-83ed-2036530017dd_324ffb0e-16fd-4b13-bf8a-7bc0202e47aa
    variables:
      cloudId: { default: CLOUD_ID }
security:
  - oauth2: []
paths:
  /exports:
    post:
      operationId: startExport
      summary: Start an export
      description: >-
        Starts an export of a page you can read, or of the page and everything under it. The space is
        the page's own. Fields not listed here are ignored. Limits are shared with exports you start in
        Confluence: three running at once and twenty started in five minutes. An export you delete
        still counts toward the twenty until its five minutes have passed.
      security:
        - oauth2: [write:export:custom, read:forge-app:confluence]
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: '#/components/schemas/StartRequest' }
            example: { pageId: '123456', scope: descendants, format: pdf, locale: de-DE, timeZone: Europe/Berlin }
      responses:
        '202':
          description: The export is queued.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/Started' }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '402': { $ref: '#/components/responses/LicenceInactive' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '404': { $ref: '#/components/responses/NotFound' }
        '413': { $ref: '#/components/responses/TooLarge' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '500': { $ref: '#/components/responses/Error' }
        '503': { $ref: '#/components/responses/Unavailable' }
  /exports/{id}:
    parameters:
      - $ref: '#/components/parameters/ExportId'
    get:
      operationId: getExport
      summary: Get an export's status
      description: >-
        The status of an export you started through this API. Exports you started in Confluence, and
        other people's exports, are not visible here. The status never carries a download link. A
        deleted export answers 404.
      security:
        - oauth2: [read:export:custom, read:forge-app:confluence]
      responses:
        '200':
          description: The export's status.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/Export' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '402': { $ref: '#/components/responses/LicenceInactive' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '404': { $ref: '#/components/responses/NotFound' }
        '500': { $ref: '#/components/responses/Error' }
    delete:
      operationId: deleteExport
      summary: Cancel or delete an export
      description: >-
        Cancels an export that is queued or running (202), and no file of it is ever given out. One
        still queued or running 15 minutes after it started is deleted instead (200). A finished or
        failed export is deleted with its file (200), and from then on every call on it answers 404.
        No file of a cancelled or deleted export is ever given out. Calling it again on a cancelled
        export deletes it once it has stopped.
      security:
        - oauth2: [write:export:custom, read:forge-app:confluence]
      responses:
        '200':
          description: The export and its file are deleted.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/Deleted' }
        '202':
          description: The export is cancelled, and no file of it is given out.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/Cancelled' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '402': { $ref: '#/components/responses/LicenceInactive' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '404': { $ref: '#/components/responses/NotFound' }
        '500': { $ref: '#/components/responses/Error' }
        '503': { $ref: '#/components/responses/Unavailable' }
  /exports/{id}/file:
    parameters:
      - $ref: '#/components/parameters/ExportId'
    get:
      operationId: getExportFile
      summary: Get a download link for a finished export
      description: >-
        A link to the finished file, valid for one hour. Anyone holding the link can download the file
        with a plain GET and no headers while it is valid, so treat it like the file itself. A new link
        is made on every call, and only while you can still open the export's space.
      security:
        - oauth2: [read:export:custom, read:forge-app:confluence]
      responses:
        '200':
          description: A download link.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/FileLink' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '402': { $ref: '#/components/responses/LicenceInactive' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '404': { $ref: '#/components/responses/NotFound' }
        '409': { $ref: '#/components/responses/NotReady' }
        '500': { $ref: '#/components/responses/Error' }
        '503': { $ref: '#/components/responses/Unavailable' }
  /templates:
    get:
      operationId: listTemplates
      summary: List the templates you can choose in a space
      security:
        - oauth2: [read:template:custom, read:forge-app:confluence]
      parameters:
        - name: spaceKey
          in: query
          required: true
          description: The key of a space you can open, exactly as Confluence shows it (letter case included).
          schema: { type: string, pattern: '^~?[A-Za-z0-9_:-]{1,128}$' }
      responses:
        '200':
          description: The templates you can choose in the space.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/TemplateList' }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '402': { $ref: '#/components/responses/LicenceInactive' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '404': { $ref: '#/components/responses/NotFound' }
        '500': { $ref: '#/components/responses/Error' }
components:
  securitySchemes:
    oauth2:
      type: oauth2
      description: Atlassian OAuth 2.0 (3LO). Create the integration in the Atlassian developer console.
      flows:
        authorizationCode:
          authorizationUrl: https://auth.atlassian.com/authorize
          tokenUrl: https://auth.atlassian.com/oauth/token
          scopes:
            read:export:custom: Read your exports
            write:export:custom: Start and delete your exports
            read:template:custom: Read export templates
            offline_access: Get a refresh token, so the integration keeps working without you
            read:forge-app:confluence: Call the REST APIs of apps installed in Confluence
  parameters:
    ExportId:
      name: id
      in: path
      required: true
      description: The id the start answered.
      schema: { type: string, pattern: '^exp_[0-9]{1,15}_[0-9a-f]{8}$' }
  schemas:
    StartRequest:
      type: object
      required: [pageId, scope]
      properties:
        pageId:
          description: The id of a page or blog post you can read, as digits.
          oneOf:
            - { type: string, pattern: '^[1-9][0-9]{0,19}$' }
            - { type: integer, minimum: 1 }
        scope:
          type: string
          enum: [current, descendants]
          description: The page alone, or the page and every page under it you can read, in the tree's order.
        templateId:
          type: string
          pattern: '^tpl_[A-Za-z0-9_]{1,60}$'
          description: One of the templates GET /templates lists for the page's space. Without it, the space's default, else the plain starter.
        format:
          type: string
          enum: [pdf, html, markdown]
          description: >-
            Without it, the template's. A format the template or the space locks is used whatever this
            asks for, and Markdown becomes a PDF where the space requires a watermark or a lock holds
            something Markdown cannot carry.
        locale:
          type: string
          description: >-
            The language month and day names are written in, as a language code alone or with a region
            (de, de-DE, pt_BR). The code is one of en, de, fr, es, it, nl, pt, pl, sv, da, nb (Norwegian
            Bokmål), fi, cs; any other answers 400.
          example: de-DE
        timeZone:
          type: string
          description: An IANA time zone for the dates the template prints.
          example: Europe/Berlin
    Started:
      type: object
      required: [id, status]
      properties:
        id: { type: string, example: exp_1764150000000_0a1b2c3d }
        status: { type: string, enum: [queued] }
    Export:
      type: object
      required: [id, status, progress, message, createdAt]
      properties:
        id: { type: string }
        status: { type: string, enum: [queued, running, done, failed, cancelled] }
        progress: { type: integer, minimum: 0, maximum: 100 }
        message: { type: string, description: What XPress says about the export, as shown in Confluence. }
        createdAt: { type: string, format: date-time }
    FileLink:
      type: object
      required: [url, expiresAt, fileName, contentType]
      properties:
        url: { type: string, format: uri, description: Download with a plain GET. Valid for one hour. }
        expiresAt: { type: string, format: date-time }
        fileName: { type: string, example: Handbook.pdf }
        contentType: { type: string, enum: [application/pdf, text/html, text/markdown, application/zip] }
    Cancelled:
      type: object
      properties:
        id: { type: string }
        status: { type: string, enum: [cancelled] }
    Deleted:
      type: object
      properties:
        id: { type: string }
        status: { type: string, enum: [deleted] }
    TemplateList:
      type: object
      required: [templates]
      properties:
        templates:
          type: array
          items:
            type: object
            required: [id, name, isSpaceDefault]
            properties:
              id: { type: string }
              name: { type: string }
              isSpaceDefault: { type: boolean }
    Error:
      type: object
      required: [code, message]
      properties:
        code: { type: string }
        message: { type: string }
  responses:
    BadRequest:
      description: The body or a parameter is not one the API accepts.
      content: { application/json: { schema: { $ref: '#/components/schemas/Error' }, example: { code: bad_request, message: This request is not one the API accepts. Check the body and the parameters against the API reference. } } }
    Unauthorized:
      description: >-
        No authorized caller. Atlassian answers a missing, expired or revoked token itself, before XPress
        runs, in its own format (for example `{"code":401,"message":"Unauthorized"}`).
    LicenceInactive:
      description: The XPress licence on the site is not active.
      content: { application/json: { schema: { $ref: '#/components/schemas/Error' }, example: { code: licence_inactive, message: The XPress licence on this site is not active. } } }
    Forbidden:
      description: >-
        You may not use XPress on this site (XPress's `forbidden` body), or App REST APIs are off on the
        site, which Atlassian answers itself, before XPress runs, in its own format.
    NotFound:
      description: >-
        No such page, space, template or export that you can use (XPress's `not_found` body). A path that
        is not one of these routes is answered by Atlassian itself, in its own format.
      content: { application/json: { schema: { $ref: '#/components/schemas/Error' }, example: { code: not_found, message: Not found. } } }
    NotReady:
      description: The export has no file to download (queued, running, failed or cancelled).
      content: { application/json: { schema: { $ref: '#/components/schemas/Error' }, example: { code: not_ready, message: This export has no file to download. Check its status. } } }
    TooLarge:
      description: More pages than one export can hold.
      content: { application/json: { schema: { $ref: '#/components/schemas/Error' }, example: { code: too_large, message: This export is too large to start in one go. Export fewer pages at a time. } } }
    RateLimited:
      description: Too many exports running or started recently. Shared with exports started in Confluence.
      headers:
        Retry-After: { schema: { type: integer, example: 60 } }
      content: { application/json: { schema: { $ref: '#/components/schemas/Error' }, example: { code: rate_limited, message: You have too many exports running or started recently. Wait a minute and try again. } } }
    Error:
      description: Something went wrong.
      content: { application/json: { schema: { $ref: '#/components/schemas/Error' } } }
    Unavailable:
      description: The request could not be finished. Try again shortly.
      content: { application/json: { schema: { $ref: '#/components/schemas/Error' } } }
