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

# Diff Commit

> Create a commit by streaming a Git patch instead of individual file blobs. Use this when your workflow already produces unified diffs or generated patches.
#### JWT claims
Required scopes: `git:write`  
Requires per repo scope: Yes

Deprecated: Use `/api/repos/{repo_name}/diff-commit` instead.



## OpenAPI

````yaml https://api.pierre.code.storage/api/openapi.json post /api/v1/repos/diff-commit
openapi: 3.1.0
info:
  description: >-
    The Code Storage HTTP API exposes repository management, Git reads, and
    write workflows over plain HTTPS.


    ## Authentication


    Send a signed JWT in the `Authorization: Bearer <token>` header on every
    request.


    - Organisation-scoped endpoints such as `GET /api/repos` require
    organisation scopes like `org:read`

    - Repository-scoped endpoints require a JWT whose `repo` claim names the
    target repository

    - Write operations require the relevant scope such as `git:write` or
    `repo:write`


    ## Pagination


    List endpoints use cursor-based pagination.


    - `cursor` is an opaque token returned by the previous response

    - `limit` defaults to `20` and is capped per endpoint

    - `has_more` tells you whether another request is available

    - `next_cursor` becomes the next `cursor` value


    ## Paths


    Preferred routes use the shorter `/api/...` form. Legacy `/api/v1/...`
    aliases remain documented where they are still supported and are marked as
    deprecated when a preferred route exists.


    ## Repository names in paths


    - Names containing `/` (or any other character that is not safe in a URL
    path segment) **must** be URL encoded so the value occupies a single path
    segment. For example, `pierre/example` becomes `pierre%2Fexample` and the
    request URL is `/api/repos/pierre%2Fexample/...`.

    - Plain names that contain only URL-safe characters can be sent as-is:
    `/api/repos/dotfiles/...`.

    - The server URL-decodes the value before resolving the repository, so
    double-encoding is not required.


    ## Errors


    Most endpoints return RFC 9457-compatible problem details under
    `application/problem+json`, with a legacy `error` field mirrored from
    `detail`.


    Streaming commit and note workflows may return operation-specific failure
    bodies so callers can inspect partial results, branch state, or workflow
    status without parsing generic error strings.
  title: code.storage
  version: 1.0.0
servers:
  - description: Code Storage tenant cluster
    url: https://api.{cluster}.code.storage
    variables:
      cluster:
        default: cluster
        description: >-
          Tenant cluster identifier (e.g. pierre-dev, pierre-staging,
          pierre-prod).
security: []
tags:
  - description: >-
      Create, inspect, update, delete, and synchronise repositories, including
      upstream pull-sync and generic HTTPS Git credentials for non-GitHub
      upstreams.
    name: Repositories
  - description: Create, delete, list, and compare branches.
    name: Branches
  - description: >-
      Read commit metadata and diffs, or create commits without a local Git
      client.
    name: Commits
  - description: >-
      Read repository trees, file contents, archives, and server-side search
      results.
    name: Files
  - description: List, create, and delete Git tags.
    name: Tags
  - description: Attach and retrieve Git notes for commits or other Git objects.
    name: Notes
