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

# Update an existing Trade



## OpenAPI

````yaml Commerce patch /trades/{customer}/{vehicle}
openapi: 3.1.0
info:
  title: Commerce
  version: '3.0'
  contact:
    email: samuel@driv.ly
    name: Samuel Lippert
    url: https://driv.ly/
  description: Drivly Commerce API
servers:
  - url: https://commerce.driv.ly/api
security: []
paths:
  /trades/{customer}/{vehicle}:
    parameters:
      - schema:
          type: string
        name: customer
        in: path
        required: true
        description: Trade is uniquely identified by Customer
      - schema:
          type: string
        name: vehicle
        in: path
        required: true
        description: Trade is uniquely identified by Vehicle
      - schema:
          type: integer
        name: depth
        in: query
        required: false
        description: The number of levels of related objects to include in the response
    patch:
      summary: Update an existing Trade
      operationId: patch-trade
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateTrade'
      responses:
        '200':
          description: Trade Updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/Trade'
                  success:
                    type: boolean
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorModel'
                examples:
                  - error:
                      code: 401
                      message: Unauthorized
                    success: false
        '404':
          description: Trade Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorModel'
                examples:
                  - error:
                      code: 404
                      message: Trade Not Found
                    success: false
        '429':
          description: Too Many Requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorModel'
                examples:
                  - error:
                      code: 429
                      message: Too Many Requests
                    success: false
