> ## 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.

# Upsert mappings

> Batch upsert mappings for the authenticated organization. Services calls create undated mappings and reject archived GL accounts as vendor defaults. Other callers retain the supplied effective_date; when omitted, vendor department edits preserve the existing mapping date. This operation does not reprocess historical transactions.



## OpenAPI

````yaml https://app.usequanta.com/openapi/quanta-services-api/openapi.json post /api/alpha/mappings/upsert
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: https://app.usequanta.com
    description: Production
security:
  - HTTPBearer: []
paths:
  /api/alpha/mappings/upsert:
    post:
      tags:
        - mappings
        - quanta-services-api
      summary: Upsert mappings
      description: >-
        Batch upsert mappings for the authenticated organization. Services calls
        create undated mappings and reject archived GL accounts as vendor
        defaults. Other callers retain the supplied effective_date; when
        omitted, vendor department edits preserve the existing mapping date.
        This operation does not reprocess historical transactions.
      operationId: upsert_mappings
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BulkUpsertMappingsRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BulkUpsertMappingsResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    BulkUpsertMappingsRequest:
      properties:
        reason:
          anyOf:
            - type: string
            - type: 'null'
          title: Reason
          description: Why these mappings are being changed.
        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/BulkMappingPairInput'
          type: array
          maxItems: 5000
          minItems: 1
          title: Mappings
          description: >-
            Mappings to upsert. Each row is either inserted, used to supersede
            the current value, or skipped if the current value already matches.
            Duplicate mapping_type and from_value pairs are rejected.
      type: object
      required:
        - mappings
      title: BulkUpsertMappingsRequest
    BulkUpsertMappingsResponse:
      properties:
        inserted:
          type: integer
          title: Inserted
        updated:
          type: integer
          title: Updated
        skipped:
          type: integer
          title: Skipped
        rows:
          items:
            $ref: '#/components/schemas/BulkMappingUpsertResultModel'
          type: array
          title: Rows
      type: object
      required:
        - inserted
        - updated
        - skipped
        - rows
      title: BulkUpsertMappingsResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    BulkMappingPairInput:
      properties:
        mapping_type:
          $ref: '#/components/schemas/MappingType'
          description: Mapping type to upsert for this row.
        from_value:
          type: string
          maxLength: 512
          minLength: 1
          title: From Value
          description: Stable identifier the caller is mapping from (e.g. an employee key).
        to_value:
          anyOf:
            - type: string
              maxLength: 512
              minLength: 1
            - type: 'null'
          title: To Value
          description: >-
            Target value the from_value should map to. Set to null to delete the
            current mapping.
      type: object
      required:
        - mapping_type
        - from_value
        - to_value
      title: BulkMappingPairInput
    BulkMappingUpsertResultModel:
      properties:
        mapping_type:
          $ref: '#/components/schemas/MappingType'
        from_value:
          type: string
          title: From Value
        to_value:
          anyOf:
            - type: string
            - type: 'null'
          title: To Value
        mapping_qid:
          anyOf:
            - type: string
            - type: 'null'
          title: Mapping Qid
          description: >-
            qid of the mapping row representing the current value after the
            call. None if the row was skipped or deleted.
        effective_date:
          anyOf:
            - type: string
              format: date
            - type: 'null'
          title: Effective Date
          description: >-
            effective_date applied to the inserted row. None if skipped or
            deleted.
        outcome:
          $ref: '#/components/schemas/MappingUpsertOutcome'
      type: object
      required:
        - mapping_type
        - from_value
        - to_value
        - outcome
      title: BulkMappingUpsertResultModel
    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
    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
    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.