> ## 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.

# Blame

> Return per-line blame metadata for a file at a branch, tag, or commit. Supports `git blame -L`-style range filters and rename/copy detection for callers building IDE blame views or audit tooling.
#### JWT claims
Required scopes: `git:read`  
Requires per repo scope: Yes



## OpenAPI

````yaml openapi.json GET /api/repos/{repo_name}/blame
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`. Each problem body has a stable, snake_case `code`. Branch on
    `code`, not on `detail`. The Error codes section lists the values.


    A `429 Too Many Requests` response carries the current IETF `RateLimit`
    service-limit field and `Retry-After`. `RateLimit` reports immediately
    available quota (`r`) and its effective window in seconds (`t`);
    `Retry-After` is the minimum delay and takes precedence. The gateway's
    capacity is dynamic, so it does not advertise a fixed `RateLimit-Policy` on
    successful responses.


    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.


    ## Error codes


    Each problem body has a stable `code`. Each status has a generic code. A
    specific code replaces it when the caller must take a different action. New
    codes can be added. Treat an unknown code as the generic code for its
    status.


    Generic codes: `bad_request` (400), `unauthorized` (401), `forbidden` (403),
    `not_found` (404), `method_not_allowed` (405), `request_timeout` (408),
    `conflict` (409), `precondition_failed` (412), `payload_too_large` (413),
    `unprocessable_entity` (422), `rate_limited` (429), `request_canceled`
    (499), `internal_error` (500), `not_implemented` (501), `bad_gateway` (502),
    `service_unavailable` (503), `gateway_timeout` (504). Any other status uses
    its status text in snake_case.


    Specific codes:


    - `authentication_unavailable` (403): the server cannot verify credentials
    now; retry.

    - `insufficient_scope` (403): the token does not have a scope that the
    operation requires.

    - `repo_claim_missing` (400): the token has no `repo` claim.

    - `repo_name_mismatch` (400): the request `repo_name` does not match the
    token `repo` claim.

    - `route_not_found` (404): no API route matches the path.

    - `repository_not_found` (404): the repository does not exist or the token
    cannot access it.

    - `repository_deleted` (409): the repository is already deleted.

    - `repository_thawing` (409): the repository is being restored from cold
    storage; retry after `Retry-After`.

    - `sync_in_progress` (409): an upstream sync is in progress; retry.

    - `upstream_already_configured` (409): the repository already has an
    upstream.

    - `branch_not_found` (404): the branch does not exist.

    - `ref_not_found` (404): the ref or revision does not exist.

    - `merge_conflict` (409): the merge has file conflicts.

    - `credential_not_found` (404): the Git credential does not exist.

    - `credential_exists` (409): the repository already has a Git credential.

    - `github_app_not_configured` (412): the organization does not have exactly
    one GitHub App.

    - `github_repository_inaccessible` (412, or the 4xx status from the
    upstream): GitHub does not give access to the upstream repository.

    - `hosting_not_enabled` (403): hosting is not enabled for the organization.

    - `hosting_project_not_found` (404): the repository has no hosting project.

    - `deployment_not_found` (404): the deployment does not exist.

    - `deployment_project_name_in_use` (409): another repository uses the
    hosting project name.

    - `idempotency_key_reused` (422): the idempotency key belongs to a different
    request.
  title: code.storage
  version: 1.0.0
servers:
  - description: Code Storage API host for your organization
    url: https://api.{org}.code.storage
    variables:
      org:
        default: your-org
        description: >-
          The subdomain of your API host. It is usually your organization name.
          The organization settings page in the dashboard shows your exact API
          host.
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
  - description: >-
      Read metadata about the Code Storage deployment that serves your
      organisation, such as its cloud location and inbound IP addresses.
    name: Organization
paths:
  /api/repos/{repo_name}/blame:
    get:
      tags:
        - Files
      summary: Blame
      description: >-
        Return per-line blame metadata for a file at a branch, tag, or commit.
        Supports `git blame -L`-style range filters and rename/copy detection
        for callers building IDE blame views or audit tooling.

        #### JWT claims

        Required scopes: `git:read`  

        Requires per repo scope: Yes
      operationId: repos-blame-get
      parameters:
        - description: >-
            Repository name. Names that contain `/` 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` is sent
            as `pierre%2Fexample`. Plain names such as `example` can be sent
            as-is. The server URL-decodes the value before resolving the
            repository.
          example: my-demo-repository
          in: path
          name: repo_name
          required: true
          schema:
            type: string
        - description: Repository-relative file path to blame.
          example: src/main.go
          in: query
          name: path
          required: true
          schema:
            type: string
        - description: >-
            Optional branch, tag, or commit SHA to blame at. When omitted, the
            repository default branch is used.
          example: main
          in: query
          name: ref
          schema:
            type: string
        - description: Whether `ref` should be resolved from the ephemeral namespace.
          in: query
          name: ephemeral
          schema:
            type: boolean
        - description: >-
            Optional `git blame -L`-style range spec. May be repeated to blame
            multiple regions (max 16). Each value is one `-L` argument: e.g.
            `10,20`, `10,+5`, `/getUser/,/^}/`, `/getUser/,+30`, `10,`, `,20`,
            `10`, `:^func .*Foo`, `:funcname`.
          example:
            - 10,20
          in: query
          name: range
          schema:
            items:
              type: string
            type: array
        - description: Follow the file across renames and copies.
          in: query
          name: detect_moves
          schema:
            type: boolean
      responses:
        '200':
          content:
            application/json:
              example:
                commit_sha: b003fc78805954584e1ee364a4ad39d7c79e819a
                lines:
                  - author_email: jane@example.com
                    author_name: Jane Doe
                    author_time: '2024-01-15T14:32:18Z'
                    commit_sha: b003fc78805954584e1ee364a4ad39d7c79e819a
                    committer_email: jane@example.com
                    committer_name: Jane Doe
                    committer_time: '2024-01-15T14:32:18Z'
                    line_number: 42
                    original_line_number: 40
                    original_path: src/main.go
                    previous_commit_sha: a4d39d7c79e819ab003fc78805954584e1ee36
                    summary: 'fix: resolve scrolling issue in dashboard'
                path: src/main.go
                ref: main
              schema:
                $ref: '#/components/schemas/ReposBlameGetResponse'
          description: Per-line blame for the resolved file revision.
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
          description: Bad Request
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
          description: Forbidden
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
          description: Not Found
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
          description: Conflict
        '429':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
          description: Too Many Requests
          headers:
            RateLimit:
              description: >-
                Current IETF service-limit field. `r=0` means no request is
                immediately available; `t` is the effective window in seconds
                before capacity is expected to return.
              schema:
                type: string
            Retry-After:
              description: >-
                Minimum delay before retrying, expressed as seconds or an HTTP
                date. This value takes precedence over the `RateLimit` effective
                window.
              schema:
                type: string
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
          description: Internal Server Error
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
          description: Service Unavailable
      security:
        - bearerAuth:
            - git:read
