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

# Run a pipeline

> Segment each image with the model, then run the templates: now, or once
the model has segmented their channels. Returns immediately, per image and
in order: the `job_ids` started, the templates the image doesn't fit, or
the `error` that kept it from starting (an image outside your organization,
the monthly analysis quota, a model whose weights were cleaned up).

Poll each job with `GET /pipeline/jobs/{job_id}` until `SUCCEEDED`, then
hand its `image_id` and `channel` to the `/export/*` endpoints. An image's
first run counts against your plan's monthly analysis quota. Running on
more than one image at once needs the Pro or Lab plan. A non-UUID
`model_id` is rejected with `422` before it reaches the database.



## OpenAPI

````yaml /api-reference/openapi.json post /api/v1/pipeline/run
openapi: 3.1.0
info:
  title: HalfPage API
  description: >
    The **HalfPage API** runs cell segmentation on your microscopy images

    programmatically. Upload an image, run a pipeline on it, and export the

    resulting cell masks, ROIs, and measurements.


    ## Base URL


    ```

    https://api.halfpagetechnologies.com/backend/api/v1

    ```


    Every path in this reference is relative to that base URL. A staging
    environment

    is available at
    `https://staging-api.halfpagetechnologies.com/backend/api/v1`.


    ## Authentication


    Authenticate every request with an API key in the `Authorization` header as
    a

    bearer token:


    ```

    Authorization: Bearer hp_live_xxxxxxxxxxxxxxxxxxxxxxxx

    ```


    Create and manage keys from the **API Keys** section of the HalfPage
    dashboard.

    Keys cannot be minted through the API. A key is scoped to the organization
    that

    owns it; every resource you create or read is confined to that organization.

    Requests without a valid key receive `401`; a valid key used against an
    endpoint

    outside the public product surface receives `403`.


    ## Core workflow


    Three steps (**upload, pipeline, export**) plus a model list to choose from.

    Segmentation runs asynchronously on GPU workers, so step 2 is poll-based:


    1. **Upload an image** (`POST /upload`) as `multipart/form-data` with a
    `file`
       part. One call: the image record is created for you and the response returns
       it already `ready`, with the `image.id` for the next step.
       *(Large file or flaky connection? POST the same endpoint as
       `application/json` with `{"name": ..., "size": ...}` instead. You get back
       presigned part URLs. PUT the chunks, call
       `POST /upload/{image_id}/complete`, then poll `GET /upload/{image_id}` until
       `upload_status` is `ready`.)*
    2. **Pick a model** (`GET /models`) and **run a pipeline** (`POST
    /pipeline/run`)
       with `image_ids` and a `model_id`. That returns, per image, the `job_ids` it
       started; poll `GET /pipeline/jobs/{job_id}` until `status` is `SUCCEEDED`.
       The response then carries the `cell_count` detected and the `channel` it ran on.
    3. **Export** the result as an overlay PNG
       (`GET /export/{image_id}/overlay.png`, plus `?channel=` for a result on one
       channel of a multiplex image), CSV measurements
       (`.../measurements.csv`), GeoJSON ROIs (`.../rois.geojson`), or an ImageJ ROI
       archive (`.../rois.zip`). The overlay PNG is a presentation RGB image, not a
       preservation of original TIFF bit depth or scientific metadata.

    ## Quotas


    Uploads and analyses are metered against your plan. Exceeding your image

    storage cap or monthly analysis cap returns `402` with a human-readable

    `detail` explaining the limit. Upgrade your plan to raise it.
  version: 1.1.0
servers:
  - url: https://api.halfpagetechnologies.com/backend
    description: Production
  - url: https://staging-api.halfpagetechnologies.com/backend
    description: Staging
security: []
tags:
  - name: upload
    description: >-
      Get microscopy images into HalfPage, and manage them once they are there.
      `POST /upload` is the only way in and covers both modes: send
      `multipart/form-data` with a `file` part to upload in one request (the
      image comes back `ready`), or send `application/json` with `{name, size}`
      to open a resumable upload and get presigned part URLs back. Resumable
      uploads finish with `complete` (no ETag bookkeeping needed) and are polled
      until `ready`.
  - name: pipeline
    description: >-
      Run segmentation on ready images, then any of your lab's analysis
      templates, and poll it to completion. `POST /pipeline/run` queues the runs
      on GPU workers and returns, per image, the `job_ids` it started; `GET
      /pipeline/jobs/{job_id}` reports progress and, once `SUCCEEDED`, the cell
      count of the result.
  - name: export
    description: >-
      Download an image's result, by its `image_id` and `channel`, as a
      presentation overlay PNG, a CSV of per-cell measurements, a GeoJSON of ROI
      polygons, or a ZIP of ImageJ-compatible ROIs. The CSV endpoint accepts a
      `columns` parameter to narrow the output to the measurements you care
      about.
  - name: models
    description: >-
      List the segmentation models available to your organization (the shared
      public base models such as `Generalist`, plus any custom models trained in
      the dashboard) to choose a `model_id` for a pipeline.
  - name: shares
    description: >-
      Share an image as a view-only public link. `POST /shares` returns a `url`
      that anyone can open in a browser, no account needed, to see the image
      with its latest cell outlines and counts. Links are revocable and count
      their views; downloading from a shared page asks the visitor to sign in.
