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

# Solve a deterministic constraint-satisfaction / assignment problem

> `optimal`/`feasible`/`infeasible` all return HTTP 200 — infeasible
carries the conflicting-constraint subset in `data.conflicts`, never a
4xx/5xx. A spec the solver rejects against its closed vocabulary
returns 422; the solver sidecar being unreachable returns 503.

POST /v1/solve



## OpenAPI

````yaml /openapi/v1.json post /solve
openapi: 3.1.0
info:
  title: HASP AI API
  version: '2026-07-12'
  description: >-
    The HASP Public AI API is the regulated-AI substrate for healthcare and
    other

    regulated industries — identity, policy, audit, compliance, and PHI handling

    for AI inference, exposed via two surfaces:


    - **Native (`/v1/ai/*`)**: HASP-native chat with full event taxonomy, run
    lifecycle,
      and PHI metadata.
    - **Anthropic-compat (`/v1/messages`)**: Drop-in replacement for
    `@anthropic-ai/sdk` —
      change only `baseURL`. All Gateway compliance checks (BAA, credits, PHI policy) apply.

    All requests require an API key (`Authorization: Bearer
    hasp_api_live_<key>`). See

    [Authentication](https://docs.usehasp.com/ai-api/authentication) for key
    management.
servers:
  - url: https://api.usehasp.com/v1
    description: Production
security:
  - http: []
paths:
  /solve:
    post:
      tags:
        - Solve
      summary: Solve a deterministic constraint-satisfaction / assignment problem
      description: |-
        `optimal`/`feasible`/`infeasible` all return HTTP 200 — infeasible
        carries the conflicting-constraint subset in `data.conflicts`, never a
        4xx/5xx. A spec the solver rejects against its closed vocabulary
        returns 422; the solver sidecar being unreachable returns 503.

        POST /v1/solve
      operationId: v1.solve
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SolveRequest'
      responses:
        '200':
          description: >-
            A solve result — optimal/feasible satisfy every requirement;
            infeasible is equally a successful result, carrying the
            conflicting-constraint subset, never an error.
          content:
            application/json:
              schema:
                examples:
                  - data:
                      object: solve_result
                      status: optimal
                      assignments:
                        - slot_id: 2026-08-03-day-rn
                          resource_ids:
                            - Riley Nguyen
                      objective: 0
                      conflicts: []
                      stats:
                        wall_time_ms: 42
                        seed: 0
                      engine: cp-sat
                  - data:
                      object: solve_result
                      status: infeasible
                      assignments: []
                      objective: null
                      conflicts:
                        - id: coverage:2026-08-03-day-rn
                          description: >-
                            No resource satisfies the requirement for slot
                            2026-08-03-day-rn.
                      stats:
                        wall_time_ms: 18
                        seed: 0
                      engine: cp-sat
                anyOf:
                  - type: object
                    properties:
                      data:
                        type: array
                        items: {}
                    required:
                      - data
                  - type: string
        '401':
          description: Bearer token is missing, malformed, or revoked.
          content:
            application/json:
              schema:
                type: object
                example:
                  success: false
                  error:
                    type: authentication
                    code: INVALID_API_KEY
                    message: Bearer token is missing, malformed, or revoked.
                    param: null
                    details: null
                    retryable: false
                    request_id: 01JQREQ7XZQK5N6PZ1VVXHYB8T
                  meta:
                    request_id: 01JQREQ7XZQK5N6PZ1VVXHYB8T
        '403':
          description: >-
            The caller is authenticated but lacks the scope or capability this
            route requires.
          content:
            application/json:
              schema:
                type: object
                example:
                  success: false
                  error:
                    type: permission
                    code: MISSING_SCOPE
                    message: >-
                      The caller is authenticated but lacks the scope or
                      capability this route requires.
                    param: null
                    details: null
                    retryable: false
                    request_id: 01JQREQ7XZQK5N6PZ1VVXHYB8T
                  meta:
                    request_id: 01JQREQ7XZQK5N6PZ1VVXHYB8T
        '422':
          $ref: '#/components/responses/ValidationException'
        '429':
          description: >-
            Rate limit exceeded. Retry after the window indicated by
            `Retry-After`.
          content:
            application/json:
              schema:
                type: object
                example:
                  success: false
                  error:
                    type: rate_limited
                    code: RATE_LIMITED
                    message: >-
                      Rate limit exceeded (per-key, per-org, or daily cap,
                      depending on which limiter tripped).
                    param: null
                    details: null
                    retryable: true
                    request_id: 01JQREQ7XZQK5N6PZ1VVXHYB8T
                  meta:
                    request_id: 01JQREQ7XZQK5N6PZ1VVXHYB8T
          headers:
            Retry-After:
              description: Seconds until the rate-limit window resets.
              schema:
                type: integer
            X-RateLimit-Limit:
              description: The request cap for the current window.
              schema:
                type: integer
            X-RateLimit-Remaining:
              description: Requests remaining in the current window (0 on a 429).
              schema:
                type: integer
            X-RateLimit-Reset:
              description: Unix timestamp when the window resets.
              schema:
                type: integer
components:
  schemas:
    SolveRequest:
      type: object
      description: >-
        Validates POST /v1/solve (HASP-575, ADR-KBGV3J).


        The request body IS the declarative solve spec (version, resources,
        slots,

        constraints, preferences, options) — validation here is deliberately

        shallow, structure only. The solver service owns the closed-vocabulary

        validation and returns the full error list on rejection; this
        FormRequest

        must not reimplement any of it.


        `resources_from`/`slots_from` are rejected: unlike the `solve` workflow

        step and the `solve.run` agent tool, this endpoint is deliberately

        literal-only. An integrator calling `/v1/solve` already holds its own

        data and is sending it anyway, so requiring them to additionally name a

        HASP project would be the odd requirement here.


        `resources`/`slots` are required non-empty arrays — the same shallow

        presence check {@see
        \App\Services\Workflow\Steps\SolveStep::fromConfig()}

        already applies to the workflow step's spec, not a new validation layer.

        Catching an obviously-empty spec here means a `422 VALIDATION_FAILED`

        instead of an unnecessary round trip to the solver sidecar for a request

        that could never be solvable.
      properties:
        resources:
          type: array
          items:
            type: string
          minItems: 1
        slots:
          type: array
          items:
            type: string
          minItems: 1
        resources_from:
          type: string
        slots_from:
          type: string
        options:
          type: object
          properties:
            time_limit_seconds:
              type:
                - number
                - 'null'
              minimum: 0
              maximum: 30
      required:
        - resources
        - slots
      title: SolveRequest
  responses:
    ValidationException:
      description: Validation error
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Errors overview.
              errors:
                type: object
                description: A detailed description of each field that failed validation.
                additionalProperties:
                  type: array
                  items:
                    type: string
            required:
              - message
              - errors
  securitySchemes:
    http:
      type: http
      scheme: bearer

````