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

# Take a brand from its files

> The brand's rules, pages, theme and name as the files say them, in one version of its history. With a source that remembers what both sides last agreed, what changed here since is kept: the files win only where both changed the same rule, page or setting, and `conflicts` names each. Files under `assets/` are named in `assets` by id or by the SHA-256 of their bytes; a 422 lists every problem at its file and line (`detail.errors`) and the files to upload first (`detail.missing`). `dryRun` answers what would change. `pending`: the brand still holds changes the files lack, to export back. Takes setup on the workspace.

Scope: `write`.



## OpenAPI

````yaml /openapi.json post /api/v1/brands/{slug}/files/import
openapi: 3.1.0
info:
  title: artbucket
  version: '1'
  description: >-
    Agent-first asset management. The web UI is built on this API and nothing
    else, beside signing in at /api/auth. Send `Authorization: Bearer <key>`: a
    key works in one workspace with one scope, and scopes are a ladder: read <
    propose < write < admin. People signed in to the app carry a session cookie
    instead, and their scope is what their grants add up to: on the
    organization, the workspace, or single collections and assets. A scope shown
    as needed on the workspace is also enough on the one collection or asset a
    route acts on. Agents (MCP at POST /api/v1/mcp) usually get `propose`: what
    they add waits for a human.
servers:
  - url: http://localhost:3000
security:
  - bearer: []
  - session: []
  - {}