components:
  schemas:
    UpdateTrade:
      $id: UpdateTrade
      title: Trade
      type: object
      description: Customer offers Vehicle for trade
      examples:
        - deal: dea_1a2b3c4d5e6f
          vehicle:
            id: veh_3k12j9qksdf0
            vin: 1C4HJXEN5MW592818
            year: 2021
            make: Jeep
            trim: Sport
            spec: Off-Road Package
            model: Wrangler
            engine: 3.6L V6
            seatCount: 5
            doorCount: 4
            bodyStyle: SUV
            drivetrain: 4WD
            transmission: Automatic
            interiorColor: Black
            exteriorColor: Red
          customer:
            id: cus_k3j5s9qj3w0d
            addresses:
              - 123 Main St, Anytown, USA
            phoneNumbers:
              - 555-123-4567
          odometer: 15000
          creditApp: cre_5j6k7l8m9n0o
          netAllowance: 25000
          grossAllowance: 26000
      properties:
        customer:
          oneOf:
            - type: string
            - $ref: '#/components/schemas/Customer'
          description: Trade is uniquely identified by Customer
        vehicle:
          oneOf:
            - type: string
            - $ref: '#/components/schemas/Vehicle'
          description: Trade is uniquely identified by Vehicle
        netAllowance:
          type: number
          multipleOf: 0.01
          description: Trade provides Net Allowance
        grossAllowance:
          type: number
          multipleOf: 0.01
          description: Trade provides Gross Allowance
        odometer:
          type: number
          minimum: 0
          description: Odometer is read for Trade
        creditApp:
          oneOf:
            - type: string
            - $ref: '#/components/schemas/CreditApp'
          description: Credit App has Trade
        deal:
          oneOf:
            - type: string
            - $ref: '#/components/schemas/Deal'
          description: Trade provides assets for Deal
    Trade:
      $id: Trade
      examples:
        - deal: dea_1a2b3c4d5e6f
          vehicle:
            id: veh_3k12j9qksdf0
            vin: 1C4HJXEN5MW592818
            year: 2021
            make: Jeep
            trim: Sport
            spec: Off-Road Package
            model: Wrangler
            engine: 3.6L V6
            seatCount: 5
            doorCount: 4
            bodyStyle: SUV
            drivetrain: 4WD
            transmission: Automatic
            interiorColor: Black
            exteriorColor: Red
          customer:
            id: cus_k3j5s9qj3w0d
            addresses:
              - 123 Main St, Anytown, USA
            phoneNumbers:
              - 555-123-4567
          odometer: 15000
          creditApp: cre_5j6k7l8m9n0o
          netAllowance: 25000
          grossAllowance: 26000
      required:
        - customer
        - vehicle
        - netAllowance
        - grossAllowance
        - odometer
      title: Trade
      description: Customer offers Vehicle for trade
      type: object
      properties:
        customer:
          oneOf:
            - type: string
            - $ref: '#/components/schemas/Customer'
          description: Trade is uniquely identified by Customer
        vehicle:
          oneOf:
            - type: string
            - $ref: '#/components/schemas/Vehicle'
          description: Trade is uniquely identified by Vehicle
        netAllowance:
          type: number
          multipleOf: 0.01
          description: Trade provides Net Allowance
        grossAllowance:
          type: number
          multipleOf: 0.01
          description: Trade provides Gross Allowance
        odometer:
          type: number
          minimum: 0
          description: Odometer is read for Trade
        creditApp:
          oneOf:
            - type: string
            - $ref: '#/components/schemas/CreditApp'
          description: Credit App has Trade
        deal:
          oneOf:
            - type: string
            - $ref: '#/components/schemas/Deal'
          description: Trade provides assets for Deal
    ErrorModel:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: number
            message:
              type: string
        success:
          type: boolean
    Customer:
      $id: Customer
      required:
        - id
      title: Customer
      type: object
      properties:
        id:
          type: string
          description: Customer is uniquely identified by id
        addresses:
          type: array
          items:
            oneOf:
              - type: string
              - $ref: '#/components/schemas/Address'
          description: Customer is located at Addresses
        phoneNumbers:
          type: array
          items:
            type: string
            pattern: ^\+?1?[- ]?\(?([0-9]{3})\)?[- ]?([0-9]{3})-?([0-9]{4})$
          description: Customer has Phone Number
    Vehicle:
      $id: Vehicle
      examples:
        - vin: 1C4HJXEN5MW592818
          year: 2021
          make: Jeep
          trim: Sport
          spec: vs_4jf8x9jv5c0b
          model: Wrangler
          engine: 3.6L V6
          seatCount: 5
          doorCount: 4
          bodyStyle: SUV
          drivetrain: 4WD
          transmission: Automatic
          interiorColor: Black
          exteriorColor: Red
      required:
        - vin
        - year
        - make
        - transmission
        - engine
        - drivetrain
        - model
        - bodyStyle
      title: Vehicle
      type: object
      properties:
        vin:
          type: string
          description: Vehicle is uniquely identified by vin
        seatCount:
          type: integer
          minimum: 0
          description: Vehicle has Seat Count
        doorCount:
          type: integer
          minimum: 0
          description: Vehicle has Door Count
        interiorColor:
          type: string
          description: Vehicle was manufactured with Interior Color
        exteriorColor:
          type: string
          description: Vehicle was manufactured with Exterior Color
        year:
          type: integer
          description: Vehicle was manufactured in Year
        make:
          type: string
          description: Vehicle is of Make
        trim:
          type: string
          description: Vehicle has Trim level
        transmission:
          type: string
          description: Vehicle has Transmission
        engine:
          type: string
          description: Vehicle has Engine specification
        spec:
          oneOf:
            - type: string
            - $ref: '#/components/schemas/VehicleSpec'
          description: Vehicle has Vehicle Spec
        drivetrain:
          type: string
          description: Vehicle has Drivetrain
        model:
          type: string
          description: Vehicle has Model
        bodyStyle:
          type: string
          description: Vehicle has Body Style
    CreditApp:
      $id: CreditApp
      examples:
        - id: crapp_4ks9j3k2d0d2
          ssn: 123-45-6789
          email: john.doe@example.com
          vehicle: Vehicle ID
          lastName: Doe
          consumer: Consumer ID
          birthDate: '1984-09-20'
          firstName: John
          phoneNumber: 555-0199
          preApproval: Pre-Approval ID
          coApplicantSSN: 234-56-7890
          coApplicantEmail: jane.doe@example.com
          coApplicantLastName: Doe
          coApplicantConsumer: Consumer ID
          coApplicantBirthDate: '1990-07-12'
          coApplicantFirstName: Jane
          coApplicantPhoneNumber: 555-6789
      required:
        - id
        - preApproval
        - consumer
        - vehicle
      title: Credit App
      type: object
      properties:
        id:
          type: string
          description: Credit App is uniquely identified by id
        provider:
          type: string
          enum:
            - TSG
            - RouteOne
          description: Credit App has Credit App Provider
        providerResponse:
          type: object
          description: Credit App has Provider Response
        coApplicantSSN:
          type: string
          description: Credit App has CoApplicant SSN
        coApplicantPhoneNumber:
          type: string
          pattern: ^\+?1?[- ]?\(?([0-9]{3})\)?[- ]?([0-9]{3})-?([0-9]{4})$
          description: Credit App has CoApplicant Phone Number
        coApplicantEmail:
          type: string
          format: idn-email
          description: Credit App has CoApplicant Email
        coApplicantBirthDate:
          type: string
          format: date
          description: Credit App has CoApplicant Birth Date
        coApplicantLastName:
          type: string
          description: Credit App has CoApplicant Last Name
        coApplicantFirstName:
          type: string
          description: Credit App has CoApplicant First Name
        ssn:
          type: string
          description: Credit App has SSN
        phoneNumber:
          type: string
          pattern: ^\+?1?[- ]?\(?([0-9]{3})\)?[- ]?([0-9]{3})-?([0-9]{4})$
          description: Credit App has Phone Number
        email:
          type: string
          format: idn-email
          description: Credit App has Email
        birthDate:
          type: string
          format: date
          description: Credit App has Birth Date
        lastName:
          type: string
          description: Credit App has Last Name
        firstName:
          type: string
          description: Credit App has First Name
        preApproval:
          oneOf:
            - type: string
            - $ref: '#/components/schemas/PreApproval'
          description: Credit App requires Pre-Approval
        consumer:
          oneOf:
            - type: string
            - $ref: '#/components/schemas/Consumer'
          description: Consumer submits Credit App
        coApplicantConsumer:
          oneOf:
            - type: string
            - $ref: '#/components/schemas/Consumer'
          description: Credit App has CoApplicant Consumer
        vehicle:
          oneOf:
            - type: string
            - $ref: '#/components/schemas/Vehicle'
          description: Credit App finances Vehicle
        toProvider:
          type: boolean
          description: Send Credit App to provider
    Deal:
      $id: Deal
      examples:
        - id: deal_5ksj49dkvdl2
          dealer:
            location:
              id: loc_8dj39dksm2d9
              zip: '90210'
              city:
                name: Anytown
                state:
                  code: CA
              line2: Suite 100
              line1: 456 Dealership Blvd
              latitude: 34.0522
              longitude: -118.2437
          vehicle:
            id: veh_3k12j9qksdf0
            vin: 1C4HJXEN5MW592818
            year: 2021
            make: Jeep
            trim: Sport
            spec: Off-Road Package
            model: Wrangler
            engine: 3.6L V6
            seatCount: 5
            doorCount: 4
            bodyStyle: SUV
            drivetrain: 4WD
            transmission: Automatic
            interiorColor: Black
            exteriorColor: Red
          customer:
            id: cus_9kd39fkj4l5d
            addresses:
              - id: adr_9fdk39dkc9d3
                city:
                  name: New City
                  state:
                    code: CA
                zip: '90212'
                line2: Apt 202
                line1: 987 New Address Blvd
            phoneNumbers:
              - 555-456-7890
          facilitator:
            id: fac_6dj39dk3kdl3
            name: AutoFacilitators Inc.
            location:
              id: loc_2kj49d1msod2
              zip: '90310'
              city:
                name: Uptown
                state:
                  code: CA
              line2: Floor 3
              line1: 789 Facilitator Road
          maximumBidPrice: 50000
          currentBidPrice: 45000
          minimumBidPrice: 30000
          coBuyerOrCoSellerCustomer:
            id: cus_k3j5s9qj3w0d
            addresses:
              - id: adr_4kj6s9qj3w0d
                city:
                  name: Anytown
                  state:
                    code: NY
                zip: '10001'
                line2: ''
                line1: 123 Customer St
            phoneNumbers:
              - 555-987-6543
      required:
        - id
        - vehicle
        - customer
      title: Deal
      type: object
      properties:
        id:
          type: string
          description: Deal is uniquely identified by id
        maximumBidPrice:
          type: integer
          description: Deal has Maximum Bid Price
        dealer:
          oneOf:
            - type: string
            - $ref: '#/components/schemas/Dealer'
          description: Deal sells from Dealer
        currentBidPrice:
          type: integer
          description: Deal has Current Bid Price
        minimumBidPrice:
          type: integer
          description: Deal has Minimum Bid Price
        facilitator:
          oneOf:
            - type: string
            - $ref: '#/components/schemas/Facilitator'
          description: Deal is facilitated by Facilitator
        coBuyerOrCoSellerCustomer:
          oneOf:
            - type: string
            - $ref: '#/components/schemas/Customer'
          description: Deal has CoBuyer Or CoSeller Customer
        vehicle:
          oneOf:
            - type: string
            - $ref: '#/components/schemas/Vehicle'
          description: Deal buys/sells Vehicle
        customer:
          oneOf:
            - type: string
            - $ref: '#/components/schemas/Customer'
          description: Deal is made with Customer
    Address:
      $id: Address
      examples:
        - id: adr_2kj49d1msod2
          zip: '62704'
          city:
            name: Springfield
            state:
              code: IL
          line2: Apt 201
          line1: 456 Elm Street
      required:
        - id
        - city
        - zip
        - line1
      title: Address
      type: object
      properties:
        id:
          type: string
          description: Address is uniquely identified by id
        city:
          oneOf:
            - type: object
              properties:
                state:
                  oneOf:
                    - type: string
                    - $ref: '#/components/schemas/State'
                name:
                  type: string
              required:
                - state
                - name
            - $ref: '#/components/schemas/City'
          description: Address is located in City
        zip:
          type: string
          description: Address has ZIP
        line2:
          type: string
          description: Address has Address Line 2
        line1:
          type: string
          description: Address has Address Line 1
    VehicleSpec:
      $id: VehicleSpec
      title: Vehicle Spec
      examples:
        - id: vs_4jf8x9jv5c0b
          make: Toyota
          year: 2022
          trim: SE
          model: Camry
          engine: 2.5L 4-cylinder
          squishVin: 4T1BF1FK5H
          bodyStyle: Sedan
          drivetrain: FWD
          transmission: Automatic
          exteriorColors:
            - Black
            - Silver
          interiorColors:
            - Black
            - Gray
      properties:
        id:
          type: string
          description: Vehicle Spec is uniquely identified by id
        model:
          type: string
          description: Vehicle Spec has Model
        make:
          type: string
          description: Vehicle Spec has Make
        squishVin:
          type: string
          minLength: 10
          maxLength: 10
          description: Vehicle Spec has Squish VIN
        year:
          type: integer
          description: Vehicle Spec has Year
        engine:
          type: string
          description: Vehicle Spec has Engine specifications
        drivetrain:
          type: string
          description: Vehicle Spec has Drivetrain
        bodyStyle:
          type: string
          description: Vehicle Spec has Body Style
        transmission:
          type: string
          description: Vehicle Spec has Transmission
        trim:
          type: string
          description: Vehicle Spec has Trim
        exteriorColors:
          type: array
          items:
            type: string
          description: Vehicle Spec has Exterior Color
        interiorColors:
          type: array
          items:
            type: string
          description: Vehicle Spec has Interior Color
      type: object
      required:
        - id
        - model
        - make
        - year
        - engine
        - drivetrain
        - bodyStyle
        - transmission
    PreApproval:
      $id: PreApproval
      examples:
        - id: pre_59dk394fjdl3
          consumer: Consumer ID
          creditBand: crb_39fjkd93nmd0
          validUntilTime: '2024-04-12T00:00:00Z'
      required:
        - id
        - validUntilTime
        - creditBand
      title: Pre-Approval
      type: object
      properties:
        id:
          type: string
          description: Pre-Approval is uniquely identified by id
        consumer:
          oneOf:
            - type: string
            - $ref: '#/components/schemas/Consumer'
          description: Consumer has Pre-Approval
        validUntilTime:
          type: string
          format: date-time
          description: Pre-Approval is Valid Until Time
        creditBand:
          oneOf:
            - type: string
            - $ref: '#/components/schemas/CreditBand'
          description: Pre-Approval falls in Credit Band
    Consumer:
      $id: Consumer
      examples:
        - id: con_2k4jd93vsd82
          ssn: 123-45-6789
          email: john.doe@example.com
          lastName: Doe
          birthDate: '1984-09-20'
          firstName: John
          phoneNumber: 555-0199
      title: Consumer
      type: object
      properties:
        id:
          type: string
          description: Customer is uniquely identified by id
        addresses:
          type: array
          items:
            oneOf:
              - type: string
              - $ref: '#/components/schemas/Address'
          description: Customer is located at Addresses
        phoneNumbers:
          type: array
          items:
            type: string
            pattern: ^\+?1?[- ]?\(?([0-9]{3})\)?[- ]?([0-9]{3})-?([0-9]{4})$
          description: Customer has Phone Number
        birthDate:
          type: string
          format: date
          description: Consumer has Birth Date
        email:
          type: string
          format: idn-email
          description: Consumer has Email
        phoneNumber:
          type: string
          pattern: ^\+?1?[- ]?\(?([0-9]{3})\)?[- ]?([0-9]{3})-?([0-9]{4})$
          description: Consumer has Phone Number
        ssn:
          type: string
          description: Consumer has SSN
        lastName:
          type: string
          description: Consumer has Last Name
        firstName:
          type: string
          description: Consumer has First Name
      required:
        - birthDate
        - phoneNumber
        - lastName
        - firstName
        - id
    Dealer:
      $id: Dealer
      title: Dealer
      examples:
        - location:
            latitude: 39.7487
            longitude: -104.999
          addresses:
            - city:
                name: Denver
                state:
                  code: CO
              zip: '80202'
              line2: Suite 400
              line1: 100 Business Park Ave
      properties:
        id:
          type: string
          description: Customer is uniquely identified by id
        addresses:
          type: array
          items:
            oneOf:
              - type: string
              - $ref: '#/components/schemas/Address'
          description: Customer is located at Addresses
        phoneNumbers:
          type: array
          items:
            type: string
            pattern: ^\+?1?[- ]?\(?([0-9]{3})\)?[- ]?([0-9]{3})-?([0-9]{4})$
          description: Customer has Phone Number
        name:
          type: string
          description: Company has Name
        contacts:
          type: array
          items:
            oneOf:
              - type: string
              - $ref: '#/components/schemas/Contact'
          description: Company has Contact
        location:
          oneOf:
            - type: object
              properties:
                longitude:
                  type: number
                  minimum: -180
                  maximum: 180
                latitude:
                  type: number
                  minimum: -90
                  maximum: 90
              required:
                - longitude
                - latitude
            - $ref: '#/components/schemas/Location'
          description: Dealer is located at Location
      type: object
      required:
        - name
        - id
    Facilitator:
      $id: Facilitator
      title: Facilitator
      type: object
      examples:
        - id: com_9j3k2dls0j29
          name: Auto Sales Co.
          address: 123 Main St, Anytown, USA
          locations:
            - id: loc_k2j3l9s9d4j0
              companyId: com_9j3k2dls0j29
              address: 123 Main St, Anytown, USA
              phone: '+1234567890'
      properties:
        id:
          type: string
          description: Customer is uniquely identified by id
        addresses:
          type: array
          items:
            oneOf:
              - type: string
              - $ref: '#/components/schemas/Address'
          description: Customer is located at Addresses
        phoneNumbers:
          type: array
          items:
            type: string
            pattern: ^\+?1?[- ]?\(?([0-9]{3})\)?[- ]?([0-9]{3})-?([0-9]{4})$
          description: Customer has Phone Number
        name:
          type: string
          description: Company has Name
        contacts:
          type: array
          items:
            oneOf:
              - type: string
              - $ref: '#/components/schemas/Contact'
          description: Company has Contact
      required:
        - name
        - id
    State:
      $id: State
      title: State
      properties:
        code:
          type: string
          description: State is uniquely identified by State Code
      type: object
      required:
        - code
    City:
      $id: City
      examples:
        - name: Springfield
          state:
            code: IL
      required:
        - state
        - name
      title: City
      type: object
      properties:
        state:
          oneOf:
            - type: string
            - $ref: '#/components/schemas/State'
          description: City is uniquely identified by State
        name:
          type: string
          description: City is uniquely identified by Name
    CreditBand:
      $id: CreditBand
      title: Credit Band
      examples:
        - id: crb_39fjkd93nmd0
          name: Good
          isNS: false
          isPrime: true
          isUnknown: false
          minimumCreditScore: 600
          maximumCreditScore: 700
      properties:
        id:
          type: string
          description: Credit Band is uniquely identified by id
        minimumCreditScore:
          type: number
          description: Credit Band has Minimum Credit Score
        maximumCreditScore:
          type: number
          description: Credit Band has Maximum Credit Score
        name:
          type: string
          description: Credit Band has Name
        isUnknown:
          type: boolean
          description: Credit Band is unknown
        isNS:
          type: boolean
          description: Credit Band is NS
        isPrime:
          type: boolean
          description: Credit Band is prime
      type: object
      required:
        - id
        - name
    Contact:
      $id: Contact
      examples:
        - id: cnt_8dk3j2ksl9d2
          roles:
            - Manager
            - Sales
          lastName: Smith
          firstName: Alice
      required:
        - id
        - lastName
        - firstName
      title: Contact
      type: object
      properties:
        id:
          type: string
          description: Contact is uniquely identified by id
        agent:
          oneOf:
            - type: string
            - $ref: '#/components/schemas/Agent'
          description: Contact is automated Agent
        address:
          oneOf:
            - type: string
            - $ref: '#/components/schemas/Address'
          description: Contact has Address
        primaryPhoneNumber:
          type: string
          pattern: ^\+?1?[- ]?\(?([0-9]{3})\)?[- ]?([0-9]{3})-?([0-9]{4})$
          description: Contact has Primary Phone Number
        primaryEmail:
          type: string
          format: idn-email
          description: Contact has Primary Email
        lastName:
          type: string
          description: Contact has Last Name
        firstName:
          type: string
          description: Contact has First Name
        emails:
          type: array
          items:
            type: string
            format: idn-email
          description: Contact has Email
        phoneNumbers:
          type: array
          items:
            type: string
            pattern: ^\+?1?[- ]?\(?([0-9]{3})\)?[- ]?([0-9]{3})-?([0-9]{4})$
          description: Contact has Phone Number
        roles:
          type: array
          items:
            type: string
          description: Contact has Role
    Location:
      $id: Location
      title: Location
      examples:
        - latitude: 37.7749295
          longitude: -122.4194155
      properties:
        longitude:
          type: number
          minimum: -180
          maximum: 180
          description: Location is uniquely identified by Longitude
        latitude:
          type: number
          minimum: -90
          maximum: 90
          description: Location is uniquely identified by Latitude
      type: object
      required:
        - longitude
        - latitude
    Agent:
      $id: Agent
      examples:
        - id: ai_3jks93ndk3s9
          model: gpt-4o
          prompt: Respond to the customer service request
          functions:
            - fnc_ed904md03684
      required:
        - id
        - model
      title: Agent
      type: object
      properties:
        id:
          type: string
          description: Agent is uniquely identified by id
        prompt:
          type: string
          description: Agent has Prompt
        model:
          type: string
          description: Agent has Agent Model
        functions:
          type: array
          items:
            type: string
          description: Agent has Function

````