paths:
  /api/v1/repos/diff-commit:
    post:
      tags:
        - Commits
      summary: Diff Commit
      description: >-
        Create a commit by streaming a Git patch instead of individual file
        blobs. Use this when your workflow already produces unified diffs or
        generated patches.

        #### JWT claims

        Required scopes: `git:write`  

        Requires per repo scope: Yes


        Deprecated: Use `/api/repos/{repo_name}/diff-commit` instead.
      operationId: diff_commit_legacy
      requestBody:
        content:
          application/x-ndjson:
            example: >
              {"metadata":{"target_branch":"main","expected_head_sha":"d34db33fd34db33fd34db33fd34db33fd34db33f","commit_message":"Apply
              generated patch","author":{"name":"Diff
              Bot","email":"diff@example.com"}}}

              {"diff_chunk":{"data":"ZGlmZiAtLWdpdCBhL1JFQURNRS5tZCBiL1JFQURNRS5tZAo=","eof":false}}

              {"diff_chunk":{"data":"QEAgLTEsMSArMSwyIEBACi1IZWxsbworSGVsbG8gV29ybGQK","eof":true}}
            schema:
              description: >-
                NDJSON stream. The first line must be `metadata`; subsequent
                lines must be `diff_chunk` payloads. Decoded diff chunks are
                limited to 4 MiB each.
              type: string
        description: >-
          Send newline-delimited JSON where the first line is a `metadata`
          object and each following line is a `diff_chunk`. The combined diff
          must be compatible with `git apply --cached --binary`.
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                additionalProperties: false
                description: >-
                  Result of applying an NDJSON commit pack, including the
                  resulting commit and branch update.
                properties:
                  commit:
                    additionalProperties: false
                    description: >-
                      Commit object information generated by the storage
                      service.
                    properties:
                      blob_count:
                        description: Number of blobs included in the pack.
                        format: int32
                        minimum: 0
                        type: integer
                      commit_sha:
                        description: SHA of the new commit.
                        type: string
                      pack_bytes:
                        description: Size of the generated pack in bytes.
                        format: int64
                        minimum: 0
                        type: integer
                      target_branch:
                        description: Branch the commit was written to.
                        type: string
                      tree_sha:
                        description: Tree SHA of the new commit.
                        type: string
                    required:
                      - commit_sha
                      - tree_sha
                      - target_branch
                      - pack_bytes
                      - blob_count
                    type: object
                  result:
                    additionalProperties: false
                    description: Final branch update outcome.
                    properties:
                      branch:
                        description: Branch that was updated.
                        type: string
                      message:
                        description: Optional human-readable message.
                        type: string
                      new_sha:
                        description: New tip SHA after the update.
                        type: string
                      old_sha:
                        description: >-
                          Previous tip SHA (40-char hex; all zeros when the
                          branch did not previously exist).
                        type: string
                      status:
                        description: Status code (ok, conflict, precondition_failed, etc.).
                        type: string
                      success:
                        description: Whether the operation succeeded.
                        type: boolean
                    required:
                      - branch
                      - old_sha
                      - new_sha
                      - success
                      - status
                    type: object
                required:
                  - commit
                  - result
                type: object
          description: Commit created from the supplied diff.
        '400':
          content:
            application/json:
              example:
                result:
                  branch: main
                  message: diff payload could not be decoded
                  new_sha: ''
                  old_sha: ''
                  status: invalid_diff
                  success: false
              schema:
                additionalProperties: false
                description: >-
                  Result of applying an NDJSON commit pack, including the
                  resulting commit and branch update.
                properties:
                  commit:
                    additionalProperties: false
                    description: >-
                      Commit object information generated by the storage
                      service.
                    properties:
                      blob_count:
                        description: Number of blobs included in the pack.
                        format: int32
                        minimum: 0
                        type: integer
                      commit_sha:
                        description: SHA of the new commit.
                        type: string
                      pack_bytes:
                        description: Size of the generated pack in bytes.
                        format: int64
                        minimum: 0
                        type: integer
                      target_branch:
                        description: Branch the commit was written to.
                        type: string
                      tree_sha:
                        description: Tree SHA of the new commit.
                        type: string
                    required:
                      - commit_sha
                      - tree_sha
                      - target_branch
                      - pack_bytes
                      - blob_count
                    type: object
                  result:
                    additionalProperties: false
                    description: Final branch update outcome.
                    properties:
                      branch:
                        description: Branch that was updated.
                        type: string
                      message:
                        description: Optional human-readable message.
                        type: string
                      new_sha:
                        description: New tip SHA after the update.
                        type: string
                      old_sha:
                        description: >-
                          Previous tip SHA (40-char hex; all zeros when the
                          branch did not previously exist).
                        type: string
                      status:
                        description: Status code (ok, conflict, precondition_failed, etc.).
                        type: string
                      success:
                        description: Whether the operation succeeded.
                        type: boolean
                    required:
                      - branch
                      - old_sha
                      - new_sha
                      - success
                      - status
                    type: object
                required:
                  - commit
                  - result
                type: object
          description: The NDJSON stream or diff payload was invalid.
        '401':
          content:
            application/json:
              schema:
                additionalProperties: false
                description: >-
                  RFC 9457-compatible problem details payload describing the
                  error response.
                properties:
                  detail:
                    description: >-
                      A human-readable explanation specific to this occurrence
                      of the problem.
                    type: string
                  error:
                    description: >-
                      Legacy compatibility field mirroring `detail` for older
                      clients.
                    type: string
                  instance:
                    description: >-
                      A URI reference that identifies the specific occurrence of
                      the problem.
                    type: string
                  status:
                    description: >-
                      The HTTP status code generated by the origin server for
                      this occurrence of the problem.
                    format: int64
                    type: integer
                  title:
                    description: A short, human-readable summary of the problem type.
                    type: string
                  type:
                    description: >-
                      A URI reference that identifies the problem type.
                      `about:blank` indicates the generic HTTP status semantics
                      apply.
                    type: string
                required:
                  - type
                  - title
                  - status
                type: object
            application/problem+json:
              schema:
                additionalProperties: false
                description: >-
                  RFC 9457-compatible problem details payload describing the
                  error response.
                properties:
                  detail:
                    description: >-
                      A human-readable explanation specific to this occurrence
                      of the problem.
                    type: string
                  error:
                    description: >-
                      Legacy compatibility field mirroring `detail` for older
                      clients.
                    type: string
                  instance:
                    description: >-
                      A URI reference that identifies the specific occurrence of
                      the problem.
                    type: string
                  status:
                    description: >-
                      The HTTP status code generated by the origin server for
                      this occurrence of the problem.
                    format: int64
                    type: integer
                  title:
                    description: A short, human-readable summary of the problem type.
                    type: string
                  type:
                    description: >-
                      A URI reference that identifies the problem type.
                      `about:blank` indicates the generic HTTP status semantics
                      apply.
                    type: string
                required:
                  - type
                  - title
                  - status
                type: object
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                additionalProperties: false
                description: >-
                  RFC 9457-compatible problem details payload describing the
                  error response.
                properties:
                  detail:
                    description: >-
                      A human-readable explanation specific to this occurrence
                      of the problem.
                    type: string
                  error:
                    description: >-
                      Legacy compatibility field mirroring `detail` for older
                      clients.
                    type: string
                  instance:
                    description: >-
                      A URI reference that identifies the specific occurrence of
                      the problem.
                    type: string
                  status:
                    description: >-
                      The HTTP status code generated by the origin server for
                      this occurrence of the problem.
                    format: int64
                    type: integer
                  title:
                    description: A short, human-readable summary of the problem type.
                    type: string
                  type:
                    description: >-
                      A URI reference that identifies the problem type.
                      `about:blank` indicates the generic HTTP status semantics
                      apply.
                    type: string
                required:
                  - type
                  - title
                  - status
                type: object
            application/problem+json:
              schema:
                additionalProperties: false
                description: >-
                  RFC 9457-compatible problem details payload describing the
                  error response.
                properties:
                  detail:
                    description: >-
                      A human-readable explanation specific to this occurrence
                      of the problem.
                    type: string
                  error:
                    description: >-
                      Legacy compatibility field mirroring `detail` for older
                      clients.
                    type: string
                  instance:
                    description: >-
                      A URI reference that identifies the specific occurrence of
                      the problem.
                    type: string
                  status:
                    description: >-
                      The HTTP status code generated by the origin server for
                      this occurrence of the problem.
                    format: int64
                    type: integer
                  title:
                    description: A short, human-readable summary of the problem type.
                    type: string
                  type:
                    description: >-
                      A URI reference that identifies the problem type.
                      `about:blank` indicates the generic HTTP status semantics
                      apply.
                    type: string
                required:
                  - type
                  - title
                  - status
                type: object
          description: Forbidden
        '404':
          content:
            application/json:
              schema:
                additionalProperties: false
                description: >-
                  RFC 9457-compatible problem details payload describing the
                  error response.
                properties:
                  detail:
                    description: >-
                      A human-readable explanation specific to this occurrence
                      of the problem.
                    type: string
                  error:
                    description: >-
                      Legacy compatibility field mirroring `detail` for older
                      clients.
                    type: string
                  instance:
                    description: >-
                      A URI reference that identifies the specific occurrence of
                      the problem.
                    type: string
                  status:
                    description: >-
                      The HTTP status code generated by the origin server for
                      this occurrence of the problem.
                    format: int64
                    type: integer
                  title:
                    description: A short, human-readable summary of the problem type.
                    type: string
                  type:
                    description: >-
                      A URI reference that identifies the problem type.
                      `about:blank` indicates the generic HTTP status semantics
                      apply.
                    type: string
                required:
                  - type
                  - title
                  - status
                type: object
            application/problem+json:
              schema:
                additionalProperties: false
                description: >-
                  RFC 9457-compatible problem details payload describing the
                  error response.
                properties:
                  detail:
                    description: >-
                      A human-readable explanation specific to this occurrence
                      of the problem.
                    type: string
                  error:
                    description: >-
                      Legacy compatibility field mirroring `detail` for older
                      clients.
                    type: string
                  instance:
                    description: >-
                      A URI reference that identifies the specific occurrence of
                      the problem.
                    type: string
                  status:
                    description: >-
                      The HTTP status code generated by the origin server for
                      this occurrence of the problem.
                    format: int64
                    type: integer
                  title:
                    description: A short, human-readable summary of the problem type.
                    type: string
                  type:
                    description: >-
                      A URI reference that identifies the problem type.
                      `about:blank` indicates the generic HTTP status semantics
                      apply.
                    type: string
                required:
                  - type
                  - title
                  - status
                type: object
          description: Not Found
        '409':
          content:
            application/json:
              example:
                result:
                  branch: main
                  message: patch does not apply cleanly
                  new_sha: ''
                  old_sha: ''
                  status: conflict
                  success: false
              schema:
                additionalProperties: false
                description: >-
                  Result of applying an NDJSON commit pack, including the
                  resulting commit and branch update.
                properties:
                  commit:
                    additionalProperties: false
                    description: >-
                      Commit object information generated by the storage
                      service.
                    properties:
                      blob_count:
                        description: Number of blobs included in the pack.
                        format: int32
                        minimum: 0
                        type: integer
                      commit_sha:
                        description: SHA of the new commit.
                        type: string
                      pack_bytes:
                        description: Size of the generated pack in bytes.
                        format: int64
                        minimum: 0
                        type: integer
                      target_branch:
                        description: Branch the commit was written to.
                        type: string
                      tree_sha:
                        description: Tree SHA of the new commit.
                        type: string
                    required:
                      - commit_sha
                      - tree_sha
                      - target_branch
                      - pack_bytes
                      - blob_count
                    type: object
                  result:
                    additionalProperties: false
                    description: Final branch update outcome.
                    properties:
                      branch:
                        description: Branch that was updated.
                        type: string
                      message:
                        description: Optional human-readable message.
                        type: string
                      new_sha:
                        description: New tip SHA after the update.
                        type: string
                      old_sha:
                        description: >-
                          Previous tip SHA (40-char hex; all zeros when the
                          branch did not previously exist).
                        type: string
                      status:
                        description: Status code (ok, conflict, precondition_failed, etc.).
                        type: string
                      success:
                        description: Whether the operation succeeded.
                        type: boolean
                    required:
                      - branch
                      - old_sha
                      - new_sha
                      - success
                      - status
                    type: object
                required:
                  - commit
                  - result
                type: object
          description: >-
            The diff could not be applied cleanly or the target branch tip
            changed.
        '429':
          content:
            application/json:
              schema:
                additionalProperties: false
                description: >-
                  RFC 9457-compatible problem details payload describing the
                  error response.
                properties:
                  detail:
                    description: >-
                      A human-readable explanation specific to this occurrence
                      of the problem.
                    type: string
                  error:
                    description: >-
                      Legacy compatibility field mirroring `detail` for older
                      clients.
                    type: string
                  instance:
                    description: >-
                      A URI reference that identifies the specific occurrence of
                      the problem.
                    type: string
                  status:
                    description: >-
                      The HTTP status code generated by the origin server for
                      this occurrence of the problem.
                    format: int64
                    type: integer
                  title:
                    description: A short, human-readable summary of the problem type.
                    type: string
                  type:
                    description: >-
                      A URI reference that identifies the problem type.
                      `about:blank` indicates the generic HTTP status semantics
                      apply.
                    type: string
                required:
                  - type
                  - title
                  - status
                type: object
            application/problem+json:
              schema:
                additionalProperties: false
                description: >-
                  RFC 9457-compatible problem details payload describing the
                  error response.
                properties:
                  detail:
                    description: >-
                      A human-readable explanation specific to this occurrence
                      of the problem.
                    type: string
                  error:
                    description: >-
                      Legacy compatibility field mirroring `detail` for older
                      clients.
                    type: string
                  instance:
                    description: >-
                      A URI reference that identifies the specific occurrence of
                      the problem.
                    type: string
                  status:
                    description: >-
                      The HTTP status code generated by the origin server for
                      this occurrence of the problem.
                    format: int64
                    type: integer
                  title:
                    description: A short, human-readable summary of the problem type.
                    type: string
                  type:
                    description: >-
                      A URI reference that identifies the problem type.
                      `about:blank` indicates the generic HTTP status semantics
                      apply.
                    type: string
                required:
                  - type
                  - title
                  - status
                type: object
          description: Too Many Requests
        '500':
          content:
            application/json:
              schema:
                additionalProperties: false
                description: >-
                  RFC 9457-compatible problem details payload describing the
                  error response.
                properties:
                  detail:
                    description: >-
                      A human-readable explanation specific to this occurrence
                      of the problem.
                    type: string
                  error:
                    description: >-
                      Legacy compatibility field mirroring `detail` for older
                      clients.
                    type: string
                  instance:
                    description: >-
                      A URI reference that identifies the specific occurrence of
                      the problem.
                    type: string
                  status:
                    description: >-
                      The HTTP status code generated by the origin server for
                      this occurrence of the problem.
                    format: int64
                    type: integer
                  title:
                    description: A short, human-readable summary of the problem type.
                    type: string
                  type:
                    description: >-
                      A URI reference that identifies the problem type.
                      `about:blank` indicates the generic HTTP status semantics
                      apply.
                    type: string
                required:
                  - type
                  - title
                  - status
                type: object
            application/problem+json:
              schema:
                additionalProperties: false
                description: >-
                  RFC 9457-compatible problem details payload describing the
                  error response.
                properties:
                  detail:
                    description: >-
                      A human-readable explanation specific to this occurrence
                      of the problem.
                    type: string
                  error:
                    description: >-
                      Legacy compatibility field mirroring `detail` for older
                      clients.
                    type: string
                  instance:
                    description: >-
                      A URI reference that identifies the specific occurrence of
                      the problem.
                    type: string
                  status:
                    description: >-
                      The HTTP status code generated by the origin server for
                      this occurrence of the problem.
                    format: int64
                    type: integer
                  title:
                    description: A short, human-readable summary of the problem type.
                    type: string
                  type:
                    description: >-
                      A URI reference that identifies the problem type.
                      `about:blank` indicates the generic HTTP status semantics
                      apply.
                    type: string
                required:
                  - type
                  - title
                  - status
                type: object
          description: Internal Server Error
        '503':
          content:
            application/json:
              schema:
                additionalProperties: false
                description: >-
                  RFC 9457-compatible problem details payload describing the
                  error response.
                properties:
                  detail:
                    description: >-
                      A human-readable explanation specific to this occurrence
                      of the problem.
                    type: string
                  error:
                    description: >-
                      Legacy compatibility field mirroring `detail` for older
                      clients.
                    type: string
                  instance:
                    description: >-
                      A URI reference that identifies the specific occurrence of
                      the problem.
                    type: string
                  status:
                    description: >-
                      The HTTP status code generated by the origin server for
                      this occurrence of the problem.
                    format: int64
                    type: integer
                  title:
                    description: A short, human-readable summary of the problem type.
                    type: string
                  type:
                    description: >-
                      A URI reference that identifies the problem type.
                      `about:blank` indicates the generic HTTP status semantics
                      apply.
                    type: string
                required:
                  - type
                  - title
                  - status
                type: object
            application/problem+json:
              schema:
                additionalProperties: false
                description: >-
                  RFC 9457-compatible problem details payload describing the
                  error response.
                properties:
                  detail:
                    description: >-
                      A human-readable explanation specific to this occurrence
                      of the problem.
                    type: string
                  error:
                    description: >-
                      Legacy compatibility field mirroring `detail` for older
                      clients.
                    type: string
                  instance:
                    description: >-
                      A URI reference that identifies the specific occurrence of
                      the problem.
                    type: string
                  status:
                    description: >-
                      The HTTP status code generated by the origin server for
                      this occurrence of the problem.
                    format: int64
                    type: integer
                  title:
                    description: A short, human-readable summary of the problem type.
                    type: string
                  type:
                    description: >-
                      A URI reference that identifies the problem type.
                      `about:blank` indicates the generic HTTP status semantics
                      apply.
                    type: string
                required:
                  - type
                  - title
                  - status
                type: object
          description: Service Unavailable
      deprecated: true
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      bearerFormat: JWT
      scheme: bearer
      type: http

````