> ## Documentation Index
> Fetch the complete documentation index at: https://www.octoparse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Assemble a contract folder into a manifest

> Merge a contract folder (files map keyed by relative path, order
preserved) into one self-contained manifest — the single source of
truth for the assembly rules shared by the portal import wizard and
the contract-json skill's self-check.

Slot files: dataapp.json / input_schema.json / output_schema.json /
runtime.json / pricing.json / examples.json / README.md (name match
is case-insensitive; the dotted `input.schema.json` spelling is also
accepted and normalized in `picked`). pricing/examples may instead
live flattened inside dataapp.json. The merged manifest then goes
through the full authoring check (same verdict as POST
/data-apps/validate); `issues` must be empty before the folder counts
as deliverable. Recoverable oddities (missing files, duplicate names
across levels, ignored non-contract files, folder-name mismatch, ...)
come back as structured `warnings` (code + params, localized by
consuming display layers), not errors.

Hard failures (400): a slot file is not valid JSON /
has the wrong shape (examples.json must be an array, other slots
objects) / exceeds 1MB, no contract file is found at all, or the
total size exceeds the 12MB channel limit. The contract channel
covers api kind only: runtime.kind=code yields an issue.

Optional 8th file `i18n.json` (`{source, locales}`, up to 4MB): it
is **not merged into the manifest** — it comes back parsed as
`translations` for the caller to save via the translations
endpoints. `source` is required (400 contract-file-invalid when
missing); invalid locales are 400 locale-invalid; a locale equal to
`source` is skipped with `i18n-locale-is-source`; path-level
problems surface as `i18n-*` warnings.

Encoding: the files map is JSON text, so byte-level encoding is the
client's concern (browsers decode as UTF-8 before upload); the
server only strips a leading UTF-8 BOM. The fixed `contract` path
segment reserves that username (like `batch`): a user named
`contract` cannot address apps named assemble/split here.

Anonymous access (like GET /data-apps/manifest-schema and the skill
zip): assembly is a pure function over the request body — nothing is
read from or written to the platform, so there is no data to
protect, and requiring a key only forced contract authors to obtain
a token before they could self-check. The per-file / total size
guards remain the only admission control.



## OpenAPI

````yaml /jp/datahub/api/openapi.json post /v1/data-apps/contract/assemble
openapi: 3.1.0
info:
  title: DataHub API
  version: 0.2.0
  description: Public /v1 contract of Octoparse DataHub. Internal channels are excluded.
servers:
  - url: https://api-datahub.octoparse.com
security:
  - bearerAuth: []
tags:
  - name: Discovery
    description: >-
      Anonymous access: platform metadata (currency), data app search, detail
      and input contract, machine-readable manifest spec.
  - name: Publishing
    description: >-
      Self-service publishing channel (API Key auth), two-phase: validate first
      (validate / package, nothing persisted), then publish (POST /data-apps,
      the submission goes live as a new Release). api kind (declarative
      integration) becomes visible on publish; code kind (code package) returns
      202 and enters an async image build; once ready it is promoted to a
      Release, visible and runnable. Poll progress via GET
      /data-apps/{ref}/builds.
  - name: Runs & Results
    description: >-
      Start / query / cancel runs and read result records with pagination.
      Business inputs go in the request body; platform run options (wait,
      max_records) go in query parameters.
  - name: Datasets
    description: >-
      Metadata and record access for platform datasets (including seeded stock
      data).
  - name: Account
    description: Account info and cumulative usage for the current API Key.
  - name: Secrets
    description: >-
      CRUD for upstream credentials (environment entries referenced by manifest
      `runtime.env`). Plaintext is write-only: every read returns a mask.
