openapi: 3.1.0
info:
  title: NexoUtils API
  version: 1.0.0
  description: >-
    Ten public endpoints cover QR generation, JSON formatting, text hashing, CSV/JSON, JSON/XML and CSV/XML transformations, and CSV-to-XLSX. Subscription-gated XLSX-to-PDF and provider-backed PDF-to-XLSX are not available in production; see x-nexo-availability on those operations. Published anonymous endpoints use a best-effort Cloudflare limit of 15 requests per minute per IP and Cloudflare location; this limit is for abuse control, not billing.
    API Pro requests share a configurable monthly allowance across all account keys. Requests that pass authentication and rate limits count before payload validation; the UTC calendar month resets on day 1. Free accounts keep their existing per-minute limits and have no monthly cap.
servers:
  - url: https://nexo-utils.com/api/v1
security:
  - ApiKey: []
  - BearerKey: []
paths:
  /qr-code:
    post:
      summary: Generate a static QR code
      operationId: createQrCode
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [text]
              properties:
                text:
                  type: string
                  minLength: 1
                  maxLength: 2000
                size:
                  type: integer
                  minimum: 256
                  maximum: 2048
                  default: 512
                foreground:
                  type: string
                  pattern: '^#[0-9a-fA-F]{6}$'
                  default: '#111827'
                background:
                  type: string
                  pattern: '^#[0-9a-fA-F]{6}$'
                  default: '#ffffff'
      responses:
        '200':
          description: SVG QR code attachment
          headers:
            X-Nexo-API-Version:
              schema: { type: string, const: '1' }
          content:
            image/svg+xml:
              schema:
                type: string
        '400': { $ref: '#/components/responses/InvalidRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '413': { $ref: '#/components/responses/PayloadTooLarge' }
        '415': { $ref: '#/components/responses/JsonRequired' }
        '422': { $ref: '#/components/responses/InvalidInput' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/Unavailable' }
  /json/format:
    post:
      summary: Validate and format JSON text
      operationId: formatJson
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [value]
              properties:
                value:
                  type: string
                  maxLength: 900000
                compact:
                  type: boolean
                  default: false
      responses:
        '200':
          description: Formatted JSON text
          headers:
            X-Nexo-API-Version:
              schema: { type: string, const: '1' }
          content:
            application/json:
              schema:
                type: object
                required: [result]
                properties:
                  result: { type: string }
        '400': { $ref: '#/components/responses/InvalidRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '413': { $ref: '#/components/responses/PayloadTooLarge' }
        '415': { $ref: '#/components/responses/JsonRequired' }
        '422': { $ref: '#/components/responses/InvalidInput' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/Unavailable' }
  /hash:
    post:
      summary: Generate a SHA-2 digest for UTF-8 text
      operationId: hashText
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [text]
              properties:
                text:
                  type: string
                  maxLength: 900000
                algorithm:
                  type: string
                  enum: [SHA-256, SHA-384, SHA-512]
                  default: SHA-256
      responses:
        '200':
          description: Hexadecimal digest
          headers:
            X-Nexo-API-Version:
              schema: { type: string, const: '1' }
          content:
            application/json:
              schema:
                type: object
                required: [algorithm, digest]
                properties:
                  algorithm: { type: string, enum: [SHA-256, SHA-384, SHA-512] }
                  digest: { type: string, pattern: '^[a-f0-9]+$' }
        '400': { $ref: '#/components/responses/InvalidRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '413': { $ref: '#/components/responses/PayloadTooLarge' }
        '415': { $ref: '#/components/responses/JsonRequired' }
        '422': { $ref: '#/components/responses/InvalidInput' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/Unavailable' }
  /csv/to-json:
    post:
      summary: Parse CSV into JSON records
      description: >-
        An API key is optional. Without a key, Cloudflare applies a best-effort limit of 15 requests per minute per IP and location; this is not an accounting limit. Accepts UTF-8 CSV using RFC 4180 quoting with CRLF or LF
        record separators. The request body and CSV text are each limited to 1 MiB.
        The selected delimiter may be comma, semicolon, tab, or pipe; when omitted,
        the endpoint detects it from the first logical record and prefers comma in a
        tie. With a header, empty or whitespace-only names, duplicate names, and
        rows wider than the header are rejected; shorter rows are padded with empty strings. Without a header, each
        record is returned as an array of strings. The limits are 10,000 rows, 100
        columns per row, 1,000,000 cells, and 262,144 characters per cell.
      operationId: convertCsvToJson
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CsvToJsonRequest'
            examples:
              withHeader:
                value:
                  csv: "name,active\r\nAna,true"
                  hasHeader: true
              withoutHeader:
                value:
                  csv: "Ana,true\r\nRui,false"
                  hasHeader: false
      responses:
        '200':
          description: Parsed records. Record values remain strings.
          headers:
            X-Nexo-API-Version:
              schema: { type: string, const: '1' }
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CsvToJsonResponse'
              examples:
                withHeader:
                  value:
                    records:
                      - name: Ana
                        active: 'true'
                    headers: [name, active]
                    rowCount: 1
                    columnCount: 2
                    delimiter: ','
        '400': { $ref: '#/components/responses/InvalidRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '413': { $ref: '#/components/responses/PayloadTooLarge' }
        '415': { $ref: '#/components/responses/JsonRequired' }
        '422': { $ref: '#/components/responses/InvalidInput' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/Unavailable' }
  /json/to-csv:
    post:
      summary: Serialize JSON records as CSV
      description: >-
        An API key is optional. Without a key, Cloudflare applies a best-effort limit of 15 requests per minute per IP and location; this is not an accounting limit. Accepts up to 10,000 output rows, with a maximum of 100 columns,
        1,000,000 cells, and 262,144 characters per cell. With object records and
        the default header, use at most 9,999 input records. The request body is
        limited to 1 MiB. Object columns follow first appearance order; missing and
        null values become empty fields. Array rows are emitted as provided and may
        be ragged. Output uses RFC 4180 quoting and CRLF record separators. CSV
        quoting does not neutralize spreadsheet formulas by itself. Set
        spreadsheetSafe to true to prefix formula-like string cells and headers
        with an apostrophe for safer spreadsheet imports; this opt-in behavior is
        disabled by default for backward compatibility. Object and array records
        cannot be mixed.
      operationId: convertJsonToCsv
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/JsonToCsvRequest'
            examples:
              withHeader:
                value:
                  records:
                    - name: "Ana, Silva"
                      active: true
                    - name: Rui
                      active: false
                  delimiter: ';'
                  includeHeader: true
              formulaSafe:
                value:
                  records:
                    - name: '=HYPERLINK("https://example.com")'
                  spreadsheetSafe: true
      responses:
        '200':
          description: CSV text encoded as a JSON string.
          headers:
            X-Nexo-API-Version:
              schema: { type: string, const: '1' }
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonToCsvResponse'
              examples:
                semicolonDelimited:
                  value:
                    csv: "name;active\r\n\"Ana, Silva\";true\r\nRui;false"
                    rowCount: 2
                    columnCount: 2
                    delimiter: ';'
        '400': { $ref: '#/components/responses/InvalidRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '413': { $ref: '#/components/responses/PayloadTooLarge' }
        '415': { $ref: '#/components/responses/JsonRequired' }
        '422': { $ref: '#/components/responses/InvalidInput' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/Unavailable' }
  /xml/to-json:
    post:
      summary: Convert well-formed XML to JSON
      description: >-
        Available without a key under the shared best-effort anonymous abuse limit. Accepts a single-root XML document in UTF-8, up to 900,000 characters in a 1 MiB JSON body, with a maximum depth of 64 and 20,000 elements. Attributes use the `@_` prefix and repeated elements become arrays. DTD and entity declarations are rejected, as is mixed text-and-element content; XML entities defined by XML itself are decoded. Request bodies and document content are not persisted.
      operationId: convertXmlToJson
      x-nexo-availability: available
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [xml]
              properties:
                xml:
                  type: string
                  minLength: 1
                  maxLength: 900000
      responses:
        '200':
          description: Parsed XML tree. Attributes use `@_`; repeated child elements are arrays.
          headers:
            X-Nexo-API-Version:
              schema: { type: string, const: '1' }
          content:
            application/json:
              schema:
                type: object
                required: [result]
                properties:
                  result:
                    type: object
                    additionalProperties: true
        '400': { $ref: '#/components/responses/InvalidRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '413': { $ref: '#/components/responses/PayloadTooLarge' }
        '415': { $ref: '#/components/responses/JsonRequired' }
        '422': { $ref: '#/components/responses/InvalidInput' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/Unavailable' }
  /json/to-xml:
    post:
      summary: Convert JSON to XML
      description: >-
        Available without a key under the shared best-effort anonymous abuse limit. `value` must be an object containing exactly one root element. Nested arrays create repeated elements, `@_name` properties create attributes, and `#text` represents element text. Text and attribute values are escaped. Mixed text-and-element content, invalid XML names/characters, XML names longer than 128 characters, depth above 64, more than 20,000 nodes, and output above 1 MiB are rejected. Request bodies and document content are not persisted.
      operationId: convertJsonToXml
      x-nexo-availability: available
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [value]
              properties:
                value:
                  type: object
                  minProperties: 1
                  maxProperties: 1
                  additionalProperties: true
      responses:
        '200':
          description: UTF-8 XML attachment.
          headers:
            Cache-Control:
              schema: { type: string, const: no-store }
            Content-Disposition:
              schema: { type: string, const: 'attachment; filename="nexoutils.xml"' }
            X-Nexo-API-Version:
              schema: { type: string, const: '1' }
          content:
            application/xml:
              schema:
                type: string
        '400': { $ref: '#/components/responses/InvalidRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '413': { $ref: '#/components/responses/PayloadTooLarge' }
        '415': { $ref: '#/components/responses/JsonRequired' }
        '422': { $ref: '#/components/responses/InvalidInput' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/Unavailable' }
  /csv/to-xml:
    post:
      summary: Convert CSV rows to repeated XML elements
      description: >-
        Available without a key under the shared best-effort anonymous abuse limit. Accepts CSV UTF-8 in a JSON body up to 1 MiB, with up to 10,000 rows, 100 columns, and 262,144 characters per cell. A combined 20,000-node XML complexity limit also applies, so row and column maxima cannot be reached simultaneously. The delimiter is detected when omitted. Headers become child elements; headers prefixed with `@_` become attributes and `#text` becomes direct row text (which cannot be combined with child-element columns). Without headers, columns are named column1, column2, etc. All cell values remain strings. Root and row element names default to `rows` and `row`. DTD declarations, XML names longer than 128 characters, and invalid XML names/characters are rejected. The XML attachment is limited to 1 MiB. Content is processed in memory and not persisted.
      operationId: convertCsvToXml
      x-nexo-availability: available
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CsvToXmlRequest'
            examples:
              catalog:
                value:
                  csv: "@_id,name\r\n7,Ana"
                  rootName: catalog
                  rowName: item
      responses:
        '200':
          description: UTF-8 XML attachment.
          headers:
            Cache-Control:
              schema: { type: string, const: no-store }
            Content-Disposition:
              schema: { type: string, const: 'attachment; filename="nexoutils.xml"' }
            X-Nexo-API-Version:
              schema: { type: string, const: '1' }
          content:
            application/xml:
              schema: { type: string }
        '400': { $ref: '#/components/responses/InvalidRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '413': { $ref: '#/components/responses/PayloadTooLarge' }
        '415': { $ref: '#/components/responses/JsonRequired' }
        '422': { $ref: '#/components/responses/InvalidInput' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/Unavailable' }
  /xml/to-csv:
    post:
      summary: Flatten simple XML rows to CSV
      description: >-
        Available without a key under the shared best-effort anonymous abuse limit. Accepts a single-root XML document in UTF-8 up to 900,000 characters in a 1 MiB JSON body, with a maximum depth of 64 and 20,000 elements. The root must contain one repeated row element type and no root attributes. Each row may contain only simple child elements and attributes; nested or repeated child elements and mixed content are rejected to avoid data loss. Element names become CSV columns and attributes use the `@_` prefix. Headers are included by default. DTD/entity declarations are rejected. Generated JSON response bodies are capped at 1 MiB. Content is processed in memory and not persisted.
      operationId: convertXmlToCsv
      x-nexo-availability: available
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/XmlToCsvRequest'
            examples:
              catalog:
                value:
                  xml: '<rows><row id="7"><name>Ana</name></row></rows>'
                  delimiter: ','
                  includeHeader: true
      responses:
        '200':
          description: CSV text encoded as a JSON string.
          headers:
            X-Nexo-API-Version:
              schema: { type: string, const: '1' }
          content:
            application/json:
              schema:
                type: object
                additionalProperties: false
                required: [csv, rowCount, columnCount, delimiter]
                properties:
                  csv: { type: string, maxLength: 1048320 }
                  rowCount: { type: integer, minimum: 0, maximum: 10000 }
                  columnCount: { type: integer, minimum: 0, maximum: 100 }
                  delimiter: { $ref: '#/components/schemas/CsvDelimiter' }
        '400': { $ref: '#/components/responses/InvalidRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '413': { $ref: '#/components/responses/PayloadTooLarge' }
        '415': { $ref: '#/components/responses/JsonRequired' }
        '422': { $ref: '#/components/responses/InvalidInput' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/Unavailable' }
  /csv/to-xlsx:
    post:
      summary: Convert a CSV file to an XLSX workbook
      description: >-
        Available in production. No API key is required; anonymous calls use the best-effort abuse limit described above. Accepts one UTF-8 `.csv` file up to 1 MiB. The request body may be at most 1 MiB plus multipart overhead. Delimiter may be comma, semicolon, tab, or pipe; if omitted, it is detected from the first logical record and comma wins ties. The workbook contains one sheet named `Dados`. `valueMode` defaults to `text`, which stores every value as inert text. `general` converts finite decimal numbers that fit Excel's 15-significant-digit precision and valid ISO `YYYY-MM-DD` dates from 1900 onward; formula-like text, leading-zero strings, ambiguous dates, out-of-range numbers, and other formats remain text. The response reports the selected mode in `X-Nexo-CSV-Value-Mode`. Limits are 10,000 rows, 100 columns per row, 1,000,000 cells, 32,767 characters per cell, and an 8 MiB generated workbook. Expanded worksheet XML is bounded during generation; a workbook exceeding 8 MiB returns `413 xlsx_output_too_large`. Files are processed by the NexoUtils Worker and are not sent to ConvertAPI or persisted by this endpoint.
      operationId: convertCsvFileToXlsx
      x-nexo-availability: available
      security: []
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              additionalProperties: false
              required: [file]
              properties:
                file:
                  type: string
                  format: binary
                  description: One UTF-8 CSV file with a .csv filename, up to 1 MiB.
                delimiter:
                  type: string
                  enum: [',', ';', "\t", '|']
                  description: Optional field delimiter. If omitted, the service detects comma, semicolon, tab, or pipe from the first logical record.
                valueMode:
                  type: string
                  enum: [text, general]
                  default: text
                  description: >-
                    Optional cell interpretation. `text` keeps all values inert as text. `general` converts finite decimal numbers within Excel's 15-significant-digit precision and valid ISO dates (YYYY-MM-DD, from 1900 onward); formulas, leading-zero strings, ambiguous dates, out-of-range numbers, and other formats remain text.
      responses:
        '200':
          description: XLSX workbook attachment with one worksheet. The selected cell interpretation is reported by X-Nexo-CSV-Value-Mode.
          headers:
            Cache-Control:
              schema: { type: string, const: no-store }
            Content-Disposition:
              schema: { type: string, const: 'attachment; filename="nexo-utils-csv-to-xlsx.xlsx"' }
            X-Nexo-API-Version:
              schema: { type: string, const: '1' }
            X-Nexo-CSV-Rows:
              schema: { type: integer, minimum: 1, maximum: 10000 }
            X-Nexo-CSV-Columns:
              schema: { type: integer, minimum: 1, maximum: 100 }
            X-Nexo-CSV-Delimiter:
              schema: { type: string, enum: [',', ';', tab, '|'] }
            X-Nexo-CSV-Value-Mode:
              schema: { type: string, enum: [text, general] }
          content:
            application/vnd.openxmlformats-officedocument.spreadsheetml.sheet:
              schema:
                type: string
                format: binary
        '400': { $ref: '#/components/responses/InvalidMultipart' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '413':
          description: The CSV upload exceeds 1 MiB, the multipart request exceeds its bounded overhead, or the generated XLSX exceeds 8 MiB.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/Error' }
        '415': { $ref: '#/components/responses/UnsupportedMedia' }
        '422': { $ref: '#/components/responses/InvalidInput' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '500':
          description: Workbook generation failed
          content:
            application/json:
              schema: { $ref: '#/components/schemas/Error' }
        '503': { $ref: '#/components/responses/Unavailable' }
  /xlsx-to-pdf:
    post:
      summary: Convert selected XLSX worksheets to PDF
      description: This contract is not available in production. Login, API key onboarding, billing, and the hosted XLSX processor must be enabled before calls can succeed. When available, it will require an API key owned by an account with an active XLSX Pro subscription and available monthly usage.
      operationId: convertXlsxToPdf
      x-nexo-availability: not-in-production
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required: [file, settings]
              properties:
                file:
                  type: string
                  format: binary
                  description: One XLSX file up to 10 MiB.
                settings:
                  $ref: '#/components/schemas/XlsxPdfSettings'
            encoding:
              settings:
                contentType: application/json
      responses:
        '200':
          description: PDF attachment. A successful conversion consumes one monthly account unit.
          headers:
            Cache-Control:
              schema: { type: string, const: no-store }
            X-Nexo-API-Version:
              schema: { type: string, const: '1' }
            X-Nexo-PDF-Pages:
              schema: { type: integer, minimum: 1 }
          content:
            application/pdf:
              schema:
                type: string
                format: binary
        '400': { $ref: '#/components/responses/InvalidMultipart' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/SubscriptionRequired' }
        '413': { $ref: '#/components/responses/PayloadTooLarge' }
        '415': { $ref: '#/components/responses/UnsupportedMedia' }
        '422': { $ref: '#/components/responses/InvalidInput' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '502': { $ref: '#/components/responses/ProcessorFailure' }
        '503': { $ref: '#/components/responses/Unavailable' }
        '504': { $ref: '#/components/responses/ProcessorFailure' }
  /pdf-to-xlsx:
    post:
      summary: Extract selected PDF pages to an XLSX workbook
      description: >-
        Implemented in this branch but disabled in production. When enabled, the endpoint requires an API key
        owned by an account with an active API Pro subscription. One PDF file up to 10 MiB is sent server-to-server
        to ConvertAPI; the integration requests in-memory output with StoreFile=false and does not accept user URLs.
        The default page range is 1-5 and at most 25 distinct pages may be selected. PDF table reconstruction and OCR
        can change values and layout; users must verify the resulting workbook.
      operationId: convertPdfToXlsx
      x-nexo-availability: not-in-production
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              additionalProperties: false
              required: [file]
              properties:
                file:
                  type: string
                  format: binary
                  description: One PDF file up to 10 MiB.
                settings:
                  $ref: '#/components/schemas/PdfToXlsxSettings'
            encoding:
              settings:
                contentType: application/json
      responses:
        '200':
          description: XLSX attachment. The API Pro monthly request allowance applies.
          headers:
            Cache-Control:
              schema: { type: string, const: no-store }
            Content-Disposition:
              schema: { type: string, const: 'attachment; filename="nexo-utils-pdf-to-xlsx.xlsx"' }
            X-Nexo-API-Version:
              schema: { type: string, const: '1' }
            X-Nexo-PDF-Pages-Selected:
              schema: { type: integer, minimum: 1, maximum: 25 }
            X-Nexo-Provider-Cost-Recorded:
              description: Whether the provider credit count was added to the daily API usage aggregate. False requires reconciliation against the ConvertAPI dashboard.
              schema: { type: string, enum: ['true', 'false'] }
          content:
            application/vnd.openxmlformats-officedocument.spreadsheetml.sheet:
              schema:
                type: string
                format: binary
        '400': { $ref: '#/components/responses/InvalidMultipart' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403':
          description: An active API Pro subscription is required.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/Error' }
        '413': { $ref: '#/components/responses/PayloadTooLarge' }
        '415': { $ref: '#/components/responses/UnsupportedMedia' }
        '422': { $ref: '#/components/responses/InvalidInput' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '502': { $ref: '#/components/responses/ProcessorFailure' }
        '503': { $ref: '#/components/responses/Unavailable' }
        '504': { $ref: '#/components/responses/ProcessorFailure' }
components:
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: X-API-Key
    BearerKey:
      type: http
      scheme: bearer
  schemas:
    CsvDelimiter:
      type: string
      enum: [',', ';', "\t", '|']
      description: One supported single-character field delimiter.
    CsvToJsonRequest:
      type: object
      additionalProperties: false
      required: [csv]
      properties:
        csv:
          type: string
          minLength: 1
          maxLength: 1048576
          description: UTF-8 CSV text; the encoded field and complete JSON request body are each limited to 1 MiB.
        delimiter:
          type: string
          enum: [',', ';', "\t", '|']
          description: If omitted, the delimiter is detected from the first logical record; comma wins ties.
        hasHeader:
          type: boolean
          default: true
    CsvToXmlRequest:
      type: object
      additionalProperties: false
      required: [csv]
      properties:
        csv:
          type: string
          minLength: 1
          maxLength: 1048576
          description: CSV text; the complete JSON body is limited to 1 MiB.
        hasHeader: { type: boolean, default: true }
        delimiter:
          allOf:
            - $ref: '#/components/schemas/CsvDelimiter'
          description: If omitted, detects comma, semicolon, tab, or pipe from the first logical record.
        rootName: { type: string, default: rows, maxLength: 128, description: Must be a valid XML element name. }
        rowName: { type: string, default: row, maxLength: 128, description: Must be a valid XML element name. }
    XmlToCsvRequest:
      type: object
      additionalProperties: false
      required: [xml]
      properties:
        xml:
          type: string
          minLength: 1
          maxLength: 900000
          description: XML UTF-8; the complete JSON body is limited to 1 MiB.
        delimiter:
          allOf:
            - $ref: '#/components/schemas/CsvDelimiter'
          default: ','
        includeHeader: { type: boolean, default: true }
        spreadsheetSafe:
          type: boolean
          default: false
          description: When true, prefixes formula-like string values with an apostrophe for safer spreadsheet imports.
    CsvToJsonResponse:
      type: object
      required: [records, rowCount, columnCount, delimiter]
      properties:
        records:
          type: array
          items:
            oneOf:
              - type: object
                additionalProperties: { type: string }
              - type: array
                items: { type: string }
          description: Objects when hasHeader is true; arrays of strings otherwise.
        headers:
          type: array
          items: { type: string }
        rowCount:
          type: integer
          minimum: 0
        columnCount:
          type: integer
          minimum: 0
        delimiter:
          $ref: '#/components/schemas/CsvDelimiter'
    JsonToCsvRequest:
      type: object
      additionalProperties: false
      required: [records]
      properties:
        records:
          type: array
          maxItems: 10000
          description: Either all object records or all array rows. Do not mix types.
          items:
            oneOf:
              - type: object
                minProperties: 1
                additionalProperties:
                  oneOf:
                    - { type: string, maxLength: 262144 }
                    - { type: number }
                    - { type: boolean }
                    - { type: 'null' }
              - type: array
                maxItems: 100
                items:
                  oneOf:
                    - { type: string, maxLength: 262144 }
                    - { type: number }
                    - { type: boolean }
                    - { type: 'null' }
        delimiter:
          allOf:
            - $ref: '#/components/schemas/CsvDelimiter'
          default: ','
        includeHeader:
          type: boolean
          default: true
        spreadsheetSafe:
          type: boolean
          default: false
          description: When true, prefixes formula-like string cells and headers with an apostrophe so spreadsheet software treats them as text. JSON numbers and booleans remain unchanged. Disabled by default for backward compatibility.
      description: Complete UTF-8 JSON request body is limited to 1 MiB. For object records, includeHeader writes property names. For array rows, include the header row in the records array; includeHeader does not create one.
    JsonToCsvResponse:
      type: object
      required: [csv, rowCount, columnCount, delimiter]
      properties:
        csv:
          type: string
          description: CSV text with RFC 4180 quoting and CRLF record separators.
        rowCount:
          type: integer
          minimum: 0
          description: Number of input records or array rows; an object header is not counted.
        columnCount:
          type: integer
          minimum: 0
        delimiter:
          $ref: '#/components/schemas/CsvDelimiter'
    XlsxPdfSettings:
      type: object
      additionalProperties: false
      required: [sheetNames, paperSize, orientation, marginsMm, fitToWidth]
      properties:
        sheetNames:
          type: array
          minItems: 1
          maxItems: 20
          uniqueItems: true
          items: { type: string, minLength: 1, maxLength: 31 }
        paperSize: { type: string, enum: [A3, A4, A5, B4, B5, Executive, Legal, Letter, Statement, Tabloid, Custom] }
        customPageSizeMm:
          anyOf:
            - type: object
              additionalProperties: false
              required: [widthMm, heightMm]
              properties:
                widthMm: { type: number, minimum: 50, maximum: 500 }
                heightMm: { type: number, minimum: 50, maximum: 500 }
            - type: 'null'
          description: Required when paperSize is Custom; omitted or null for a named standard size.
        orientation: { type: string, enum: [portrait, landscape] }
        marginsMm:
          type: object
          additionalProperties: false
          required: [top, right, bottom, left]
          properties:
            top: { type: number, minimum: 0, maximum: 50 }
            right: { type: number, minimum: 0, maximum: 50 }
            bottom: { type: number, minimum: 0, maximum: 50 }
            left: { type: number, minimum: 0, maximum: 50 }
        fitToWidth: { type: boolean, description: Fit the print range to one page wide. When true, scalePercent must be 100. }
        clearPrintAreas: { type: boolean, default: false, description: Clear selected worksheets' saved print areas before applying supplied printAreas. Cannot be combined with preserveWorkbookSettings. }
        preserveWorkbookSettings: { type: boolean, default: false, description: Preserve each selected worksheet's saved print area, page size, orientation, margins, scale, and print titles. Takes precedence over supplied print overrides; sheetNames still controls included worksheets. Cannot be combined with clearPrintAreas. }
        fitToPage: { type: boolean, default: false, description: Fit each selected worksheet to one page. Cannot be combined with fitToWidth; scalePercent must be 100. }
        scalePercent: { type: integer, minimum: 10, maximum: 300, default: 100, description: Fixed print scale used only when fitToWidth and fitToPage are false. }
        repeatHeaderRows: { type: integer, minimum: 0, maximum: 10, default: 0, description: Repeat this many rows from the top of each selected worksheet on subsequent printed pages. Zero disables repeated title rows. }
        printAreas:
          type: object
          maxProperties: 20
          additionalProperties:
            type: string
            pattern: '^[A-Za-z]{1,3}[1-9][0-9]{0,6}:[A-Za-z]{1,3}[1-9][0-9]{0,6}$'
          description: Optional A1 range per selected sheet, for example Summary=A1:H36. One contiguous, top-left-to-bottom-right range of at most 1,000,000 cells. Omitted sheets keep saved settings unless clearPrintAreas is true.
        sheetSettings:
          type: object
          maxProperties: 20
          additionalProperties:
            $ref: '#/components/schemas/XlsxPdfSheetSettings'
          description: Optional per-sheet page size, orientation, and scale overrides. Keys must name selected worksheets. Omitted options inherit the workbook-wide settings; margins remain global.
      allOf:
        - not:
            required: [clearPrintAreas, preserveWorkbookSettings]
            properties:
              clearPrintAreas: { const: true }
              preserveWorkbookSettings: { const: true }
        - if:
            anyOf:
              - required: [fitToWidth]
              - required: [fitToPage]
              - required: [scalePercent]
          then:
            allOf:
              - not:
                  required: [fitToWidth, fitToPage]
                  properties:
                    fitToWidth: { const: true }
                    fitToPage: { const: true }
              - if:
                  required: [fitToWidth]
                  properties:
                    fitToWidth: { const: true }
                then:
                  properties:
                    scalePercent: { const: 100 }
              - if:
                  required: [fitToPage]
                  properties:
                    fitToPage: { const: true }
                then:
                  properties:
                    scalePercent: { const: 100 }
    XlsxPdfSheetSettings:
      type: object
      additionalProperties: false
      properties:
        paperSize: { type: string, enum: [A3, A4, A5, B4, B5, Executive, Legal, Letter, Statement, Tabloid] }
        orientation: { type: string, enum: [portrait, landscape] }
        fitToWidth: { type: boolean }
        fitToPage: { type: boolean }
        scalePercent: { type: integer, minimum: 10, maximum: 300, default: 100 }
      allOf:
        - if:
            anyOf:
              - required: [fitToWidth]
              - required: [fitToPage]
              - required: [scalePercent]
          then:
            required: [fitToWidth, fitToPage]
            allOf:
              - not:
                  required: [fitToWidth, fitToPage]
                  properties:
                    fitToWidth: { const: true }
                    fitToPage: { const: true }
              - if:
                  required: [fitToWidth]
                  properties:
                    fitToWidth: { const: true }
                then:
                  properties:
                    scalePercent: { const: 100 }
              - if:
                  required: [fitToPage]
                  properties:
                    fitToPage: { const: true }
                then:
                  properties:
                    scalePercent: { const: 100 }
      description: Per-sheet overrides. If any scaling property is provided, both fit flags are required. Exactly one fit flag may be true; fixed scale requires both false and defaults to 100 percent.
    PdfToXlsxSettings:
      type: object
      additionalProperties: false
      properties:
        pages:
          type: string
          maxLength: 128
          pattern: '^\d{1,4}(?:-\d{1,4})?(?:,\d{1,4}(?:-\d{1,4})?)*$'
          default: '1-5'
          description: Comma-separated page numbers or ranges, with no duplicates; at most 25 distinct pages from 1 to 2000.
        password:
          type: string
          maxLength: 256
          description: Optional PDF password. It is sent to ConvertAPI with the file and is never included in logs or analytics.
        ocrMode: { type: string, enum: [auto, force, never], default: auto }
        ocrLanguage:
          type: string
          enum: [auto, ar, ca, zh, da, nl, en, fi, fr, de, el, ko, it, ja, no, pl, pt, ro, ru, sl, es, sv, tr, ua, th]
          default: auto
        ocrEngine:
          type: string
          enum: [native, tesseract]
          default: native
          description: Tesseract requires a specific ocrLanguage rather than auto.
        includeFormatting: { type: boolean, default: false }
        singleSheet: { type: boolean, default: false }
        decimalSeparator: { type: string, enum: [auto, period, comma], default: auto }
        thousandsSeparator: { type: string, enum: [auto, period, comma, space], default: auto }
    Error:
      type: object
      required: [error]
      properties:
        error:
          type: object
          required: [code, message]
          properties:
            code: { type: string }
            message: { type: string }
  responses:
    InvalidRequest:
      description: Request body is not valid JSON
      content:
        application/json:
          schema: { $ref: '#/components/schemas/Error' }
    PayloadTooLarge:
      description: Request body exceeds the endpoint limit
      content:
        application/json:
          schema: { $ref: '#/components/schemas/Error' }
    JsonRequired:
      description: Request must use application/json
      content:
        application/json:
          schema: { $ref: '#/components/schemas/Error' }
    Unauthorized:
      description: Missing, invalid, or expired API key
      content:
        application/json:
          schema: { $ref: '#/components/schemas/Error' }
    InvalidInput:
      description: Input does not meet endpoint requirements
      content:
        application/json:
          schema: { $ref: '#/components/schemas/Error' }
    InvalidMultipart:
      description: Multipart body is malformed or a required field is missing
      content:
        application/json:
          schema: { $ref: '#/components/schemas/Error' }
    UnsupportedMedia:
      description: Request must use multipart/form-data or the workbook format is unsupported
      content:
        application/json:
          schema: { $ref: '#/components/schemas/Error' }
    SubscriptionRequired:
      description: An active XLSX Pro subscription is required
      content:
        application/json:
          schema: { $ref: '#/components/schemas/Error' }
    ProcessorFailure:
      description: The isolated spreadsheet processor failed or timed out
      content:
        application/json:
          schema: { $ref: '#/components/schemas/Error' }
    RateLimited:
      description: A per-key or account-wide per-minute limit, or the API Pro monthly allowance, was reached. For the monthly allowance, Retry-After points to the next UTC month and the monthly headers are present.
      headers:
        Retry-After:
          description: Seconds until the rate-limit window or monthly quota resets.
          schema: { type: string }
        X-Nexo-Monthly-Limit:
          description: Configured API Pro monthly request allowance; present when the monthly quota was reached.
          schema: { type: string }
        X-Nexo-Monthly-Remaining:
          description: Requests remaining in the current API Pro month; zero when the monthly quota was reached.
          schema: { type: string, const: '0' }
        X-Nexo-Monthly-Reset:
          description: Next UTC month boundary as an ISO 8601 timestamp.
          schema: { type: string, format: date-time }
      content:
        application/json:
          schema: { $ref: '#/components/schemas/Error' }
    Unavailable:
      description: Authentication, API service, monthly quota configuration, or usage storage is not configured or available
      content:
        application/json:
          schema: { $ref: '#/components/schemas/Error' }
