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

# Atualização de proposta

> Atualiza a proposta informada. - `deal_code` pode ser usado para trocar o contexto do negócio sem enviar `deal_id`. - Quando `items` é enviado, a lista inteira é reprocessada e aceita remoções com `delete: true`. - Itens com `sku` e sem `product_id` são resolvidos pelo catálogo da empresa.




## OpenAPI

````yaml /openapi.json put /integrations/external/proposals/{id}
openapi: 3.0.3
info:
  title: >-
    Integração Externa - Leads, Oportunidades, Tarefas, Arquivos, Propostas,
    Chats, Satisfação e Campos Personalizados
  version: 1.0.0
  description: >
    Documentação oficial da API externa da Wegly para campos personalizados,
    leads, oportunidades, tarefas, arquivos, propostas, chats e satisfação
    (`/integrations/external/custom-fields`, `/integrations/external/files`,
    `/integrations/external/leads`, `/integrations/external/deals`,
    `/integrations/external/tasks`, `/integrations/external/proposals`,
    `/integrations/external/chats` e `/integrations/external/satisfaction`).
    Todas as descrições estão em português e refletem as regras aplicadas pelo
    serviço.
servers:
  - url: https://api.wegly.com.br
    description: Ambiente de produção Wegly
security:
  - bearerAuth: []
tags:
  - name: Campos Personalizados
    description: >-
      Consulta dos campos personalizados disponíveis para uso nas integrações
      externas.
  - name: Arquivos
    description: >-
      Upload de arquivos públicos de integração vinculados diretamente a leads
      ou oportunidades.
  - name: Leads
    description: >-
      Operações de listagem, criação, consulta e atualização de leads via
      integração externa.
  - name: Oportunidades
    description: Operações de criação de oportunidades (deals) via integração externa.
  - name: Tarefas
    description: >-
      Operações de listagem, criação, consulta, atualização e remoção de tarefas
      vinculadas a leads, oportunidades, entregas, pessoas ou organizações.
  - name: Satisfação
    description: >-
      Geração de links públicos para formulários de satisfação via integração
      externa.
  - name: Propostas
    description: >-
      Operações de listagem, criação, consulta, atualização e remoção de
      propostas via integração externa.
  - name: Chats
    description: >-
      Operações principais de listagem, criação, consulta e resumo de não lidas
      de chats via integração externa.
paths:
  /integrations/external/proposals/{id}:
    put:
      tags:
        - Propostas
      summary: Atualização de proposta
      description: >
        Atualiza a proposta informada. - `deal_code` pode ser usado para trocar
        o contexto do negócio sem enviar `deal_id`. - Quando `items` é enviado,
        a lista inteira é reprocessada e aceita remoções com `delete: true`. -
        Itens com `sku` e sem `product_id` são resolvidos pelo catálogo da
        empresa.
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: UUID da proposta.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateExternalProposal'
      responses:
        '200':
          description: Proposta atualizada.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProposalDetails'
        '400':
          description: Validação de dados falhou ou regra de negócio não foi atendida.
        '401':
          description: Token de integração ausente ou inválido.
        '403':
          description: >-
            Permissão `crm/proposal.update` ausente ou domínio de origem não
            autorizado na chave.
        '404':
          description: Proposta, negócio, produto ou lead não encontrados.
        '409':
          description: Múltiplos negócios encontrados para o `deal_code` informado.