paths:
  /api/v1/pipeline/run:
    post:
      tags:
        - pipeline
      summary: Run a pipeline
      description: >-
        Segment each image with the model, then run the templates: now, or once

        the model has segmented their channels. Returns immediately, per image
        and

        in order: the `job_ids` started, the templates the image doesn't fit, or

        the `error` that kept it from starting (an image outside your
        organization,

        the monthly analysis quota, a model whose weights were cleaned up).


        Poll each job with `GET /pipeline/jobs/{job_id}` until `SUCCEEDED`, then

        hand its `image_id` and `channel` to the `/export/*` endpoints. An
        image's

        first run counts against your plan's monthly analysis quota. Running on

        more than one image at once needs the Pro or Lab plan. A non-UUID

        `model_id` is rejected with `422` before it reaches the database.
      operationId: run_pipeline_api_v1_pipeline_run_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PipelineRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                items:
                  $ref: '#/components/schemas/PipelineResult'
                type: array
                title: Response Run Pipeline Api V1 Pipeline Run Post
        '400':
          description: Nothing to run, or a channel with templates or analyses.
        '401':
          description: >-
            Missing or invalid credentials. Supply a valid `Authorization:
            Bearer hp_live_...` API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                detail: Requires authentication
        '402':
          description: More than one image on a plan that runs one image at a time.
        '422':
          description: >-
            An id in the path or body is not a valid UUID (rejected before it
            reaches the database).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                detail: Input should be a valid UUID
      security:
        - HTTPBearer: []
components:
  schemas:
    PipelineRequest:
      properties:
        image_ids:
          items:
            type: string
          type: array
          maxItems: 1000
          minItems: 1
          title: Image Ids
          examples:
            - - 3fa85f64-5717-4562-b3fc-2c963f66afa6
        model_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Model Id
          description: >-
            The model that segments the images. Null keeps the outlines each
            image has, for templates.
          examples:
            - c0ffee00-1234-5678-9abc-def012345678
        template_ids:
          items:
            type: string
          type: array
          title: Template Ids
          description: >-
            The lab's analysis templates to run once the images are segmented.
            Empty: segment only.
        analyses:
          items:
            $ref: '#/components/schemas/ColocalizationSettings'
          type: array
          title: Analyses
          description: >-
            Colocalizations to run with settings not saved as a template, their
            channels by position, 0-based. Each image gets the answer as its
            own, under no template.
        channels:
          items:
            $ref: '#/components/schemas/ChannelRun'
          type: array
          title: Channels
          description: >-
            For a multiplex image, without templates or analyses: segment these
            channels, 0-based, each on its own and with its own `model_id`
            (default: the run's). The image gets one `pipeline` job, with a
            prediction job per channel under it.
      type: object
      required:
        - image_ids
      title: PipelineRequest
      description: >-
        Run a pipeline on ready images (see `GET /upload/{image_id}`): segment

        them with `model_id`, one of the ids `GET /models` returns, then run
        each

        template in `template_ids`. One image is a list of one.
    PipelineResult:
      properties:
        job_ids:
          items:
            type: string
          type: array
          title: Job Ids
        skipped:
          items:
            $ref: '#/components/schemas/SkippedTemplate'
          type: array
          title: Skipped
        image_id:
          type: string
          title: Image Id
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
      type: object
      required:
        - job_ids
        - skipped
        - image_id
      title: PipelineResult
      description: What a pipeline started on one image, or why it couldn't start there.
    ErrorResponse:
      properties:
        detail:
          type: string
          title: Detail
          examples:
            - Job with id 11111111-1111-1111-1111-111111111111 not found
      type: object
      required:
        - detail
      title: ErrorResponse
      description: |-
        The body returned for a handled error: a single human-readable
        ``detail`` string.
    ColocalizationSettings:
      properties:
        parent_channel:
          type: integer
          minimum: 0
          title: Parent Channel
        child_channel:
          type: integer
          minimum: 0
          title: Child Channel
        method:
          type: string
          const: overlap
          title: Method
          default: overlap
        min_overlap:
          type: number
          maximum: 1
          exclusiveMinimum: 0
          title: Min Overlap
        exclude_edge_parents:
          type: boolean
          title: Exclude Edge Parents
          default: true
      type: object
      required:
        - parent_channel
        - child_channel
        - min_overlap
      title: ColocalizationSettings
      description: >-
        A colocalization's settings (`colocalization`): each object on

        the child channel goes to the object on the parent channel it overlaps

        most, when at least `min_overlap` of the child is inside it. With

        `exclude_edge_parents`, parents touching the image edge are left out,
        and

        so are the children they would take.
    ChannelRun:
      properties:
        channel:
          type: integer
          minimum: 0
          title: Channel
        model_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Model Id
      type: object
      required:
        - channel
      title: ChannelRun
      description: |-
        One channel of a multiplex image to segment on its own, with its own
        model, or the run's `model_id` when it names none.
    SkippedTemplate:
      properties:
        template_id:
          type: string
          title: Template Id
        reason:
          type: string
          title: Reason
      type: object
      required:
        - template_id
        - reason
      title: SkippedTemplate
      description: A template a run left out on one image, and why.
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````

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