paths:
  /api/v1/brands/{slug}/files/import:
    parameters:
      - name: slug
        in: path
        required: true
        description: Brand slug
        schema:
          type: string
    post:
      summary: Take a brand from its files
      description: >-
        The brand's rules, pages, theme and name as the files say them, in one
        version of its history. With a source that remembers what both sides
        last agreed, what changed here since is kept: the files win only where
        both changed the same rule, page or setting, and `conflicts` names each.
        Files under `assets/` are named in `assets` by id or by the SHA-256 of
        their bytes; a 422 lists every problem at its file and line
        (`detail.errors`) and the files to upload first (`detail.missing`).
        `dryRun` answers what would change. `pending`: the brand still holds
        changes the files lack, to export back. Takes setup on the workspace.


        Scope: `write`.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                files:
                  type: object
                  propertyNames:
                    type: string
                    minLength: 1
                    maxLength: 300
                  additionalProperties:
                    type: string
                    maxLength: 2000000
                  description: >-
                    The brand's files by path in its folder: brand.yaml,
                    rules/*.yaml, pages/*.yaml. Others are left alone
                assets:
                  description: >-
                    The files under assets/ the brand's files point at: path to
                    asset id, or to the SHA-256 of its bytes (upload first)
                  type: object
                  propertyNames:
                    type: string
                    minLength: 1
                    maxLength: 300
                  additionalProperties:
                    type: string
                    maxLength: 64
                commit:
                  description: >-
                    The commit the files are at, when they are the repository's:
                    recorded as agreed, when the brand has a source
                  type: string
                  minLength: 1
                  maxLength: 100
                message:
                  description: >-
                    The commit's message: its first line names the version the
                    import makes
                  type: string
                  maxLength: 2000
                dryRun:
                  description: Check and merge, answer what would change, write nothing
                  type: boolean
                merge:
                  description: >-
                    Keep what changed here since the source last agreed
                    (default); false takes the files whole
                  type: boolean
                publish:
                  description: 'Publish after, with this note (true: none). Takes share'
                  anyOf:
                    - type: boolean
                    - type: string
                      maxLength: 2000
              required:
                - files
              additionalProperties: false
      responses:
        '200':
          description: What changed
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      brand:
                        type: string
                      applied:
                        type: boolean
                        description: >-
                          Something changed: a new version in the brand's
                          history
                      version:
                        anyOf:
                          - type: integer
                            minimum: -9007199254740991
                            maximum: 9007199254740991
                          - type: 'null'
                      published:
                        anyOf:
                          - type: integer
                            minimum: -9007199254740991
                            maximum: 9007199254740991
                          - type: 'null'
                        description: >-
                          The version published, when publish was asked and
                          something was new
                      diff:
                        type: object
                        properties:
                          name:
                            anyOf:
                              - type: object
                                properties:
                                  before:
                                    type: string
                                  after:
                                    type: string
                                required:
                                  - before
                                  - after
                                additionalProperties: false
                              - type: 'null'
                          rules:
                            type: array
                            items:
                              type: object
                              properties:
                                change:
                                  type: string
                                  enum:
                                    - added
                                    - removed
                                    - changed
                                key:
                                  type: string
                                context:
                                  type:
                                    - string
                                    - 'null'
                                type:
                                  type: string
                                  enum:
                                    - color
                                    - text
                                    - number
                                    - list
                                    - font
                                before: {}
                                after: {}
                                fields:
                                  description: >-
                                    What changed: value, usage, label, spec,
                                    assets, type
                                  type: array
                                  items:
                                    type: string
                              required:
                                - change
                                - key
                                - context
                                - type
                              additionalProperties: false
                          pages:
                            type: array
                            items:
                              type: object
                              properties:
                                change:
                                  type: string
                                  enum:
                                    - added
                                    - removed
                                    - changed
                                    - moved
                                slug:
                                  type: string
                                title:
                                  type: string
                              required:
                                - change
                                - slug
                                - title
                              additionalProperties: false
                          theme:
                            type: array
                            items:
                              type: string
                            description: Theme settings changed
                          reordered:
                            type: boolean
                            description: The rules' order changed
                        required:
                          - name
                          - rules
                          - pages
                          - theme
                          - reordered
                        additionalProperties: false
                      conflicts:
                        type: array
                        items:
                          type: object
                          properties:
                            what:
                              type: string
                            ours: {}
                            theirs: {}
                          required:
                            - what
                            - ours
                            - theirs
                          additionalProperties: false
                        description: >-
                          Pieces both sides changed differently: the files' side
                          was taken, this side's is in the history
                      warnings:
                        type: array
                        items:
                          type: object
                          properties:
                            file:
                              type: string
                            line:
                              type: integer
                              minimum: -9007199254740991
                              maximum: 9007199254740991
                            message:
                              type: string
                          required:
                            - file
                            - message
                          additionalProperties: false
                      pending:
                        type: boolean
                        description: >-
                          The brand holds changes the files lack: export them
                          back
                    required:
                      - brand
                      - applied
                      - version
                      - published
                      - diff
                      - conflicts
                      - warnings
                      - pending
                    additionalProperties: false
                required:
                  - data
                additionalProperties: false
        '422':
          description: Problems in the files
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      detail:
                        type: object
                        properties:
                          errors:
                            type: array
                            items:
                              type: object
                              properties:
                                file:
                                  type: string
                                line:
                                  type: integer
                                  minimum: -9007199254740991
                                  maximum: 9007199254740991
                                message:
                                  type: string
                              required:
                                - file
                                - message
                              additionalProperties: false
                          warnings:
                            type: array
                            items:
                              type: object
                              properties:
                                file:
                                  type: string
                                line:
                                  type: integer
                                  minimum: -9007199254740991
                                  maximum: 9007199254740991
                                message:
                                  type: string
                              required:
                                - file
                                - message
                              additionalProperties: false
                          missing:
                            type: array
                            items:
                              type: string
                            description: >-
                              Files under assets/ to upload, then name in assets
                              by SHA-256
                        required:
                          - errors
                          - warnings
                          - missing
                        additionalProperties: false
                    required:
                      - code
                      - message
                      - detail
                    additionalProperties: false
                required:
                  - error
                additionalProperties: false
        default:
          description: An error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      detail: {}
                    required:
                      - code
                      - message
                    additionalProperties: false
                required:
                  - error
                additionalProperties: false
components:
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      description: 'An API key: ab_...'
    session:
      type: apiKey
      in: cookie
      name: better-auth.session_token
      description: Signed in, at /api/auth

````