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

# Preview the next part number

> Return the next part number for the rule configured on this product in the app.
    This call does not assign the number.

    ## Flow

    1. Call this endpoint. Send `{}` when the rule has no input segments. When it does,
       send `input_values` in segment order, for example `["MECH"]`.
    2. Assign the returned `part_number` on product or item update, item create, or
       `POST /v1/public/items/bulk`.

    When the product has a counter rule, any other value returns **422**
    (`PART_NUMBER_NOT_NEXT`). The body includes `expected_part_number`. Call this
    endpoint again and assign that value. A string that does not match the format
    returns **422** (`PART_NUMBER_FORMAT_MISMATCH`) with `expected_format`.

    `part_number` is null when the product has no counter rule, or when `input_values`
    are missing or invalid. You can then omit `part_number` or send any unique string.



## OpenAPI

````yaml /openapi.json post /v1/public/products/{product_id}/part-number-preview
openapi: 3.1.0
info:
  title: Poelis Public API
  description: |2-

            Poelis Public API - REST endpoints for external clients and integrations.
            
            ## Authentication
            
            All endpoints require an API key in the `Authorization` header:
            ```
            Authorization: Bearer poelis_api_...
            ```
            
            Get your API key from the web application's API Keys section.
            
            ## Rate Limiting
            
            API requests are rate-limited per organization. Contact support for higher limits.
            
            ## Support
            
            For questions or issues, contact support@poelis.com
            
  version: 1.0.0
servers:
  - url: https://api.poelis.com
    description: Production
  - url: http://localhost:8000
    description: Local
security: []
paths:
  /v1/public/products/{product_id}/part-number-preview:
    post:
      tags:
        - Products
      summary: Preview the next part number
      description: >-
        Return the next part number for the rule configured on this product in
        the app.
            This call does not assign the number.

            ## Flow

            1. Call this endpoint. Send `{}` when the rule has no input segments. When it does,
               send `input_values` in segment order, for example `["MECH"]`.
            2. Assign the returned `part_number` on product or item update, item create, or
               `POST /v1/public/items/bulk`.

            When the product has a counter rule, any other value returns **422**
            (`PART_NUMBER_NOT_NEXT`). The body includes `expected_part_number`. Call this
            endpoint again and assign that value. A string that does not match the format
            returns **422** (`PART_NUMBER_FORMAT_MISMATCH`) with `expected_format`.

            `part_number` is null when the product has no counter rule, or when `input_values`
            are missing or invalid. You can then omit `part_number` or send any unique string.
      operationId: >-
        preview_part_number_v1_public_products__product_id__part_number_preview_post
      parameters:
        - name: product_id
          in: path
          required: true
          schema:
            type: string
            title: Product Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PartNumberPreviewRequest'
      responses:
        '200':
          description: The next part number, or null when one cannot be generated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartNumberPreviewResponse'
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
            X-RateLimit-Limit:
              $ref: '#/components/headers/RateLimitLimit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/RateLimitRemaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/RateLimitReset'
        '401':
          description: Unauthorized - Invalid or missing API key
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
            X-RateLimit-Limit:
              $ref: '#/components/headers/RateLimitLimit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/RateLimitRemaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/RateLimitReset'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: unauthorized
                message: Invalid or missing API key
        '403':
          description: Forbidden - Access denied
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
            X-RateLimit-Limit:
              $ref: '#/components/headers/RateLimitLimit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/RateLimitRemaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/RateLimitReset'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: forbidden
                message: Access denied
        '404':
          description: Not found
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
            X-RateLimit-Limit:
              $ref: '#/components/headers/RateLimitLimit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/RateLimitRemaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/RateLimitReset'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: not_found
                message: Not found
        '422':
          description: Validation error - Invalid request body or parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: validation_error
                message: Invalid data format
                details:
                  errors:
                    - loc:
                        - body
                        - field_name
                      msg: field required
                      type: value_error.missing
        '429':
          description: Too many requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: rate_limit_exceeded
                message: Too many requests
      security:
        - API Key: []
components:
  schemas:
    PartNumberPreviewRequest:
      properties:
        input_values:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Input Values
          description: >-
            Values for the rule's input segments, in segment order. Omit when
            the rule has no input segments.
      type: object
      title: PartNumberPreviewRequest
      description: Input-segment values used to preview the next part number.
    PartNumberPreviewResponse:
      properties:
        part_number:
          anyOf:
            - type: string
            - type: 'null'
          title: Part Number
          description: >-
            Next part number for the product's rule and input_values. Null when
            the product has no counter rule, or input_values are missing or
            invalid.
      type: object
      title: PartNumberPreviewResponse
      description: Next part number for a product rule, without assigning it.
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: Machine-readable error code (e.g. validation_error, item_not_found).
        message:
          type: string
          description: Human-readable error message.
        details:
          type: object
          description: >-
            Additional error context (optional). For validation errors, contains
            a list of field-level issues.
          nullable: true
      required:
        - error
        - message
  headers:
    RequestId:
      description: >-
        Request correlation ID. Echoes the incoming `x-request-id` header or a
        server-generated ID.
      schema:
        type: string
    RateLimitLimit:
      description: Request limit for the current rate limit window.
      schema:
        type: integer
    RateLimitRemaining:
      description: Remaining requests in the current rate limit window.
      schema:
        type: integer
    RateLimitReset:
      description: Unix timestamp (seconds) when the current rate limit window resets.
      schema:
        type: integer
  securitySchemes:
    API Key:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: 'Enter your API key. Example: Bearer poelis_api_...'

````

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