openapi: 3.0.3
info:
  title: Grana.ai API de Credores
  description: Grana.ai API de Credores
  version: 1.0.0
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
  schemas:
    AdvanceContractRequest:
      type: object
      properties:
        assetHolderDocument:
          type: string
        reference:
          type: string
        effectType:
          type: string
          enum:
            - ownershipAssignment
            - collateral
        receivingBankAccount:
          type: object
          properties:
            branch:
              description: Número da agência
              type: string
            account:
              description: Número da conta
              type: string
            accountDigit:
              description: Dígito da conta
              type: string
            accountType:
              type: string
              enum:
                - CC
                - CD
                - PG
                - PP
            ispb:
              description: Código do ISPB com oito dígitos
              pattern: ^\d{8}$
              type: string
            documentNumber:
              description: Número do documento federal (CPF ou CNPJ) do titular da conta
              pattern: ^\d{11,14}$
              type: string
            nickname:
              maxLength: 50
              type: string
          required:
            - branch
            - account
            - accountDigit
            - accountType
            - ispb
            - documentNumber
        interestRate:
          examples:
            - "1.6"
            - "2.54"
            - "3.0"
          type: string
        receivableUnits:
          type: array
          items:
            type: object
            properties:
              acquirerDocument:
                description: CNPJ da credenciadora/subcredenciadora
                type: string
              paymentScheme:
                description: 'Arranjo de pagamento (ex: "VCC", "MCC", "VCD", "MCD";
                  respectivamente: Visa Cartão de Crédito, Mastercard Cartão de
                  Crédito, Visa Cartão de Débito, Mastercard Cartão de Débito)'
                type: string
              value:
                description: Valor monetário
                type: integer
            required:
              - acquirerDocument
              - paymentScheme
              - value
        signatureDate:
          format: date
          type: string
      required:
        - assetHolderDocument
        - reference
        - effectType
        - interestRate
        - receivableUnits
        - signatureDate
    BankAccount:
      type: object
      properties:
        branch:
          description: Número da agência
          type: string
        account:
          description: Número da conta
          type: string
        accountDigit:
          description: Dígito da conta
          type: string
        accountType:
          type: string
          enum:
            - CC
            - CD
            - PG
            - PP
        ispb:
          description: Código do ISPB com oito dígitos
          pattern: ^\d{8}$
          type: string
        documentNumber:
          description: Número do documento federal (CPF ou CNPJ) do titular da conta
          pattern: ^\d{11,14}$
          type: string
        nickname:
          maxLength: 50
          type: string
      required:
        - branch
        - account
        - accountDigit
        - accountType
        - ispb
        - documentNumber
    BankAccountType:
      type: string
      enum:
        - CC
        - CD
        - PG
        - PP
    Commitment:
      type: object
      properties:
        divisionMethod:
          type: string
          enum:
            - FIXED
            - PERCENTAGE
        committedAmount:
          type: integer
        committedEffectAmount:
          type: integer
        priority:
          type: integer
      required:
        - divisionMethod
        - committedAmount
        - committedEffectAmount
        - priority
    ContractCreationProcessingResponse:
      type: object
      properties:
        status:
          const: processing
          type: string
        jobId:
          description: ID do job em processamento
          type: string
        message:
          description: Contrato em processamento. Pode demorar alguns minutos. Você
            receberá uma notificação no Slack quando estiver pronto.
          type: string
        estimatedMinutes:
          description: Tempo estimado em minutos
          default: 2
          type: integer
      required:
        - status
        - jobId
        - message
        - estimatedMinutes
    ContractCreationResponse:
      type: object
      properties:
        contractId:
          description: ID do contrato criado
          type: string
      required:
        - contractId
    ContractSpecification:
      type: object
      properties:
        acquirerDocument:
          description: CNPJ da credenciadora/subcredenciadora
          type: string
        paymentScheme:
          description: 'Arranjo de pagamento (ex: "VCC", "MCC", "VCD", "MCD";
            respectivamente: Visa Cartão de Crédito, Mastercard Cartão de
            Crédito, Visa Cartão de Débito, Mastercard Cartão de Débito)'
          type: string
        value:
          description: Valor monetário
          type: integer
      required:
        - acquirerDocument
        - paymentScheme
        - value
    EffectType:
      type: string
      enum:
        - ownershipAssignment
        - collateral
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
          required:
            - message
      required:
        - error
    ForecastedCreditContractRequest:
      type: object
      properties:
        assetHolderDocument:
          type: string
        reference:
          type: string
        effectType:
          type: string
          enum:
            - ownershipAssignment
            - collateral
        receivableUnits:
          type: array
          items:
            type: object
            properties:
              acquirerDocument:
                description: CNPJ da credenciadora/subcredenciadora
                type: string
              paymentScheme:
                description: 'Arranjo de pagamento (ex: "VCC", "MCC", "VCD", "MCD";
                  respectivamente: Visa Cartão de Crédito, Mastercard Cartão de
                  Crédito, Visa Cartão de Débito, Mastercard Cartão de Débito)'
                type: string
              value:
                description: Valor monetário
                type: integer
            required:
              - acquirerDocument
              - paymentScheme
              - value
        receivingBankAccount:
          type: object
          properties:
            branch:
              description: Número da agência
              type: string
            account:
              description: Número da conta
              type: string
            accountDigit:
              description: Dígito da conta
              type: string
            accountType:
              type: string
              enum:
                - CC
                - CD
                - PG
                - PP
            ispb:
              description: Código do ISPB com oito dígitos
              pattern: ^\d{8}$
              type: string
            documentNumber:
              description: Número do documento federal (CPF ou CNPJ) do titular da conta
              pattern: ^\d{11,14}$
              type: string
            nickname:
              maxLength: 50
              type: string
          required:
            - branch
            - account
            - accountDigit
            - accountType
            - ispb
            - documentNumber
        signatureDate:
          format: date
          type: string
        totalValue:
          type: integer
        installments:
          type: integer
        periodicity:
          type: string
          enum:
            - daily
            - weekly
            - biweekly
            - monthly
            - bimonthly
            - quarterly
            - semiannual
            - annual
        startDate:
          format: date
          type: string
      required:
        - assetHolderDocument
        - reference
        - effectType
        - receivableUnits
        - signatureDate
        - totalValue
        - installments
        - periodicity
        - startDate
    Periodicity:
      type: string
      enum:
        - daily
        - weekly
        - biweekly
        - monthly
        - bimonthly
        - quarterly
        - semiannual
        - annual
    ReceivableUnit:
      type: object
      properties:
        key:
          type: string
        assetHolderDocument:
          description: CPF/CNPJ do titular da UR
          type: string
        paymentScheme:
          type: string
        acquirerDocument:
          type: string
        expectedSettlementDate:
          format: date
          type: string
        totalAmount:
          type: integer
        committedAmount:
          type: integer
        availableAmount:
          type: integer
        commitments:
          type: array
          items:
            type: object
            properties:
              divisionMethod:
                type: string
                enum:
                  - FIXED
                  - PERCENTAGE
              committedAmount:
                type: integer
              committedEffectAmount:
                type: integer
              priority:
                type: integer
            required:
              - divisionMethod
              - committedAmount
              - committedEffectAmount
              - priority
      required:
        - key
        - assetHolderDocument
        - paymentScheme
        - acquirerDocument
        - expectedSettlementDate
        - totalAmount
        - committedAmount
        - availableAmount
        - commitments
    ReceivablesScheduleRequest:
      type: object
      properties:
        assetHolderDocument:
          type: string
        startDate:
          format: date
          type: string
        endDate:
          format: date
          type: string
      required:
        - assetHolderDocument
        - startDate
        - endDate
    ReceivablesScheduleRequestResponse:
      type: object
      properties:
        scheduleRequestId:
          type: string
      required:
        - scheduleRequestId
    RelationMetadata:
      type: object
      properties:
        debtorDocument:
          type: string
        paymentScheme:
          type: string
        status:
          type: string
          enum:
            - processing
            - completed
            - failed
            - interrupted
      required:
        - debtorDocument
        - paymentScheme
        - status
    Schedule:
      type: object
      properties:
        units:
          type: array
          items:
            type: object
            properties:
              key:
                type: string
              assetHolderDocument:
                description: CPF/CNPJ do titular da UR
                type: string
              paymentScheme:
                type: string
              acquirerDocument:
                type: string
              expectedSettlementDate:
                format: date
                type: string
              totalAmount:
                type: integer
              committedAmount:
                type: integer
              availableAmount:
                type: integer
              commitments:
                type: array
                items:
                  type: object
                  properties:
                    divisionMethod:
                      type: string
                      enum:
                        - FIXED
                        - PERCENTAGE
                    committedAmount:
                      type: integer
                    committedEffectAmount:
                      type: integer
                    priority:
                      type: integer
                  required:
                    - divisionMethod
                    - committedAmount
                    - committedEffectAmount
                    - priority
            required:
              - key
              - assetHolderDocument
              - paymentScheme
              - acquirerDocument
              - expectedSettlementDate
              - totalAmount
              - committedAmount
              - availableAmount
              - commitments
        error:
          type: object
          properties:
            message:
              type: string
          required:
            - message
        metadata:
          type: object
          properties:
            relations:
              type: array
              items:
                type: object
                properties:
                  debtorDocument:
                    type: string
                  paymentScheme:
                    type: string
                  status:
                    type: string
                    enum:
                      - processing
                      - completed
                      - failed
                      - interrupted
                required:
                  - debtorDocument
                  - paymentScheme
                  - status
          required:
            - relations
      required:
        - units
    ScheduleMetadata:
      type: object
      properties:
        relations:
          type: array
          items:
            type: object
            properties:
              debtorDocument:
                type: string
              paymentScheme:
                type: string
              status:
                type: string
                enum:
                  - processing
                  - completed
                  - failed
                  - interrupted
            required:
              - debtorDocument
              - paymentScheme
              - status
      required:
        - relations