components:
  schemas:
    UpdateExternalProposal:
      type: object
      properties:
        lead_id:
          type: string
          format: uuid
          nullable: true
        deal_id:
          type: string
          format: uuid
          nullable: true
        deal_code:
          type: string
          maxLength: 50
        title:
          type: string
          maxLength: 150
          nullable: true
        notes:
          type: string
          nullable: true
        status:
          $ref: '#/components/schemas/ProposalStatusValue'
        discount_type:
          type: integer
          allOf:
            - $ref: '#/components/schemas/ProposalDiscountType'
          nullable: true
        discount_value:
          type: number
          minimum: 0
          nullable: true
        valid_until:
          type: string
          format: date-time
          nullable: true
        approved_by:
          type: string
          format: uuid
          nullable: true
        approved_at:
          type: string
          format: date-time
          nullable: true
        archived_at:
          type: string
          format: date-time
          nullable: true
        rejected_at:
          type: string
          format: date-time
          nullable: true
        items:
          type: array
          items:
            $ref: '#/components/schemas/ProposalItemInput'
    ProposalDetails:
      allOf:
        - $ref: '#/components/schemas/ProposalSummary'
        - type: object
          properties:
            items:
              type: array
              items:
                $ref: '#/components/schemas/ProposalItemResponse'
    ProposalStatusValue:
      type: integer
      enum:
        - 1
        - 2
        - 3
        - 4
        - 5
      description: >
        1 = negociação, 2 = aprovada, 3 = rejeitada, 4 = arquivada, 5 =
        dispensada.
    ProposalDiscountType:
      type: integer
      enum:
        - 0
        - 1
      description: 0 = percentual, 1 = valor fixo.
    ProposalItemInput:
      type: object
      properties:
        id:
          type: string
          nullable: true
        delete:
          type: boolean
          description: Marca o item para remoção durante uma atualização.
        product_id:
          type: string
          format: uuid
          nullable: true
        sku:
          type: string
          maxLength: 50
          nullable: true
          description: >-
            Código interno do produto usado para resolver `product_id` quando
            ele não é enviado.
        name:
          type: string
          maxLength: 150
          nullable: true
        description:
          type: string
          nullable: true
        quantity:
          type: number
          minimum: 0.001
        unit_price:
          type: number
          minimum: 0
        unit:
          type: integer
          enum:
            - 0
            - 1
            - 2
            - 3
            - 4
            - 5
            - 6
            - 7
          nullable: true
        discount_type:
          $ref: '#/components/schemas/ProposalDiscountType'
        discount_value:
          type: number
          minimum: 0
          nullable: true
        notes:
          type: string
          nullable: true
        is_recurring_default:
          type: boolean
        billing_interval_default:
          type: integer
          enum:
            - 0
            - 1
            - 2
            - 3
            - 4
            - 5
            - 6
          nullable: true
        contract_term_months:
          type: integer
          minimum: 1
          nullable: true
        start_date:
          type: string
          format: date-time
          nullable: true
        end_date:
          type: string
          format: date-time
          nullable: true
        billing_cycles:
          type: integer
          minimum: 1
          nullable: true
    ProposalSummary:
      type: object
      properties:
        id:
          type: string
          format: uuid
        lead:
          type: object
          allOf:
            - $ref: '#/components/schemas/ProposalContextSummary'
          nullable: true
        deal:
          type: object
          allOf:
            - $ref: '#/components/schemas/ProposalContextSummary'
          nullable: true
        code:
          type: integer
        version:
          type: integer
        title:
          type: string
          nullable: true
        status:
          $ref: '#/components/schemas/ProposalStatusValue'
        notes:
          type: string
          nullable: true
        is_primary:
          type: boolean
        discount_type:
          type: integer
          allOf:
            - $ref: '#/components/schemas/ProposalDiscountType'
          nullable: true
        discount_value:
          type: number
          nullable: true
        subtotal:
          type: number
        total:
          type: number
        items_count:
          type: integer
        valid_until:
          type: string
          format: date-time
          nullable: true
        created_by:
          type: object
          allOf:
            - $ref: '#/components/schemas/ExternalUserSummary'
          nullable: true
        approved_by:
          type: object
          allOf:
            - $ref: '#/components/schemas/ExternalPersonSummary'
          nullable: true
        approved_at:
          type: string
          format: date-time
          nullable: true
        archived_at:
          type: string
          format: date-time
          nullable: true
        rejected_at:
          type: string
          format: date-time
          nullable: true
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    ProposalItemResponse:
      type: object
      properties:
        id:
          type: string
          format: uuid
        product_id:
          type: string
          format: uuid
          nullable: true
        product:
          type: object
          allOf:
            - $ref: '#/components/schemas/ProposalProductSummary'
          nullable: true
        name:
          type: string
          nullable: true
        description:
          type: string
          nullable: true
        unit:
          type: integer
          nullable: true
        quantity:
          type: number
        unit_price:
          type: number
        discount_type:
          type: integer
          allOf:
            - $ref: '#/components/schemas/ProposalDiscountType'
          nullable: true
        discount_value:
          type: number
          nullable: true
        subtotal:
          type: number
        total:
          type: number
        notes:
          type: string
          nullable: true
        is_recurring_default:
          type: boolean
        billing_interval_default:
          type: integer
          nullable: true
        contract_term_months:
          type: integer
          nullable: true
        start_date:
          type: string
          format: date-time
          nullable: true
        end_date:
          type: string
          format: date-time
          nullable: true
        billing_cycles:
          type: integer
          nullable: true
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    ProposalContextSummary:
      type: object
      properties:
        id:
          type: string
          format: uuid
        title:
          type: string
          nullable: true
    ExternalUserSummary:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        avatar:
          type: string
          nullable: true
    ExternalPersonSummary:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
    ProposalProductSummary:
      type: object
      properties:
        id:
          type: string
          format: uuid
        code:
          type: string
          nullable: true
        name:
          type: string
        image:
          type: string
          nullable: true
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >
        Utilize o token de integração no header `Authorization: Bearer {token}`.
        O domínio de origem (Origin/Referer) deve respeitar `allowed_domain`,
        quando configurado na chave.

````