paths:
  /v1/data-apps/contract/assemble:
    post:
      tags:
        - Publishing
      summary: Assemble a contract folder into a manifest
      description: |-
        Merge a contract folder (files map keyed by relative path, order
        preserved) into one self-contained manifest — the single source of
        truth for the assembly rules shared by the portal import wizard and
        the contract-json skill's self-check.

        Slot files: dataapp.json / input_schema.json / output_schema.json /
        runtime.json / pricing.json / examples.json / README.md (name match
        is case-insensitive; the dotted `input.schema.json` spelling is also
        accepted and normalized in `picked`). pricing/examples may instead
        live flattened inside dataapp.json. The merged manifest then goes
        through the full authoring check (same verdict as POST
        /data-apps/validate); `issues` must be empty before the folder counts
        as deliverable. Recoverable oddities (missing files, duplicate names
        across levels, ignored non-contract files, folder-name mismatch, ...)
        come back as structured `warnings` (code + params, localized by
        consuming display layers), not errors.

        Hard failures (400): a slot file is not valid JSON /
        has the wrong shape (examples.json must be an array, other slots
        objects) / exceeds 1MB, no contract file is found at all, or the
        total size exceeds the 12MB channel limit. The contract channel
        covers api kind only: runtime.kind=code yields an issue.

        Optional 8th file `i18n.json` (`{source, locales}`, up to 4MB): it
        is **not merged into the manifest** — it comes back parsed as
        `translations` for the caller to save via the translations
        endpoints. `source` is required (400 contract-file-invalid when
        missing); invalid locales are 400 locale-invalid; a locale equal to
        `source` is skipped with `i18n-locale-is-source`; path-level
        problems surface as `i18n-*` warnings.

        Encoding: the files map is JSON text, so byte-level encoding is the
        client's concern (browsers decode as UTF-8 before upload); the
        server only strips a leading UTF-8 BOM. The fixed `contract` path
        segment reserves that username (like `batch`): a user named
        `contract` cannot address apps named assemble/split here.

        Anonymous access (like GET /data-apps/manifest-schema and the skill
        zip): assembly is a pure function over the request body — nothing is
        read from or written to the platform, so there is no data to
        protect, and requiring a key only forced contract authors to obtain
        a token before they could self-check. The per-file / total size
        guards remain the only admission control.
      operationId: assemble_contract_v1_data_apps_contract_assemble_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ContractAssembleRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DataEnvelope_ContractAssembleResult_'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    ContractAssembleRequest:
      properties:
        files:
          additionalProperties:
            type: string
          type: object
          title: Files
      type: object
      required:
        - files
      title: ContractAssembleRequest
      description: |-
        POST contract/assemble request body: a contract folder as a files map.

        Keys are the relative paths as picked/dragged (kept in order): the
        "duplicate name across levels" preference (shallower wins, later wins at
        equal depth) and folder-name derivation depend on them.
    DataEnvelope_ContractAssembleResult_:
      properties:
        data:
          $ref: '#/components/schemas/ContractAssembleResult'
      type: object
      required:
        - data
      title: DataEnvelope[ContractAssembleResult]
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ContractAssembleResult:
      properties:
        manifest:
          additionalProperties: true
          type: object
          title: Manifest
        picked:
          items:
            type: string
          type: array
          title: Picked
        folder_name:
          type: string
          title: Folder Name
          default: ''
        issues:
          items:
            $ref: '#/components/schemas/ManifestIssue'
          type: array
          title: Issues
        warnings:
          items:
            $ref: '#/components/schemas/ContractWarning'
          type: array
          title: Warnings
        translations:
          anyOf:
            - $ref: '#/components/schemas/ContractTranslations'
            - type: 'null'
      type: object
      required:
        - manifest
      title: ContractAssembleResult
      description: |-
        Assembly result: the merged manifest plus the full authoring check
        (same verdict as POST /data-apps/validate) and structured soft warnings.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    ManifestIssue:
      properties:
        path:
          type: string
          title: Path
        message:
          type: string
          title: Message
      type: object
      required:
        - path
        - message
      title: ManifestIssue
    ContractWarning:
      properties:
        code:
          type: string
          title: Code
        params:
          additionalProperties: true
          type: object
          title: Params
      type: object
      required:
        - code
      title: ContractWarning
      description: >-
        One structured soft warning from contract assembly. `code` is a stable

        kebab-case identifier; `params` carries the variables (file names, the

        ignored-file list, ...). Localization happens in consuming display
        layers

        keyed by `code`; unknown codes should be shown as the code itself.


        Codes: `contract-file-missing` (a non-optional slot file is absent;

        params.file), `readme-missing`, `duplicate-contract-file` (same name at

        several levels; params.file/kept/ignored), `id-field-missing`

        (output_schema.json has no id_field and runtime has no dedup_by to infer

        it from), `pricing-missing` (no pricing.json and no pricing section in

        dataapp.json), `non-contract-files-ignored` (params.files is the full

        list), `folder-name-mismatch` (params.folder_name/declared_name).

        i18n.json codes (params.locale/path): `i18n-locale-is-source` (a locale

        equal to `source`, skipped), `i18n-path-unresolved` (path not in the

        translatable allowlist or absent from the manifest),
        `i18n-type-mismatch`

        (params.expected string/list), `i18n-length-mismatch` (`enum_titles`

        length differs from `enum`; params.expected/actual),
        `i18n-path-ambiguous`

        (duplicate pricing event / example id makes the path ambiguous).
    ContractTranslations:
      properties:
        source:
          type: string
          title: Source
        locales:
          additionalProperties:
            additionalProperties: true
            type: object
          type: object
          title: Locales
      type: object
      required:
        - source
      title: ContractTranslations
      description: |-
        The companion `i18n.json` of a contract folder: `source` is the locale
        the manifest is written in (required); `locales` maps each target locale
        to a flat entries object (path → string or string array; see
        GET/PUT /data-apps/{ref}/translations/{locale}). Never merged into the
        manifest — translations are stored per app, not per release.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: DataHub API Key

````