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

# Update a sample

> Atomically update any combination of an owned sample's display name, unified field values, and isotropic microns-per-pixel value. Public share ids are not patchable. OAuth callers need both `samples:read` and `samples:write` because the response includes full owned detail and job history. When countable `mpp` is supplied, an idempotent recount is enqueued even if the stored value is unchanged; after an enqueue-failure 500, retry the identical patch to heal the recount.

Atomically updates any combination of an owned sample's display name, unified
field values, and isotropic microns-per-pixel value. The response is the full
owned sample detail, including inference-job history.

`fields` is keyed by stable definition key. Each supplied value replaces that
field's complete value; `null` clears it. This payload replaces Tags:

```json theme={"dark"}
{ "fields": { "tags": ["baseline", "trial-42"] } }
```

Tags values are trimmed and lowercased, duplicates collapse, each value must be
between 1 and 50 characters without commas or control characters, and a sample
may carry
at most 50 distinct Tags values. Public is readable through `fields.public` but
is not writable through this endpoint; publication uses its protected flow.

Use `GET /sample-fields` to discover keys, value types, origin, storage, and
writability. The retired top-level `tags` property is rejected with HTTP 400.


## OpenAPI

````yaml PATCH /samples/{id}
openapi: 3.1.0
info:
  title: Strand AI Platform API
  version: v1
  description: >-
    REST surface for uploading WSIs, submitting Lattice inference jobs, and
    streaming results. All endpoints require an API key or Strand AI OAuth
    access token in the `Authorization: Bearer` header.
servers:
  - url: https://app.strandai.com/api/v1
    description: Production
security:
  - ApiKey: []
  - OAuth2: []
paths:
  /samples/{id}:
    patch:
      summary: Update a sample
      description: >-
        Atomically update any combination of an owned sample's display name,
        unified field values, and isotropic microns-per-pixel value. Public
        share ids are not patchable. OAuth callers need both `samples:read` and
        `samples:write` because the response includes full owned detail and job
        history. When countable `mpp` is supplied, an idempotent recount is
        enqueued even if the stored value is unchanged; after an enqueue-failure
        500, retry the identical patch to heal the recount.
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SamplePatch'
      responses:
        '200':
          description: Updated owned sample detail
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OwnedSampleDetail'
        '400':
          description: Body is not JSON, empty, or contains unknown fields
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Missing or invalid credential
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: >-
            OAuth token lacks samples:read or samples:write, or the patch
            attempts to write a read-only field such as Public
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Owned sample not found in this org
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: A provided field is invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: >-
            The sample update committed but its MPP tissue recount could not be
            enqueued. Retry the identical patch to re-attempt the idempotent
            recount.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - ApiKey: []
        - OAuth2:
            - samples:read
            - samples:write