paths:
  /v1/contracts/advancement:
    post:
      operationId: createAdvancementContract
      summary: Antecipação de recebíveis
      tags:
        - Contrato
      description: Cria um novo contrato de antecipação de recebíveis
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AdvanceContractRequest"
      responses:
        "201":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ContractCreationResponse"
        "400":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "500":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /v1/contracts/forecasted:
    post:
      operationId: createForecastedContract
      summary: Crédito fumaça
      tags:
        - Contrato
      description: Cria um novo contrato de crédito fumaça. Com muitas parcelas (>30)
        e flag ativa, retorna 202 (processamento assíncrono).
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ForecastedCreditContractRequest"
      responses:
        "201":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ContractCreationResponse"
        "202":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ContractCreationProcessingResponse"
        "400":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "500":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /v1/receivables-schedule-requests/:
    post:
      operationId: createReceivablesScheduleRequest
      summary: Nova consulta de agenda
      tags:
        - Agenda
      description: Cria uma nova consulta de agenda de recebíveis
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ReceivablesScheduleRequest"
      responses:
        "202":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ReceivablesScheduleRequestResponse"
        "400":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "500":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /v1/receivables-schedule-requests/{scheduleRequestId}:
    get:
      operationId: getReceivablesScheduleResult
      summary: Resultado da consulta
      tags:
        - Agenda
      description: Obtém o resultado de uma consulta de agenda de recebíveis
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: scheduleRequestId
          required: true
          description: UUID referente à consulta criada.
      responses:
        "200":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Schedule"
        "404":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "500":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /v1/asset-holders/:
    get:
      operationId: listAssetHoldersV2
      summary: Listar estabelecimentos
      tags:
        - Estabelecimento
      description: Lista estabelecimentos (asset holders) do credor com paginação e
        busca opcional.
      parameters:
        - schema:
            type: number
          in: query
          name: page
          required: false
        - schema:
            type: number
          in: query
          name: pageSize
          required: false
        - schema:
            type: string
          in: query
          name: search
          required: false
      responses:
        "200":
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                allOf:
                  - type: object
                    properties:
                      data:
                        type: array
                        items:
                          type: object
                          allOf:
                            - type: object
                              properties:
                                id:
                                  format: uuid
                                  type: string
                                creditorsId:
                                  format: uuid
                                  type: string
                                name:
                                  maxLength: 255
                                  type: string
                                shortName:
                                  maxLength: 150
                                  default: ""
                                  type: string
                                documentType:
                                  maxLength: 10
                                  default: CNPJ
                                  type: string
                                documentNumber:
                                  maxLength: 30
                                  type: string
                                birthDate:
                                  type: string
                                mainPhone:
                                  maxLength: 50
                                  type: string
                                mainEmail:
                                  maxLength: 255
                                  type: string
                                mainContact:
                                  maxLength: 255
                                  type: string
                                flag:
                                  maxLength: 50
                                  type: string
                                observation:
                                  maxLength: 255
                                  type: string
                                isActive:
                                  type: boolean
                              required:
                                - id
                                - creditorsId
                                - name
                                - shortName
                                - documentType
                                - documentNumber
                                - isActive
                            - type: object
                              properties:
                                bankAccounts:
                                  type: array
                                  items:
                                    type: object
                                    allOf:
                                      - type: object
                                        properties:
                                          id:
                                            format: uuid
                                            type: string
                                          banksId:
                                            format: uuid
                                            type: string
                                          branch:
                                            maxLength: 20
                                            type: string
                                          branchDigit:
                                            maxLength: 5
                                            type: string
                                          account:
                                            maxLength: 20
                                            type: string
                                          accountDigit:
                                            maxLength: 5
                                            type: string
                                          accountType:
                                            maxLength: 5
                                            type: string
                                          documentType:
                                            maxLength: 10
                                            default: CNPJ
                                            type: string
                                          documentNumber:
                                            maxLength: 35
                                            type: string
                                          accountableId:
                                            format: uuid
                                            type: string
                                          accountableType:
                                            maxLength: 255
                                            type: string
                                          flag:
                                            maxLength: 50
                                            type: string
                                          pixValue:
                                            type: string
                                          pixType:
                                            type: string
                                          isDefault:
                                            type: boolean
                                          isActive:
                                            type: boolean
                                          isEscrow:
                                            type: boolean
                                          nickname:
                                            anyOf:
                                              - maxLength: 50
                                                type: string
                                            nullable: true
                                        required:
                                          - banksId
                                          - branch
                                          - account
                                          - documentType
                                          - documentNumber
                                          - accountableId
                                          - accountableType
                                          - isDefault
                                          - isActive
                                      - type: object
                                        properties:
                                          banks:
                                            type: object
                                            allOf:
                                              - type: object
                                                properties:
                                                  name:
                                                    maxLength: 255
                                                    type: string
                                                  shortName:
                                                    maxLength: 255
                                                    type: string
                                                  compeNumber:
                                                    type: string
                                                  isCompeParticipate:
                                                    default: false
                                                    type: boolean
                                                  mainAccess:
                                                    maxLength: 50
                                                    type: string
                                                  ispb:
                                                    type: string
                                                  isActive:
                                                    default: false
                                                    type: boolean
                                                required:
                                                  - name
                                                  - shortName
                                                  - ispb
                                                  - isActive
                                              - type: object
                                                properties:
                                                  id:
                                                    format: uuid
                                                    type: string
                                                required:
                                                  - id
                                        required:
                                          - banks
                                address:
                                  type: object
                                  properties:
                                    id:
                                      format: uuid
                                      type: string
                                    addressableId:
                                      format: uuid
                                      type: string
                                    addressableType:
                                      maxLength: 255
                                      type: string
                                    title:
                                      maxLength: 255
                                      type: string
                                    street:
                                      maxLength: 255
                                      type: string
                                    number:
                                      maxLength: 20
                                      type: string
                                    complement:
                                      maxLength: 255
                                      type: string
                                    neighborhood:
                                      maxLength: 255
                                      type: string
                                    city:
                                      maxLength: 255
                                      type: string
                                    state:
                                      maxLength: 2
                                      type: string
                                    postalCode:
                                      maxLength: 9
                                      type: string
                                  required:
                                    - addressableId
                                    - addressableType
                                fees:
                                  type: array
                                  items:
                                    type: object
                                    properties:
                                      id:
                                        format: uuid
                                        type: string
                                      assetHoldersId:
                                        format: uuid
                                        type: string
                                      feeType:
                                        type: string
                                        enum:
                                          - LatePaymentInterest
                                          - LatePaymentFine
                                          - CreditInterest
                                          - AdvanceInterest
                                      percent:
                                        type: number
                                    required:
                                      - id
                                      - assetHoldersId
                                      - feeType
                                      - percent
                      total:
                        type: number
                    required:
                      - data
                      - total
                  - type: object
                    properties:
                      page:
                        type: number
                      pageSize:
                        type: number
                    required:
                      - page
                      - pageSize
        "404":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "500":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createAssetHolderV2
      summary: Criar estabelecimento
      tags:
        - Estabelecimento
      description: Cria um estabelecimento vinculado ao credor.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              allOf:
                - type: object
                  properties:
                    name:
                      maxLength: 255
                      type: string
                    shortName:
                      maxLength: 150
                      default: ""
                      type: string
                    documentType:
                      maxLength: 10
                      default: CNPJ
                      type: string
                    documentNumber:
                      maxLength: 30
                      type: string
                    birthDate:
                      type: string
                    mainPhone:
                      maxLength: 50
                      type: string
                    mainEmail:
                      maxLength: 255
                      type: string
                    mainContact:
                      maxLength: 255
                      type: string
                    observation:
                      maxLength: 255
                      type: string
                  required:
                    - name
                    - shortName
                    - documentType
                    - documentNumber
                - type: object
                  properties:
                    bankAccounts:
                      type: array
                      items:
                        type: object
                        properties:
                          banksId:
                            format: uuid
                            type: string
                          branch:
                            maxLength: 20
                            type: string
                          branchDigit:
                            maxLength: 5
                            type: string
                          account:
                            maxLength: 20
                            type: string
                          accountDigit:
                            maxLength: 5
                            type: string
                          accountType:
                            maxLength: 5
                            type: string
                          documentType:
                            maxLength: 10
                            default: CNPJ
                            type: string
                          documentNumber:
                            maxLength: 35
                            type: string
                          pixValue:
                            type: string
                          pixType:
                            type: string
                          isDefault:
                            type: boolean
                          isEscrow:
                            type: boolean
                          nickname:
                            anyOf:
                              - maxLength: 50
                                type: string
                            nullable: true
                        required:
                          - banksId
                          - branch
                          - account
                          - documentType
                          - documentNumber
                          - isDefault
                    address:
                      type: object
                      properties:
                        title:
                          maxLength: 255
                          type: string
                        street:
                          maxLength: 255
                          type: string
                        number:
                          maxLength: 20
                          type: string
                        complement:
                          maxLength: 255
                          type: string
                        neighborhood:
                          maxLength: 255
                          type: string
                        city:
                          maxLength: 255
                          type: string
                        state:
                          maxLength: 2
                          type: string
                        postalCode:
                          maxLength: 9
                          type: string
                      required:
                        - title
                        - street
                        - number
                        - complement
                        - neighborhood
                        - city
                        - state
                        - postalCode
                    fees:
                      type: array
                      items:
                        type: object
                        properties:
                          feeType:
                            type: string
                            enum:
                              - LatePaymentInterest
                              - LatePaymentFine
                              - CreditInterest
                              - AdvanceInterest
                          percent:
                            type: number
                        required:
                          - feeType
                          - percent
      responses:
        "201":
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                allOf:
                  - type: object
                    properties:
                      id:
                        format: uuid
                        type: string
                      creditorsId:
                        format: uuid
                        type: string
                      name:
                        maxLength: 255
                        type: string
                      shortName:
                        maxLength: 150
                        default: ""
                        type: string
                      documentType:
                        maxLength: 10
                        default: CNPJ
                        type: string
                      documentNumber:
                        maxLength: 30
                        type: string
                      birthDate:
                        type: string
                      mainPhone:
                        maxLength: 50
                        type: string
                      mainEmail:
                        maxLength: 255
                        type: string
                      mainContact:
                        maxLength: 255
                        type: string
                      flag:
                        maxLength: 50
                        type: string
                      observation:
                        maxLength: 255
                        type: string
                      isActive:
                        type: boolean
                    required:
                      - id
                      - creditorsId
                      - name
                      - shortName
                      - documentType
                      - documentNumber
                      - isActive
                  - type: object
                    properties:
                      bankAccounts:
                        type: array
                        items:
                          type: object
                          allOf:
                            - type: object
                              properties:
                                id:
                                  format: uuid
                                  type: string
                                banksId:
                                  format: uuid
                                  type: string
                                branch:
                                  maxLength: 20
                                  type: string
                                branchDigit:
                                  maxLength: 5
                                  type: string
                                account:
                                  maxLength: 20
                                  type: string
                                accountDigit:
                                  maxLength: 5
                                  type: string
                                accountType:
                                  maxLength: 5
                                  type: string
                                documentType:
                                  maxLength: 10
                                  default: CNPJ
                                  type: string
                                documentNumber:
                                  maxLength: 35
                                  type: string
                                accountableId:
                                  format: uuid
                                  type: string
                                accountableType:
                                  maxLength: 255
                                  type: string
                                flag:
                                  maxLength: 50
                                  type: string
                                pixValue:
                                  type: string
                                pixType:
                                  type: string
                                isDefault:
                                  type: boolean
                                isActive:
                                  type: boolean
                                isEscrow:
                                  type: boolean
                                nickname:
                                  anyOf:
                                    - maxLength: 50
                                      type: string
                                  nullable: true
                              required:
                                - banksId
                                - branch
                                - account
                                - documentType
                                - documentNumber
                                - accountableId
                                - accountableType
                                - isDefault
                                - isActive
                            - type: object
                              properties:
                                banks:
                                  type: object
                                  allOf:
                                    - type: object
                                      properties:
                                        name:
                                          maxLength: 255
                                          type: string
                                        shortName:
                                          maxLength: 255
                                          type: string
                                        compeNumber:
                                          type: string
                                        isCompeParticipate:
                                          default: false
                                          type: boolean
                                        mainAccess:
                                          maxLength: 50
                                          type: string
                                        ispb:
                                          type: string
                                        isActive:
                                          default: false
                                          type: boolean
                                      required:
                                        - name
                                        - shortName
                                        - ispb
                                        - isActive
                                    - type: object
                                      properties:
                                        id:
                                          format: uuid
                                          type: string
                                      required:
                                        - id
                              required:
                                - banks
                      address:
                        type: object
                        properties:
                          id:
                            format: uuid
                            type: string
                          addressableId:
                            format: uuid
                            type: string
                          addressableType:
                            maxLength: 255
                            type: string
                          title:
                            maxLength: 255
                            type: string
                          street:
                            maxLength: 255
                            type: string
                          number:
                            maxLength: 20
                            type: string
                          complement:
                            maxLength: 255
                            type: string
                          neighborhood:
                            maxLength: 255
                            type: string
                          city:
                            maxLength: 255
                            type: string
                          state:
                            maxLength: 2
                            type: string
                          postalCode:
                            maxLength: 9
                            type: string
                        required:
                          - addressableId
                          - addressableType
                      fees:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              format: uuid
                              type: string
                            assetHoldersId:
                              format: uuid
                              type: string
                            feeType:
                              type: string
                              enum:
                                - LatePaymentInterest
                                - LatePaymentFine
                                - CreditInterest
                                - AdvanceInterest
                            percent:
                              type: number
                          required:
                            - id
                            - assetHoldersId
                            - feeType
                            - percent
        "400":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "500":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /v1/asset-holders/{assetHolderId}:
    patch:
      operationId: updateAssetHolderV2
      summary: Atualizar estabelecimento
      tags:
        - Estabelecimento
      description: Atualiza parcialmente um estabelecimento do credor.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              allOf:
                - type: object
                  properties:
                    creditorsId:
                      format: uuid
                      type: string
                    name:
                      maxLength: 255
                      type: string
                    shortName:
                      maxLength: 150
                      default: ""
                      type: string
                    documentType:
                      maxLength: 10
                      default: CNPJ
                      type: string
                    documentNumber:
                      maxLength: 30
                      type: string
                    birthDate:
                      type: string
                    mainPhone:
                      maxLength: 50
                      type: string
                    mainEmail:
                      maxLength: 255
                      type: string
                    mainContact:
                      maxLength: 255
                      type: string
                    observation:
                      maxLength: 255
                      type: string
                  required:
                    - creditorsId
                    - name
                    - shortName
                    - documentType
                    - documentNumber
                - type: object
                  properties:
                    bankAccounts:
                      type: array
                      items:
                        type: object
                        allOf:
                          - type: object
                            properties:
                              banksId:
                                format: uuid
                                type: string
                              branch:
                                maxLength: 20
                                type: string
                              branchDigit:
                                maxLength: 5
                                type: string
                              account:
                                maxLength: 20
                                type: string
                              accountDigit:
                                maxLength: 5
                                type: string
                              accountType:
                                maxLength: 5
                                type: string
                              documentType:
                                maxLength: 10
                                default: CNPJ
                                type: string
                              documentNumber:
                                maxLength: 35
                                type: string
                              pixValue:
                                type: string
                              pixType:
                                type: string
                              isDefault:
                                type: boolean
                              isEscrow:
                                type: boolean
                              nickname:
                                anyOf:
                                  - maxLength: 50
                                    type: string
                                nullable: true
                            required:
                              - banksId
                              - branch
                              - account
                              - documentType
                              - documentNumber
                              - isDefault
                          - type: object
                            properties:
                              id:
                                format: uuid
                                type: string
                              banksId:
                                format: uuid
                                type: string
                              branch:
                                maxLength: 20
                                type: string
                              account:
                                maxLength: 20
                                type: string
                              accountType:
                                maxLength: 5
                                type: string
                              documentType:
                                maxLength: 10
                                default: CNPJ
                                type: string
                              documentNumber:
                                maxLength: 35
                                type: string
                              flag:
                                maxLength: 50
                                type: string
                              pixValue:
                                type: string
                              pixType:
                                type: string
                              isDefault:
                                type: boolean
                            required:
                              - branch
                              - account
                              - documentType
                              - documentNumber
                              - isDefault
                    address:
                      type: object
                      allOf:
                        - type: object
                          properties:
                            title:
                              maxLength: 255
                              type: string
                            street:
                              maxLength: 255
                              type: string
                            number:
                              maxLength: 20
                              type: string
                            complement:
                              maxLength: 255
                              type: string
                            neighborhood:
                              maxLength: 255
                              type: string
                            city:
                              maxLength: 255
                              type: string
                            state:
                              maxLength: 2
                              type: string
                            postalCode:
                              maxLength: 9
                              type: string
                        - type: object
                          properties:
                            id:
                              format: uuid
                              type: string
                          required:
                            - id
                    fees:
                      type: array
                      items:
                        type: object
                        allOf:
                          - type: object
                            properties:
                              feeType:
                                type: string
                                enum:
                                  - LatePaymentInterest
                                  - LatePaymentFine
                                  - CreditInterest
                                  - AdvanceInterest
                              percent:
                                type: number
                            required:
                              - feeType
                              - percent
                          - type: object
                            properties:
                              id:
                                format: uuid
                                type: string
                  required:
                    - bankAccounts
                    - address
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: assetHolderId
          required: true
      responses:
        "200":
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                allOf:
                  - type: object
                    properties:
                      id:
                        format: uuid
                        type: string
                      creditorsId:
                        format: uuid
                        type: string
                      name:
                        maxLength: 255
                        type: string
                      shortName:
                        maxLength: 150
                        default: ""
                        type: string
                      documentType:
                        maxLength: 10
                        default: CNPJ
                        type: string
                      documentNumber:
                        maxLength: 30
                        type: string
                      birthDate:
                        type: string
                      mainPhone:
                        maxLength: 50
                        type: string
                      mainEmail:
                        maxLength: 255
                        type: string
                      mainContact:
                        maxLength: 255
                        type: string
                      flag:
                        maxLength: 50
                        type: string
                      observation:
                        maxLength: 255
                        type: string
                      isActive:
                        type: boolean
                    required:
                      - id
                      - creditorsId
                      - name
                      - shortName
                      - documentType
                      - documentNumber
                      - isActive
                  - type: object
                    properties:
                      bankAccounts:
                        type: array
                        items:
                          type: object
                          allOf:
                            - type: object
                              properties:
                                id:
                                  format: uuid
                                  type: string
                                banksId:
                                  format: uuid
                                  type: string
                                branch:
                                  maxLength: 20
                                  type: string
                                branchDigit:
                                  maxLength: 5
                                  type: string
                                account:
                                  maxLength: 20
                                  type: string
                                accountDigit:
                                  maxLength: 5
                                  type: string
                                accountType:
                                  maxLength: 5
                                  type: string
                                documentType:
                                  maxLength: 10
                                  default: CNPJ
                                  type: string
                                documentNumber:
                                  maxLength: 35
                                  type: string
                                accountableId:
                                  format: uuid
                                  type: string
                                accountableType:
                                  maxLength: 255
                                  type: string
                                flag:
                                  maxLength: 50
                                  type: string
                                pixValue:
                                  type: string
                                pixType:
                                  type: string
                                isDefault:
                                  type: boolean
                                isActive:
                                  type: boolean
                                isEscrow:
                                  type: boolean
                                nickname:
                                  anyOf:
                                    - maxLength: 50
                                      type: string
                                  nullable: true
                              required:
                                - banksId
                                - branch
                                - account
                                - documentType
                                - documentNumber
                                - accountableId
                                - accountableType
                                - isDefault
                                - isActive
                            - type: object
                              properties:
                                banks:
                                  type: object
                                  allOf:
                                    - type: object
                                      properties:
                                        name:
                                          maxLength: 255
                                          type: string
                                        shortName:
                                          maxLength: 255
                                          type: string
                                        compeNumber:
                                          type: string
                                        isCompeParticipate:
                                          default: false
                                          type: boolean
                                        mainAccess:
                                          maxLength: 50
                                          type: string
                                        ispb:
                                          type: string
                                        isActive:
                                          default: false
                                          type: boolean
                                      required:
                                        - name
                                        - shortName
                                        - ispb
                                        - isActive
                                    - type: object
                                      properties:
                                        id:
                                          format: uuid
                                          type: string
                                      required:
                                        - id
                              required:
                                - banks
                      address:
                        type: object
                        properties:
                          id:
                            format: uuid
                            type: string
                          addressableId:
                            format: uuid
                            type: string
                          addressableType:
                            maxLength: 255
                            type: string
                          title:
                            maxLength: 255
                            type: string
                          street:
                            maxLength: 255
                            type: string
                          number:
                            maxLength: 20
                            type: string
                          complement:
                            maxLength: 255
                            type: string
                          neighborhood:
                            maxLength: 255
                            type: string
                          city:
                            maxLength: 255
                            type: string
                          state:
                            maxLength: 2
                            type: string
                          postalCode:
                            maxLength: 9
                            type: string
                        required:
                          - addressableId
                          - addressableType
                      fees:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              format: uuid
                              type: string
                            assetHoldersId:
                              format: uuid
                              type: string
                            feeType:
                              type: string
                              enum:
                                - LatePaymentInterest
                                - LatePaymentFine
                                - CreditInterest
                                - AdvanceInterest
                            percent:
                              type: number
                          required:
                            - id
                            - assetHoldersId
                            - feeType
                            - percent
        "400":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "500":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /v1/debtor-relations/:
    get:
      operationId: listDebtorRelationsV2
      summary: Listar relações comerciais
      tags:
        - Relações comerciais
      description: Lista relações do estabelecimento identificado por
        `assetHolderDocument` (CNPJ/CPF, somente dígitos ou formatado).
      parameters:
        - schema:
            minLength: 1
            type: string
          in: query
          name: assetHolderDocument
          required: true
      responses:
        "200":
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  relations:
                    type: array
                    items:
                      type: object
                      allOf:
                        - type: object
                          properties:
                            id:
                              type: string
                            debtorId:
                              type: string
                            registrarId:
                              type: string
                            assetHolderId:
                              type: string
                            paymentSchemeId:
                              type: string
                            isActive:
                              type: boolean
                          required:
                            - id
                            - debtorId
                            - registrarId
                            - assetHolderId
                            - paymentSchemeId
                            - isActive
                        - type: object
                          properties:
                            AssetHolder:
                              type: object
                              properties:
                                id:
                                  type: string
                                creditorsId:
                                  type: string
                                name:
                                  maxLength: 255
                                  type: string
                                shortName:
                                  anyOf:
                                    - maxLength: 150
                                      type: string
                                  nullable: true
                                documentType:
                                  maxLength: 10
                                  default: CNPJ
                                  type: string
                                documentNumber:
                                  maxLength: 30
                                  type: string
                                mainPhone:
                                  anyOf:
                                    - maxLength: 50
                                      type: string
                                  nullable: true
                                mainEmail:
                                  anyOf:
                                    - maxLength: 255
                                      type: string
                                  nullable: true
                                mainContact:
                                  anyOf:
                                    - maxLength: 255
                                      type: string
                                  nullable: true
                                flag:
                                  anyOf:
                                    - maxLength: 50
                                      type: string
                                  nullable: true
                                observation:
                                  anyOf:
                                    - maxLength: 255
                                      type: string
                                  nullable: true
                                isActive:
                                  type: boolean
                                deletedAt:
                                  anyOf:
                                    - type: string
                                      format: date-time
                                  nullable: true
                                createdAt:
                                  type: string
                                  format: date-time
                                updatedAt:
                                  type: string
                                  format: date-time
                              required:
                                - id
                                - creditorsId
                                - name
                                - shortName
                                - documentType
                                - documentNumber
                                - mainPhone
                                - mainEmail
                                - mainContact
                                - flag
                                - observation
                                - isActive
                                - deletedAt
                                - createdAt
                                - updatedAt
                            Debtors:
                              type: object
                              properties:
                                id:
                                  type: string
                                name:
                                  type: string
                                shortName:
                                  type: string
                                documentType:
                                  type: string
                                code:
                                  type: number
                                documentNumber:
                                  type: string
                                mainPhone:
                                  anyOf:
                                    - type: string
                                  nullable: true
                                mainEmail:
                                  anyOf:
                                    - type: string
                                  nullable: true
                                mainContact:
                                  anyOf:
                                    - type: string
                                  nullable: true
                                flag:
                                  anyOf:
                                    - type: string
                                  nullable: true
                                isActive:
                                  type: boolean
                                logoUri:
                                  anyOf:
                                    - type: string
                                  nullable: true
                                createdAt:
                                  type: string
                                  format: date-time
                                updatedAt:
                                  type: string
                                  format: date-time
                              required:
                                - id
                                - name
                                - shortName
                                - documentType
                                - code
                                - documentNumber
                                - mainPhone
                                - mainEmail
                                - mainContact
                                - flag
                                - isActive
                                - logoUri
                                - createdAt
                                - updatedAt
                            Registrars:
                              type: object
                              properties:
                                id:
                                  type: string
                                name:
                                  maxLength: 255
                                  type: string
                                documentNumber:
                                  anyOf:
                                    - maxLength: 35
                                      type: string
                                  nullable: true
                                flag:
                                  anyOf:
                                    - maxLength: 50
                                      type: string
                                  nullable: true
                                createdAt:
                                  type: string
                                  format: date-time
                                updatedAt:
                                  type: string
                                  format: date-time
                                isActive:
                                  type: boolean
                              required:
                                - id
                                - name
                                - documentNumber
                                - flag
                                - createdAt
                                - updatedAt
                                - isActive
                            PaymentScheme:
                              type: object
                              allOf:
                                - type: object
                                  properties:
                                    id:
                                      type: string
                                    description:
                                      anyOf:
                                        - type: string
                                      nullable: true
                                    isActive:
                                      type: boolean
                                    acronym:
                                      type: string
                                    isConnected:
                                      type: boolean
                                    createdAt:
                                      type: string
                                      format: date-time
                                    updatedAt:
                                      type: string
                                      format: date-time
                                  required:
                                    - id
                                    - description
                                    - isActive
                                    - acronym
                                    - createdAt
                                    - updatedAt
                                - type: object
                                  properties:
                                    brands:
                                      type: object
                                      properties:
                                        logoUri:
                                          anyOf:
                                            - type: string
                                          nullable: true
                                      required:
                                        - logoUri
                                  required:
                                    - brands
                            ScheduleRequests:
                              type: array
                              items:
                                type: object
                                properties:
                                  id:
                                    type: string
                                  assetHoldersId:
                                    type: string
                                  createdAt:
                                    type: string
                                    format: date-time
                                  updatedAt:
                                    type: string
                                    format: date-time
                                  initialExpectedSettlementDate:
                                    type: string
                                    format: date-time
                                  finalExpectedSettlementDate:
                                    type: string
                                    format: date-time
                                  assetHolders:
                                    type: object
                                    properties:
                                      id:
                                        type: string
                                      creditorsId:
                                        type: string
                                      name:
                                        maxLength: 255
                                        type: string
                                      shortName:
                                        anyOf:
                                          - maxLength: 150
                                            type: string
                                        nullable: true
                                      documentType:
                                        maxLength: 10
                                        default: CNPJ
                                        type: string
                                      documentNumber:
                                        maxLength: 30
                                        type: string
                                      mainPhone:
                                        anyOf:
                                          - maxLength: 50
                                            type: string
                                        nullable: true
                                      mainEmail:
                                        anyOf:
                                          - maxLength: 255
                                            type: string
                                        nullable: true
                                      mainContact:
                                        anyOf:
                                          - maxLength: 255
                                            type: string
                                        nullable: true
                                      flag:
                                        anyOf:
                                          - maxLength: 50
                                            type: string
                                        nullable: true
                                      observation:
                                        anyOf:
                                          - maxLength: 255
                                            type: string
                                        nullable: true
                                      isActive:
                                        type: boolean
                                      deletedAt:
                                        anyOf:
                                          - type: string
                                            format: date-time
                                        nullable: true
                                      createdAt:
                                        type: string
                                        format: date-time
                                      updatedAt:
                                        type: string
                                        format: date-time
                                    required:
                                      - id
                                      - creditorsId
                                      - name
                                      - shortName
                                      - documentType
                                      - documentNumber
                                      - mainPhone
                                      - mainEmail
                                      - mainContact
                                      - flag
                                      - observation
                                      - isActive
                                      - deletedAt
                                      - createdAt
                                      - updatedAt
                                  processes:
                                    type: array
                                    items:
                                      type: object
                                      properties:
                                        id:
                                          type: string
                                        key:
                                          maxLength: 50
                                          type: string
                                        type:
                                          maxLength: 255
                                          type: string
                                        creditorId:
                                          anyOf:
                                            - type: string
                                          nullable: true
                                        createdAt:
                                          type: string
                                          format: date-time
                                        updatedAt:
                                          type: string
                                          format: date-time
                                        lastUpdated:
                                          anyOf:
                                            - type: string
                                              format: date-time
                                          nullable: true
                                        scheduleRequestId:
                                          anyOf:
                                            - type: string
                                          nullable: true
                                      required:
                                        - id
                                        - key
                                        - type
                                        - creditorId
                                        - createdAt
                                        - updatedAt
                                        - lastUpdated
                                        - scheduleRequestId
                                  firstEmissionDate:
                                    anyOf:
                                      - type: string
                                        format: date-time
                                    nullable: true
                                  lastEmissionDate:
                                    anyOf:
                                      - type: string
                                        format: date-time
                                    nullable: true
                                required:
                                  - id
                                  - assetHoldersId
                                  - createdAt
                                  - updatedAt
                                  - initialExpectedSettlementDate
                                  - finalExpectedSettlementDate
                                  - assetHolders
                                  - processes
                                  - firstEmissionDate
                                  - lastEmissionDate
                          required:
                            - AssetHolder
                            - Debtors
                            - Registrars
                            - PaymentScheme
                            - ScheduleRequests
                required:
                  - relations
        "403":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "500":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createDebtorRelationV2
      summary: Criar relações comerciais
      tags:
        - Relações comerciais
      description: Cria relações entre devedor (credenciadora), registradora e
        portador de ativos para os arranjos informados.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                debtorId:
                  type: string
                assetHolderId:
                  type: string
                paymentSchemeIds:
                  minItems: 1
                  type: array
                  items:
                    type: string
                isActive:
                  type: boolean
              required:
                - debtorId
                - assetHolderId
                - paymentSchemeIds
        required: true
      responses:
        "201":
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  createdRelations:
                    type: array
                    items:
                      type: object
                      allOf:
                        - type: object
                          properties:
                            id:
                              type: string
                            debtorId:
                              type: string
                            registrarId:
                              type: string
                            assetHolderId:
                              type: string
                            paymentSchemeId:
                              type: string
                            isActive:
                              type: boolean
                          required:
                            - id
                            - debtorId
                            - registrarId
                            - assetHolderId
                            - paymentSchemeId
                            - isActive
                        - type: object
                          properties:
                            AssetHolder:
                              type: object
                              properties:
                                id:
                                  type: string
                                creditorsId:
                                  type: string
                                name:
                                  maxLength: 255
                                  type: string
                                shortName:
                                  anyOf:
                                    - maxLength: 150
                                      type: string
                                  nullable: true
                                documentType:
                                  maxLength: 10
                                  default: CNPJ
                                  type: string
                                documentNumber:
                                  maxLength: 30
                                  type: string
                                mainPhone:
                                  anyOf:
                                    - maxLength: 50
                                      type: string
                                  nullable: true
                                mainEmail:
                                  anyOf:
                                    - maxLength: 255
                                      type: string
                                  nullable: true
                                mainContact:
                                  anyOf:
                                    - maxLength: 255
                                      type: string
                                  nullable: true
                                flag:
                                  anyOf:
                                    - maxLength: 50
                                      type: string
                                  nullable: true
                                observation:
                                  anyOf:
                                    - maxLength: 255
                                      type: string
                                  nullable: true
                                isActive:
                                  type: boolean
                                deletedAt:
                                  anyOf:
                                    - type: string
                                      format: date-time
                                  nullable: true
                                createdAt:
                                  type: string
                                  format: date-time
                                updatedAt:
                                  type: string
                                  format: date-time
                              required:
                                - id
                                - creditorsId
                                - name
                                - shortName
                                - documentType
                                - documentNumber
                                - mainPhone
                                - mainEmail
                                - mainContact
                                - flag
                                - observation
                                - isActive
                                - deletedAt
                                - createdAt
                                - updatedAt
                            Debtors:
                              type: object
                              properties:
                                id:
                                  type: string
                                name:
                                  type: string
                                shortName:
                                  type: string
                                documentType:
                                  type: string
                                code:
                                  type: number
                                documentNumber:
                                  type: string
                                mainPhone:
                                  anyOf:
                                    - type: string
                                  nullable: true
                                mainEmail:
                                  anyOf:
                                    - type: string
                                  nullable: true
                                mainContact:
                                  anyOf:
                                    - type: string
                                  nullable: true
                                flag:
                                  anyOf:
                                    - type: string
                                  nullable: true
                                isActive:
                                  type: boolean
                                logoUri:
                                  anyOf:
                                    - type: string
                                  nullable: true
                                createdAt:
                                  type: string
                                  format: date-time
                                updatedAt:
                                  type: string
                                  format: date-time
                              required:
                                - id
                                - name
                                - shortName
                                - documentType
                                - code
                                - documentNumber
                                - mainPhone
                                - mainEmail
                                - mainContact
                                - flag
                                - isActive
                                - logoUri
                                - createdAt
                                - updatedAt
                            Registrars:
                              type: object
                              properties:
                                id:
                                  type: string
                                name:
                                  maxLength: 255
                                  type: string
                                documentNumber:
                                  anyOf:
                                    - maxLength: 35
                                      type: string
                                  nullable: true
                                flag:
                                  anyOf:
                                    - maxLength: 50
                                      type: string
                                  nullable: true
                                createdAt:
                                  type: string
                                  format: date-time
                                updatedAt:
                                  type: string
                                  format: date-time
                                isActive:
                                  type: boolean
                              required:
                                - id
                                - name
                                - documentNumber
                                - flag
                                - createdAt
                                - updatedAt
                                - isActive
                            PaymentScheme:
                              type: object
                              allOf:
                                - type: object
                                  properties:
                                    id:
                                      type: string
                                    description:
                                      anyOf:
                                        - type: string
                                      nullable: true
                                    isActive:
                                      type: boolean
                                    acronym:
                                      type: string
                                    isConnected:
                                      type: boolean
                                    createdAt:
                                      type: string
                                      format: date-time
                                    updatedAt:
                                      type: string
                                      format: date-time
                                  required:
                                    - id
                                    - description
                                    - isActive
                                    - acronym
                                    - createdAt
                                    - updatedAt
                                - type: object
                                  properties:
                                    brands:
                                      type: object
                                      properties:
                                        logoUri:
                                          anyOf:
                                            - type: string
                                          nullable: true
                                      required:
                                        - logoUri
                                  required:
                                    - brands
                          required:
                            - AssetHolder
                            - Debtors
                            - Registrars
                            - PaymentScheme
                required:
                  - createdRelations
        "400":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "409":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "500":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /v1/debtor-relations/{debtorRelationId}:
    patch:
      operationId: patchDebtorRelationV2
      summary: Atualizar status da relação comercial
      tags:
        - Relações comerciais
      description: Ativa ou desativa uma relação pelo identificador.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                isActive:
                  type: boolean
              required:
                - isActive
        required: true
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: debtorRelationId
          required: true
      responses:
        "200":
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
                  relation:
                    type: object
                    allOf:
                      - type: object
                        properties:
                          id:
                            type: string
                          debtorId:
                            type: string
                          registrarId:
                            type: string
                          assetHolderId:
                            type: string
                          paymentSchemeId:
                            type: string
                          isActive:
                            type: boolean
                        required:
                          - id
                          - debtorId
                          - registrarId
                          - assetHolderId
                          - paymentSchemeId
                          - isActive
                      - type: object
                        properties:
                          AssetHolder:
                            type: object
                            properties:
                              id:
                                type: string
                              creditorsId:
                                type: string
                              name:
                                maxLength: 255
                                type: string
                              shortName:
                                anyOf:
                                  - maxLength: 150
                                    type: string
                                nullable: true
                              documentType:
                                maxLength: 10
                                default: CNPJ
                                type: string
                              documentNumber:
                                maxLength: 30
                                type: string
                              mainPhone:
                                anyOf:
                                  - maxLength: 50
                                    type: string
                                nullable: true
                              mainEmail:
                                anyOf:
                                  - maxLength: 255
                                    type: string
                                nullable: true
                              mainContact:
                                anyOf:
                                  - maxLength: 255
                                    type: string
                                nullable: true
                              flag:
                                anyOf:
                                  - maxLength: 50
                                    type: string
                                nullable: true
                              observation:
                                anyOf:
                                  - maxLength: 255
                                    type: string
                                nullable: true
                              isActive:
                                type: boolean
                              deletedAt:
                                anyOf:
                                  - type: string
                                    format: date-time
                                nullable: true
                              createdAt:
                                type: string
                                format: date-time
                              updatedAt:
                                type: string
                                format: date-time
                            required:
                              - id
                              - creditorsId
                              - name
                              - shortName
                              - documentType
                              - documentNumber
                              - mainPhone
                              - mainEmail
                              - mainContact
                              - flag
                              - observation
                              - isActive
                              - deletedAt
                              - createdAt
                              - updatedAt
                          Debtors:
                            type: object
                            properties:
                              id:
                                type: string
                              name:
                                type: string
                              shortName:
                                type: string
                              documentType:
                                type: string
                              code:
                                type: number
                              documentNumber:
                                type: string
                              mainPhone:
                                anyOf:
                                  - type: string
                                nullable: true
                              mainEmail:
                                anyOf:
                                  - type: string
                                nullable: true
                              mainContact:
                                anyOf:
                                  - type: string
                                nullable: true
                              flag:
                                anyOf:
                                  - type: string
                                nullable: true
                              isActive:
                                type: boolean
                              logoUri:
                                anyOf:
                                  - type: string
                                nullable: true
                              createdAt:
                                type: string
                                format: date-time
                              updatedAt:
                                type: string
                                format: date-time
                            required:
                              - id
                              - name
                              - shortName
                              - documentType
                              - code
                              - documentNumber
                              - mainPhone
                              - mainEmail
                              - mainContact
                              - flag
                              - isActive
                              - logoUri
                              - createdAt
                              - updatedAt
                          Registrars:
                            type: object
                            properties:
                              id:
                                type: string
                              name:
                                maxLength: 255
                                type: string
                              documentNumber:
                                anyOf:
                                  - maxLength: 35
                                    type: string
                                nullable: true
                              flag:
                                anyOf:
                                  - maxLength: 50
                                    type: string
                                nullable: true
                              createdAt:
                                type: string
                                format: date-time
                              updatedAt:
                                type: string
                                format: date-time
                              isActive:
                                type: boolean
                            required:
                              - id
                              - name
                              - documentNumber
                              - flag
                              - createdAt
                              - updatedAt
                              - isActive
                          PaymentScheme:
                            type: object
                            allOf:
                              - type: object
                                properties:
                                  id:
                                    type: string
                                  description:
                                    anyOf:
                                      - type: string
                                    nullable: true
                                  isActive:
                                    type: boolean
                                  acronym:
                                    type: string
                                  isConnected:
                                    type: boolean
                                  createdAt:
                                    type: string
                                    format: date-time
                                  updatedAt:
                                    type: string
                                    format: date-time
                                required:
                                  - id
                                  - description
                                  - isActive
                                  - acronym
                                  - createdAt
                                  - updatedAt
                              - type: object
                                properties:
                                  brands:
                                    type: object
                                    properties:
                                      logoUri:
                                        anyOf:
                                          - type: string
                                        nullable: true
                                    required:
                                      - logoUri
                                required:
                                  - brands
                        required:
                          - AssetHolder
                          - Debtors
                          - Registrars
                          - PaymentScheme
                required:
                  - success
                  - message
                  - relation
        "403":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "500":
          description: Default Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
servers:
  - url: https://api-creditors-{env}.grana.ai
    variables:
      env:
        default: prod
        enum:
          - prod
          - sandbox
security:
  - bearerAuth: []
tags:
  - name: Agenda
    description: Consulta de agenda de recebíveis
  - name: Contrato
    description: Operações para criação e gerenciamento de contratos
  - name: Estabelecimento
    description: Cadastro e gestão de estabelecimentos (asset holders)
  - name: Relações comerciais
    description: Relações entre credenciadora, registradora e estabelecimento
