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

# Bulk-upsert mappings

> Idempotent batch upsert of mappings for the authenticated org. For each input row, looks up the current active to_value for (claims.org_qid, mapping_type, from_value): the row is reported as 'skipped' (no DB writes) if the current value matches, 'inserted' if no prior mapping existed, or 'updated' if a prior mapping existed with a different to_value. The whole batch runs in a single transaction; any failure rolls back all writes.



## OpenAPI

````yaml https://app.usequanta.com/openapi/quanta-services-api/openapi.json post /api/mappings/bulk-upsert
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: https://app.usequanta.com
    description: Production
security:
  - HTTPBearer: []
paths:
  /api/mappings/bulk-upsert:
    post:
      tags:
        - quanta-services-api
      summary: Bulk-upsert mappings
      description: >-
        Idempotent batch upsert of mappings for the authenticated org. For each
        input row, looks up the current active to_value for (claims.org_qid,
        mapping_type, from_value): the row is reported as 'skipped' (no DB
        writes) if the current value matches, 'inserted' if no prior mapping
        existed, or 'updated' if a prior mapping existed with a different
        to_value. The whole batch runs in a single transaction; any failure
        rolls back all writes.
      operationId: bulk_upsert_mappings_route
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LegacyBulkUpsertMappingsRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LegacyBulkUpsertMappingsResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    LegacyBulkUpsertMappingsRequest:
      properties:
        mapping_type:
          $ref: '#/components/schemas/MappingType'
          description: Mapping type to upsert.
        effective_date:
          anyOf:
            - type: string
              format: date
            - type: 'null'
          title: Effective Date
          description: Date to stamp on newly inserted mapping rows. Optional.
        mappings:
          items:
            $ref: '#/components/schemas/LegacyBulkMappingPairInput'
          type: array
          maxItems: 5000
          minItems: 1
          title: Mappings
          description: Mappings to upsert. Duplicate from_values are rejected.
      type: object
      required:
        - mapping_type
        - mappings
      title: LegacyBulkUpsertMappingsRequest
    LegacyBulkUpsertMappingsResponse:
      properties:
        mapping_type:
          $ref: '#/components/schemas/MappingType'
        inserted:
          type: integer
          title: Inserted
        updated:
          type: integer
          title: Updated
        skipped:
          type: integer
          title: Skipped
        rows:
          items:
            $ref: '#/components/schemas/LegacyBulkMappingUpsertResultModel'
          type: array
          title: Rows
      type: object
      required:
        - mapping_type
        - inserted
        - updated
        - skipped
        - rows
      title: LegacyBulkUpsertMappingsResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    MappingType:
      type: string
      enum:
        - VENDOR_TO_GL_ACCOUNT
        - VENDOR_TO_DEPARTMENT
        - VENDOR_NAME_ALIAS_TO_VENDOR_QID
        - GL_ACCOUNT_TO_DEPARTMENT
        - SOURCE_QID_TO_FOREX_RATE
        - WARP_EMPLOYEE_TO_DEPARTMENT
        - GENERIC_PAYROLL_ACCOUNT_TO_GL_ACCOUNT_QID
        - GLOBAL_RIPPLING_COMPANY_NAME_TO_ORG
        - PRODUCT_QID_TO_REVENUE_GL_ACCOUNT_QID
        - PRODUCT_QID_TO_REFUND_GL_ACCOUNT_QID
        - PRODUCT_QID_TO_DISCOUNT_GL_ACCOUNT_QID
        - PRODUCT_QID_TO_LEDGER_REVENUE_POLICY
        - RIPPLING_R_AND_D_TAX_CREDIT
        - ORG_IGNORE_MERCURY_INVOICES
        - PARAFORM_PAYMENT_TYPE_TO_GL_ACCOUNT_QID
      title: MappingType
    LegacyBulkMappingPairInput:
      properties:
        from_value:
          type: string
          maxLength: 512
          minLength: 1
          title: From Value
          description: Stable identifier the caller is mapping from.
        to_value:
          type: string
          maxLength: 512
          minLength: 1
          title: To Value
          description: Target value the from_value should map to.
      type: object
      required:
        - from_value
        - to_value
      title: LegacyBulkMappingPairInput
    LegacyBulkMappingUpsertResultModel:
      properties:
        from_value:
          type: string
          title: From Value
        to_value:
          type: string
          title: To Value
        mapping_qid:
          anyOf:
            - type: string
            - type: 'null'
          title: Mapping Qid
        effective_date:
          anyOf:
            - type: string
              format: date
            - type: 'null'
          title: Effective Date
        outcome:
          $ref: '#/components/schemas/MappingUpsertOutcome'
      type: object
      required:
        - from_value
        - to_value
        - outcome
      title: LegacyBulkMappingUpsertResultModel
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    MappingUpsertOutcome:
      type: string
      enum:
        - inserted
        - updated
        - skipped
      title: MappingUpsertOutcome
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Quanta Services API scoped bearer token. Supported only on Services API
        routes.

````

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