openapi: 3.0.0
info:
  title: API Webhook - Core-Banking - Consent
  description: >-
    API para notificação de alteração de status de consentimentos de
    compartilhamento de dados (fase 2 do Open Finance Brasil).
  version: 1.0.0
servers:
  - url: https://seu-dominio-core-banking
components:
  schemas: {}
  parameters: {}
paths:
  /consent/webhook:
    post:
      description: >-
        Esta rota deve ser disponibilizada do lado do núcleo financeiro para
        receber notificações de alteração de status de consentimentos de
        compartilhamento de dados (fase 2).
      tags:
        - Webhook Consent
      summary: Notificação de alteração de status de consentimento
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                event:
                  type: string
                  enum:
                    - SD_CONSENT_CREATED
                    - SD_CONSENT_AUTHORISED
                    - SD_CONSENT_REJECTED
                    - SD_CONSENT_REVOKED
                    - SD_CONSENT_EXTENDED
                  description: >-
                    Tipo do evento de consentimento:


                    SD_CONSENT_CREATED - Consentimento criado (status
                    AWAITING_AUTHORISATION).


                    SD_CONSENT_AUTHORISED - Consentimento autorizado pelo
                    usuário.


                    SD_CONSENT_REJECTED - Consentimento rejeitado antes de ser
                    autorizado.


                    SD_CONSENT_REVOKED - Consentimento revogado após
                    autorização.


                    SD_CONSENT_EXTENDED - Data de expiração do consentimento
                    estendida.
                consent:
                  type: object
                  properties:
                    consentId:
                      type: string
                      example: urn:bancoex:C1DD33123
                    creationDateTime:
                      type: string
                      nullable: true
                    expirationDateTime:
                      type: string
                      nullable: true
                    statusUpdateDateTime:
                      type: string
                      nullable: true
                    status:
                      type: string
                      enum:
                        - AWAITING_AUTHORISATION
                        - AUTHORISED
                        - REJECTED
                        - CONSUMED
                    internalStatus:
                      type: string
                      enum:
                        - PENDING
                        - ACTIVE
                        - REJECTED
                        - EXPIRED
                        - CLOSED
                    version:
                      type: string
                      enum:
                        - v1
                        - v2
                    loggedUser:
                      type: object
                      properties:
                        document:
                          type: object
                          properties:
                            identification:
                              type: string
                              example: '76109277673'
                            rel:
                              type: string
                              enum: &ref_0
                                - CPF
                                - CNPJ
                          required:
                            - identification
                            - rel
                      required:
                        - document
                    brandCreditor:
                      type: object
                      properties:
                        brandName:
                          type: string
                          example: Banco Exemplo
                        brandId:
                          type: string
                          example: bank-id-123
                        logoUri:
                          type: string
                          example: https://exemplo.com/logo.png
                    resources:
                      type: array
                      items:
                        type: object
                        properties:
                          resourceId:
                            type: string
                            example: CONSENTIMENTO_NAO_ENCONTRADO
                          resourceType:
                            type: string
                            enum:
                              - ACCOUNT
                              - CREDIT_CARD_ACCOUNT
                              - LOAN
                              - FINANCING
                              - UNARRANGED_ACCOUNT_OVERDRAFT
                              - INVOICE_FINANCING
                              - BANK_FIXED_INCOME
                              - CREDIT_FIXED_INCOME
                              - FUND
                              - VARIABLE_INCOME
                              - TREASURE_TITLE
                              - EXCHANGE
                          status:
                            type: string
                            enum:
                              - AVAILABLE
                              - UNAVAILABLE
                              - TEMPORARILY_UNAVAILABLE
                              - PENDING_AUTHORISATION
                        required:
                          - resourceId
                          - resourceType
                          - status
                    businessEntity:
                      type: object
                      properties:
                        document:
                          type: object
                          properties:
                            identification:
                              type: string
                              example: '76109277673'
                            rel:
                              type: string
                              enum: *ref_0
                          required:
                            - identification
                            - rel
                      required:
                        - document
                    partners:
                      type: array
                      items:
                        type: object
                        properties:
                          document:
                            type: string
                          identification:
                            type: string
                          name:
                            type: string
                          status:
                            type: string
                            enum:
                              - AWAITING_AUTHORISATION
                              - AUTHORISED
                        required:
                          - document
                          - name
                          - status
                    journey:
                      type: object
                      properties:
                        isLinked:
                          type: boolean
                        linkId:
                          type: string
                          nullable: true
                      required:
                        - isLinked
                    rejection:
                      type: object
                      properties:
                        rejectedBy:
                          type: string
                        reason:
                          type: object
                          properties:
                            code:
                              type: string
                            additionalInformation:
                              type: string
                          required:
                            - code
                            - additionalInformation
                      required:
                        - rejectedBy
                        - reason
                    dateApprovalConsent:
                      type: string
                      nullable: true
                    dateRevokeConsent:
                      type: string
                      nullable: true
                  required:
                    - consentId
                    - creationDateTime
                    - status
                    - internalStatus
                    - loggedUser
                    - resources
              required:
                - event
                - consent
      responses:
        '204':
          description: Notificação recebida com sucesso.