components:
  schemas:
    SamplePatch:
      type: object
      additionalProperties: false
      minProperties: 1
      properties:
        name:
          type: string
          nullable: true
          maxLength: 200
          pattern: ^[^\u0000]*$
          description: >-
            Trimmed display name. Null or an empty string reverts to filename.
            NUL characters are rejected.
        fields:
          allOf:
            - $ref: '#/components/schemas/SampleFields'
          minProperties: 1
          description: >-
            Complete values for the named fields, not deltas. Null clears a
            field. `fields.tags` is the complete desired tag set;
            `fields.public` is read-only and returns 403.
        mpp:
          oneOf:
            - type: number
              exclusiveMinimum: 0
              maximum: 100
            - type: object
              additionalProperties: false
              required:
                - x
                - 'y'
              properties:
                x:
                  type: number
                  exclusiveMinimum: 0
                  maximum: 100
                'y':
                  type: number
                  exclusiveMinimum: 0
                  maximum: 100
          description: >-
            User-reported microns per pixel. Object axes must be equal;
            anisotropic input is rejected.
    OwnedSampleDetail:
      type: object
      additionalProperties: false
      description: >-
        An owned sample's curated read model and its 50 newest inference jobs.
        `jobCount` is the uncapped total.
      required:
        - ownership
        - id
        - appUrl
        - name
        - filename
        - status
        - fileSize
        - widthPx
        - heightPx
        - mpp
        - fields
        - createdAt
        - expiresAt
        - expiresAtSource
        - expiresInDays
        - willExpire
        - trashedAt
        - jobs
        - jobCount
        - segmentation
      properties:
        ownership:
          type: string
          enum:
            - mine
        id:
          type: string
          format: uuid
        appUrl:
          type: string
          format: uri
          description: Canonical browser URL for this owned sample.
        name:
          type: string
          nullable: true
          description: >-
            Human-friendly display name, or null if unset (falls back to
            filename).
        filename:
          type: string
          description: Original uploaded filename.
        status:
          type: string
          description: >-
            Lifecycle status: `uploading`, `upload_failed`, `deid_running`,
            `deid_failed`, `preprocessing`, `ready`, or `preprocess_failed`.
        fileSize:
          type: string
          description: Uploaded file size in bytes (string-encoded 64-bit integer).
        widthPx:
          type: integer
          nullable: true
          description: >-
            Level-0 width in pixels, or null before the dimensions probe
            completes.
        heightPx:
          type: integer
          nullable: true
          description: >-
            Level-0 height in pixels, or null before the dimensions probe
            completes.
        mpp:
          type: number
          nullable: true
          description: >-
            Effective isotropic microns per pixel (user override → calibrated
            slide value), or null when the sample has no usable scale yet.
        fields:
          $ref: '#/components/schemas/SampleFields'
        createdAt:
          type: string
          format: date-time
          nullable: true
        expiresAt:
          type: string
          format: date-time
          nullable: true
          description: When the sample moves to Trash. Null when it never expires.
        expiresAtSource:
          type: string
          nullable: true
          enum:
            - org_default
            - custom
            - null
          description: >-
            `org_default` = derived from the org policy at upload time. `custom`
            = set by an explicit expiration call (a date or a never-expire pin).
            Null when the sample has no expiration and no org policy applies.
        expiresInDays:
          type: integer
          nullable: true
          description: >-
            Whole days until expiry, clamped at 0 for a sample at/past its date
            but not yet swept. Null when the sample never expires.
        willExpire:
          type: boolean
          description: True when the sample has an expiration date set.
        trashedAt:
          type: string
          format: date-time
          nullable: true
          description: >-
            When the sample entered Trash, or null if it is still active.
            Trashed samples are permanently deleted 7 days after this time.
        jobs:
          type: array
          maxItems: 50
          items:
            $ref: '#/components/schemas/SampleJob'
        jobCount:
          type: integer
          minimum: 0
          description: Total inference-job count for the sample before the 50-job cap.
        segmentation:
          $ref: '#/components/schemas/SegmentationState'
    Error:
      type: object
      required:
        - error
        - message
      properties:
        error:
          type: string
        message:
          type: string
        reason:
          type: string
          nullable: true
        required:
          type: integer
          nullable: true
        retryAfterSeconds:
          type: integer
          nullable: true
    SampleFields:
      type: object
      additionalProperties: true
      description: >-
        Unified field values keyed by stable definition key. Tags is a string
        array at `tags`; Public is a boolean at `public`. Values are validated
        against the organization's definitions.
    SampleJob:
      type: object
      additionalProperties: false
      required:
        - id
        - appUrl
        - status
        - progress
        - reservedCredits
        - markers
        - createdAt
        - startedAt
        - completedAt
        - errorMessage
        - resultsAvailable
      properties:
        id:
          type: string
          format: uuid
        appUrl:
          type: string
          format: uri
          description: Canonical authenticated Platform URL for this job's sample.
        status:
          type: string
          description: >-
            Lifecycle: `queued` → `dispatching` → `preprocessing` → `running` →
            `postprocessing` → terminal. Terminal values: `completed`,
            `partial_failed`, `failed`, and `cancelled`.
        progress:
          type: number
          nullable: true
        reservedCredits:
          type: integer
          nullable: true
        markers:
          type: array
          items:
            type: string
        createdAt:
          type: string
          format: date-time
          nullable: true
        startedAt:
          type: string
          format: date-time
          nullable: true
        completedAt:
          type: string
          format: date-time
          nullable: true
        errorMessage:
          type: string
          nullable: true
        resultsAvailable:
          type: boolean
    SegmentationState:
      type: object
      additionalProperties: false
      required:
        - status
        - retryable
        - creditCost
        - job
        - layer
      properties:
        status:
          type: string
          enum:
            - not_started
            - queued
            - running
            - postprocessing
            - completed
            - failed
            - cancelled
        retryable:
          type: boolean
        creditCost:
          type: integer
          enum:
            - 0
          description: Segmentation is credit-free.
        job:
          type: object
          nullable: true
          additionalProperties: true
        layer:
          type: object
          nullable: true
          additionalProperties: true
  securitySchemes:
    ApiKey:
      type: http
      scheme: bearer
      bearerFormat: sk-strand-XXXXXXXXXXXXXXXXXXXXXXXX
    OAuth2:
      type: oauth2
      description: >-
        Strand AI authorization-code flow with S256 PKCE, explicit organization
        consent, and RFC 8707 resource binding.
      flows:
        authorizationCode:
          authorizationUrl: https://auth.strandai.com/oauth2/auth
          tokenUrl: https://auth.strandai.com/oauth2/token
          scopes:
            samples:read: Read slide metadata and estimates
            samples:write: Upload and change slides
            jobs:read: Read run status
            jobs:write: Start, export, or cancel runs
            results:read: Read and download results
            credits:spend: Reserve and spend organization credits

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.