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

# Copy a schema

> Clone a schema's current published version.

Clones the source's current published version into a new Active v1 you own. Used after a direct-share. Copies survive link revoke.


## OpenAPI

````yaml POST /api/v2/structs/{slug}/copy/
openapi: 3.1.0
info:
  title: Abacus Docs API
  version: 1.0.0
  description: |
    REST + SSE surface for Abacus Docs on the same host as the web app
    (`https://abacusdocs.com`). Paths are `/api/v2/…`.

    Authenticate with an organisation API key (`sk-abacus-*`) as a Bearer
    token, or an Auth0 access token. Cross-tenant reads return **404**, not
    403. Page-based lists use `?page=` and `?page_size=`.

    Extraction, reprocess, schema tests, and chat turns spend credits.
    See the help centre Credits pages for rates.
  contact:
    name: Abacus Docs
    url: https://abacusdocs.com/contact
servers:
  - url: https://abacusdocs.com
    description: Production (Extract)
security: []
paths:
  /api/v2/structs/{slug}/copy/:
    post:
      tags:
        - v2/structs
      summary: Deep-copy an extraction schema into the caller's scope
      description: >-
        Forks a Struct the caller currently has view access to (own / mod /
        superuser / approved org-library share / active direct-share acceptance)
        into a fresh row owned by ``request.user``.


        When the source has a published shape, its ``current_version`` is cloned
        into a brand-new ``StructVersion`` (v1) on the recipient's Struct, so
        the copy lands ACTIVE and is immediately usable in the IDP picker
        (Decision 40 in the AD-253 plan). When the source is DRAFT-only (never
        published), the working ``schema_json`` / ``annotations_json`` are
        cloned instead and the copy lands DRAFT with no version — matching a
        hand-created draft (AD-368 WS-4.4, so a draft-only schema is still
        duplicable from the /structs/ list).


        Returned body matches the standard ``StructDetailSerializer`` projection
        plus a top-level ``redirect_url`` pointing at the recipient's new
        schema-builder edit page — the SPA + the legacy HTML 'Copy to my
        schemas' / 'Duplicate' buttons all navigate straight there.


        Errors:

        - 403 — caller cannot view the source (caught by the visibility   helper
        before the copy proceeds).

        - 404 — source slug doesn't exist in the caller's org or is   archived.
      operationId: v2_structs_copy_create
      parameters:
        - in: path
          name: slug
          schema:
            type: string
          required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StructDetail'
          description: ''
        '403':
          content:
            application/json:
              schema:
                type: object
                additionalProperties: {}
          description: ''
        '404':
          content:
            application/json:
              schema:
                type: object
                additionalProperties: {}
          description: ''
      security:
        - extractApiKey: []
        - bearerAuth: []
        - cookieAuth: []
components:
  schemas:
    StructDetail:
      type: object
      description: |-
        Full Struct projection for the detail / restore response.

        Adds the working draft body (``schema_json``, ``annotations_json``), the
        nested current version summary, optional sample attachment, and a
        description for editing.
      properties:
        id:
          type: integer
          readOnly: true
        slug:
          type: string
          maxLength: 200
          pattern: ^[-a-zA-Z0-9_]+$
        name:
          type: string
          maxLength: 200
        status:
          $ref: '#/components/schemas/StatusEnum'
        mode:
          allOf:
            - $ref: '#/components/schemas/ModeF53Enum'
          description: >-
            Mirror of schema_json['mode'] for filtering/display; schema_json is
            authoritative.


            * `form` - Form

            * `document` - Document
        black_hole_enabled:
          type: boolean
          description: >-
            Org-scoped black-hole participation flag (Decision 2). Only the
            current PUBLISHED, non-deprecated version participates in
            classification — enforced by
            documents.services.black_hole.black_hole_participants(), not here.
            The flag may be set on a draft; it becomes effective on first
            publish.
        field_count:
          type: integer
          readOnly: true
        has_unpublished_changes:
          type: boolean
          readOnly: true
        current_version_number:
          type:
            - integer
            - 'null'
          readOnly: true
        version_count:
          type: integer
          readOnly: true
        updated_at:
          type: string
          format: date-time
          readOnly: true
        description:
          type: string
        schema_json: {}
        annotations_json: {}
        sample_attachment:
          type:
            - object
            - 'null'
          additionalProperties: {}
          readOnly: true
        current_version:
          oneOf:
            - $ref: '#/components/schemas/StructVersionSummary'
            - type: 'null'
          readOnly: true
        parsed_sections:
          type: array
          items:
            type: object
            additionalProperties: {}
          readOnly: true
        created_at:
          type: string
          format: date-time
          readOnly: true
        latest_proposals_json:
          oneOf:
            - {}
            - type: 'null'
      required:
        - annotations_json
        - created_at
        - current_version
        - current_version_number
        - description
        - field_count
        - has_unpublished_changes
        - id
        - name
        - parsed_sections
        - sample_attachment
        - schema_json
        - slug
        - updated_at
        - version_count
    StatusEnum:
      enum:
        - draft
        - active
        - archived
      type: string
      description: |-
        * `draft` - Draft
        * `active` - Active
        * `archived` - Archived
    ModeF53Enum:
      enum:
        - form
        - document
      type: string
      description: |-
        * `form` - Form
        * `document` - Document
    StructVersionSummary:
      type: object
      description: List shape for ``StructVersion`` rows (no schema body).
      properties:
        version_number:
          type: integer
          maximum: 2147483647
          minimum: 0
        published_at:
          type: string
          format: date-time
          readOnly: true
        published_by:
          oneOf:
            - $ref: '#/components/schemas/_PublishedBy'
            - type: 'null'
          readOnly: true
        publish_note:
          type: string
          maxLength: 500
        field_count:
          type: integer
          readOnly: true
        is_deprecated:
          type: boolean
          readOnly: true
        deprecated_at:
          type:
            - string
            - 'null'
          format: date-time
        deprecated_by:
          oneOf:
            - $ref: '#/components/schemas/_PublishedBy'
            - type: 'null'
          readOnly: true
        deprecation_note:
          type: string
          maxLength: 500
      required:
        - deprecated_by
        - field_count
        - is_deprecated
        - published_at
        - published_by
        - version_number
    _PublishedBy:
      type: object
      description: Compact projection of the user who published / deprecated a version.
      properties:
        id:
          type: integer
        email:
          type: string
          format: email
      required:
        - email
        - id
  securitySchemes:
    extractApiKey:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: |
        Organisation API key from Settings → API / `/api/keys/`. The secret is
        shown once. Send `Authorization: Bearer sk-abacus-…`. One active key
        per organisation. Ingest (`/api/v2/ingest/*`) refuses API keys — that
        surface is Auth0-only with `ingest:read` / `ingest:write` scopes.
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >
        Auth0 access token for a signed-in user. Send `Authorization: Bearer
        <token>`.

        The SPA and desktop agent use this. Prefer an organisation API key for

        server-to-server integrations.
    cookieAuth:
      type: apiKey
      in: cookie
      name: sessionid
      description: |
        Django session cookie from a browser login. Present so the web app can
        call `/api/v2` without a header. Do not rely on this for integrations.

````