components:
  schemas:
    ReposBlameGetResponse:
      additionalProperties: false
      description: >-
        Per-line blame information for the requested file at the resolved
        revision.
      properties:
        commit_sha:
          description: Commit SHA the blame was computed at.
          examples:
            - b003fc78805954584e1ee364a4ad39d7c79e819a
          type: string
        lines:
          description: Per-line blame results in file order.
          items:
            $ref: '#/components/schemas/BlameLine'
          type: array
        path:
          description: Repository-relative file path that was blamed.
          examples:
            - src/main.go
          type: string
        ref:
          description: Resolved ref used for the blame.
          examples:
            - main
          type: string
      required:
        - ref
        - path
        - commit_sha
        - lines
      type: object
    ProblemDetails:
      additionalProperties: false
      description: >-
        RFC 9457-compatible problem details payload describing the error
        response.
      properties:
        code:
          description: >-
            A stable, machine-readable error code in snake_case. Branch on
            `code`, not on `detail`. The API description lists the codes.
          type: string
        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
        - code
      type: object
    BlameLine:
      additionalProperties: false
      description: >-
        Single blame entry describing the commit and author responsible for a
        line.
      properties:
        author_email:
          description: Author email of the commit that last touched this line.
          examples:
            - jane@example.com
          type: string
        author_name:
          description: Author of the commit that last touched this line.
          examples:
            - Jane Doe
          type: string
        author_time:
          description: Author timestamp in RFC 3339 format.
          examples:
            - '2024-01-15T14:32:18Z'
          type: string
        commit_sha:
          description: Commit SHA that last touched this line.
          examples:
            - b003fc78805954584e1ee364a4ad39d7c79e819a
          type: string
        committer_email:
          description: Committer email of the commit that last touched this line.
          examples:
            - jane@example.com
          type: string
        committer_name:
          description: Committer of the commit that last touched this line.
          examples:
            - Jane Doe
          type: string
        committer_time:
          description: Committer timestamp in RFC 3339 format.
          examples:
            - '2024-01-15T14:32:18Z'
          type: string
        line_number:
          description: Line number in the current file.
          examples:
            - 42
          format: int32
          type: integer
        original_line_number:
          description: Line number in the original file before any renames or moves.
          examples:
            - 40
          format: int32
          type: integer
        original_path:
          description: Original repository-relative path the line was introduced at.
          examples:
            - src/main.go
          type: string
        previous_commit_sha:
          description: Commit SHA prior to the current commit when known.
          examples:
            - a4d39d7c79e819ab003fc78805954584e1ee36
          type: string
        summary:
          description: First line of the commit message.
          examples:
            - 'fix: resolve scrolling issue in dashboard'
          type: string
      required:
        - line_number
        - commit_sha
        - original_line_number
        - original_path
        - author_name
        - author_email
        - author_time
        - committer_name
        - committer_email
        - committer_time
        - summary
      type: object
  securitySchemes:
    bearerAuth:
      bearerFormat: JWT
      description: >-
        JWT bearer token signed with your organization's registered signing key.
        There is no OAuth authorization server; you mint tokens yourself and the
        token's `scopes` claim carries the granted permission scopes. Public
        scopes: `git:read` (read repository contents), `git:write` (write
        branches, commits, tags, and notes), `repo:write` (create and manage
        repositories), `org:read` (list an organization's repositories). Each
        operation's security requirement names the scopes it requires. See
        https://code.storage/docs/getting-started/authentication for how to mint
        tokens.
      scheme: bearer
      type: http

````