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

# Example requests

> The most common queries and mutations you can run on the ION API

Run these queries and mutations in the [API Playground](/api/playground).

<Tabs>
  <Tab title="Queries">
    <AccordionGroup>
      <Accordion title="Search parts">
        Find parts by part number or description substring:

        ```graphql theme={null}
        query SearchParts($q: String!, $first: Int) {
          parts(filters: { partNumber: { ilike: $q } }, first: $first) {
            edges {
              node {
                id
                partNumber
                description
                revision
                partType
                status
                partSubtypes { id name }
              }
            }
          }
        }
        ```

        ```json theme={null}
        { "q": "%BRKT%", "first": 25 }
        ```
      </Accordion>

      <Accordion title="Get a procedure with all steps">
        Fetch a procedure template plus every step and its fields:

        ```graphql theme={null}
        query GetProcedure($id: Int!) {
          procedure(id: $id) {
            id
            title
            steps {
              id
              title
              fields { id }
            }
          }
        }
        ```

        ```json theme={null}
        { "id": 12 }
        ```
      </Accordion>

      <Accordion title="Get an aBOM with full hierarchy">
        Walk an as-built BOM tree from the parent down to all installations:

        ```graphql theme={null}
        query AbomTree($id: Int!) {
          partInventory(id: $id) {
            id
            serialNumber
            part { partNumber }
            buildRequirements {
              id
              part { partNumber }
              quantity
            }
          }
        }
        ```

        ```json theme={null}
        { "id": 9876 }
        ```
      </Accordion>

      <Accordion title="Compare two aBOM versions">
        Pull two as-built BOMs and diff them client-side:

        ```graphql theme={null}
        query CompareAboms($idA: Int!, $idB: Int!) {
          a: partInventory(id: $idA) {
            id
            serialNumber
            buildRequirements { id part { partNumber } quantity }
          }
          b: partInventory(id: $idB) {
            id
            serialNumber
            buildRequirements { id part { partNumber } quantity }
          }
        }
        ```

        ```json theme={null}
        { "idA": 9876, "idB": 9877 }
        ```
      </Accordion>

      <Accordion title="List open runs with current step">
        Get every run that's in progress, with the current step the operator is on:

        ```graphql theme={null}
        query OpenRuns {
          runs(filters: { status: { in: ["TODO", "IN_PROGRESS"] } }, first: 100) {
            edges {
              node {
                id
                title
                status
                procedure { id title }
                partInventory { id serialNumber part { partNumber } }
              }
            }
          }
        }
        ```
      </Accordion>

      <Accordion title="Run history for a part">
        Every run a specific part inventory has gone through, newest first:

        ```graphql theme={null}
        query RunHistory($partInventoryId: Int!) {
          runs(
            filters: { partInventoryId: { eq: $partInventoryId } }
            first: 50
          ) {
            edges {
              node {
                id
                title
                status
                _created
                procedure { id title }
              }
            }
          }
        }
        ```

        ```json theme={null}
        { "partInventoryId": 9876 }
        ```
      </Accordion>

      <Accordion title="Inventory for a part by location">
        List inventory units of a given part, grouped by physical location:

        ```graphql theme={null}
        query InventoryByLocation($partId: Int!) {
          partInventories(filters: { partId: { eq: $partId } }, first: 250) {
            edges {
              node {
                id
                serialNumber
                lotNumber
                quantity
                status
                location { id name type }
              }
            }
          }
        }
        ```

        ```json theme={null}
        { "partId": 12 }
        ```
      </Accordion>

      <Accordion title="Serialized units for a part">
        Get every serialized instance of a part with its current state:

        ```graphql theme={null}
        query SerializedUnits($partId: Int!) {
          partInventories(filters: { partId: { eq: $partId } }, first: 250) {
            edges {
              node {
                id
                serialNumber
                status
                location { id name }
              }
            }
          }
        }
        ```

        ```json theme={null}
        { "partId": 12 }
        ```
      </Accordion>

      <Accordion title="List open issues by disposition">
        All open issues grouped by disposition type for triage:

        ```graphql theme={null}
        query OpenIssuesByDisposition {
          issues(
            filters: { status: { in: ["PENDING", "IN_PROGRESS", "IN_REVIEW"] } }
            first: 250
          ) {
            edges {
              node {
                id
                title
                status
                issueDispositionType { id title }
                assignedTo { id name }
                _created
              }
            }
          }
        }
        ```
      </Accordion>

      <Accordion title="Get current user and org">
        Verify your token and find which org you're in:

        ```graphql theme={null}
        query Me {
          me {
            id
            name
            email
            organization { id domain }
          }
        }
        ```
      </Accordion>
    </AccordionGroup>
  </Tab>

  <Tab title="Mutations">
    <AccordionGroup>
      <Accordion title="Create a part">
        Create a new part in the library:

        ```graphql theme={null}
        mutation CreatePart($input: CreatePartInput!) {
          createPart(input: $input) {
            part { id partNumber description revision partType status }
          }
        }
        ```

        ```json theme={null}
        {
          "input": {
            "partNumber": "TEST-001",
            "description": "Integration test part",
            "revision": "A",
            "partType": "part",
            "trackingType": "lot"
          }
        }
        ```
      </Accordion>

      <Accordion title="Create a run from a procedure">
        Start a new run by binding a procedure to a part inventory:

        ```graphql theme={null}
        mutation CreateRun($input: CreateRunInput!) {
          createRun(input: $input) {
            run {
              id
              title
              status
              procedure { id title }
              partInventory { id serialNumber }
            }
          }
        }
        ```

        ```json theme={null}
        {
          "input": {
            "procedureId": 12,
            "partInventoryId": 9876,
            "title": "Build #2026-04-26 Unit 1"
          }
        }
        ```
      </Accordion>

      <Accordion title="Submit a run step result">
        Sign off a step with measurements. Requires the step's `_etag`:

        ```graphql theme={null}
        mutation SubmitStep($input: UpdateRunStepInput!) {
          updateRunStep(input: $input) {
            runStep {
              id
              status
              fields { id name value }
            }
          }
        }
        ```

        ```json theme={null}
        {
          "input": {
            "id": 4567,
            "_etag": "abc123",
            "status": "complete",
            "fieldValues": [
              { "runStepFieldId": 88, "value": "PASS" },
              { "runStepFieldId": 89, "value": "12.45" }
            ]
          }
        }
        ```
      </Accordion>

      <Accordion title="Start or complete a run">
        Move a run between lifecycle states:

        ```graphql theme={null}
        mutation UpdateRunStatus($input: UpdateRunInput!) {
          updateRun(input: $input) {
            run { id status startTime endTime }
          }
        }
        ```

        ```json theme={null}
        {
          "input": {
            "id": 1234,
            "_etag": "xyz789",
            "status": "complete"
          }
        }
        ```
      </Accordion>

      <Accordion title="Create a purchase order">
        Issue a new PO with line items:

        ```graphql theme={null}
        mutation CreatePO($input: CreatePurchaseOrderInput!) {
          createPurchaseOrder(input: $input) {
            purchaseOrder {
              id
              status
              supplier { id name }
              purchaseOrderLines { id part { partNumber } quantity }
            }
          }
        }
        ```

        ```json theme={null}
        {
          "input": {
            "vendorId": 42,
            "lineItems": [
              { "partId": 12, "quantity": 100 },
              { "partId": 13, "quantity": 50 }
            ]
          }
        }
        ```
      </Accordion>

      <Accordion title="Create an issue linked to a run">
        Open a quality issue tied to a specific run step:

        ```graphql theme={null}
        mutation CreateIssue($input: CreateIssueInput!) {
          createIssue(input: $input) {
            issue {
              id
              title
              status
              runStep { id }
            }
          }
        }
        ```

        ```json theme={null}
        {
          "input": {
            "title": "Surface scratches on RX-22 lot 4",
            "runStepId": 4567,
            "description": "Visible scratches across 4 of 12 units"
          }
        }
        ```
      </Accordion>

      <Accordion title="Close an issue with a resolution">
        Move an issue to resolved once reviews are signed off:

        ```graphql theme={null}
        mutation ResolveIssue($input: UpdateIssueInput!) {
          updateIssue(input: $input) {
            issue { id status }
          }
        }
        ```

        ```json theme={null}
        {
          "input": {
            "id": 7777,
            "_etag": "etag-value",
            "status": "resolved"
          }
        }
        ```
      </Accordion>
    </AccordionGroup>
  </Tab>
</Tabs>
