{
  "openapi": "3.0.3",
  "info": {
    "title": "LightAPI — API demonstrativa",
    "version": "1.0.0",
    "description": "API independente de simulações. Sem integração bancária real. Valores monetários em centavos no JSON e NUMERIC no PostgreSQL. Todas as entidades são isoladas pela empresa da credencial. Tokens expiram em uma hora. Operações de criação, formalização, assinatura, pagamento e cancelamento exigem idempotência; repetição devolve o resultado persistido. Correlacione requisições pelo header X-Request-Id. O cenário timeout retorna HTTP 504 controlado, sem aguardar nem escrever uma operação."
  },
  "servers": [
    {
      "url": "https://lightapi.appkippa.com.br",
      "description": "Ambiente demonstrativo publicado"
    },
    {
      "url": "http://127.0.0.1:8102",
      "description": "Ambiente local"
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "summary": "Verificar serviço e schema",
        "responses": {
          "200": {
            "description": "LightAPI conectada ao PostgreSQL."
          },
          "503": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/oauth/token": {
      "post": {
        "summary": "Obter token client credentials",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "client_id",
                  "client_secret"
                ],
                "properties": {
                  "client_id": {
                    "type": "string"
                  },
                  "client_secret": {
                    "type": "string",
                    "format": "password"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Token emitido.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "requestId"
                  ],
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "access_token": {
                          "type": "string"
                        },
                        "token_type": {
                          "type": "string",
                          "enum": [
                            "Bearer"
                          ]
                        },
                        "expires_in": {
                          "type": "integer",
                          "example": 3600
                        },
                        "scope": {
                          "type": "string"
                        }
                      }
                    },
                    "requestId": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/customers/{id}/contracts": {
      "get": {
        "summary": "Consultar contratos do cliente",
        "description": "Escopo necessário: contracts:read. Dados integralmente fictícios.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Operação concluída.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "requestId"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": true
                      }
                    },
                    "requestId": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/contracts/{id}/simulate": {
      "post": {
        "summary": "Simular negociação",
        "description": "Escopo necessário: negotiations:write. Dados integralmente fictícios.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Operação concluída.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "requestId"
                  ],
                  "properties": {
                    "data": {
                      "type": "object",
                      "required": [
                        "contractId",
                        "total",
                        "discount",
                        "down",
                        "count",
                        "due",
                        "installment",
                        "last",
                        "schedule"
                      ],
                      "properties": {
                        "contractId": {
                          "type": "string"
                        },
                        "customerId": {
                          "type": "string"
                        },
                        "payment": {
                          "enum": [
                            "cash",
                            "installments"
                          ]
                        },
                        "balance": {
                          "type": "integer",
                          "minimum": 0,
                          "description": "Valor em centavos de real (BRL)."
                        },
                        "total": {
                          "type": "integer",
                          "minimum": 0,
                          "description": "Valor em centavos de real (BRL)."
                        },
                        "discount": {
                          "type": "integer",
                          "minimum": 0,
                          "description": "Valor em centavos de real (BRL)."
                        },
                        "down": {
                          "type": "integer",
                          "minimum": 0,
                          "description": "Valor em centavos de real (BRL)."
                        },
                        "count": {
                          "type": "integer"
                        },
                        "due": {
                          "type": "string",
                          "format": "date"
                        },
                        "installment": {
                          "type": "integer",
                          "minimum": 0,
                          "description": "Valor em centavos de real (BRL)."
                        },
                        "last": {
                          "type": "integer",
                          "minimum": 0,
                          "description": "Valor em centavos de real (BRL)."
                        },
                        "schedule": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "sequence": {
                                "type": "integer"
                              },
                              "due": {
                                "type": "string",
                                "format": "date"
                              },
                              "amount": {
                                "type": "integer",
                                "minimum": 0,
                                "description": "Valor em centavos de real (BRL)."
                              },
                              "kind": {
                                "enum": [
                                  "down_payment",
                                  "installment"
                                ]
                              }
                            }
                          }
                        }
                      }
                    },
                    "requestId": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "payment",
                  "down",
                  "installments",
                  "due"
                ],
                "properties": {
                  "payment": {
                    "type": "string",
                    "enum": [
                      "cash",
                      "installments"
                    ]
                  },
                  "down": {
                    "type": "integer",
                    "minimum": 0,
                    "description": "Valor em centavos de real (BRL)."
                  },
                  "installments": {
                    "type": "integer",
                    "enum": [
                      1,
                      2,
                      3,
                      6,
                      12
                    ]
                  },
                  "due": {
                    "type": "string",
                    "format": "date",
                    "description": "Hoje até 90 dias à frente, America/Sao_Paulo."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/contracts/{id}/proposals": {
      "post": {
        "summary": "Criar proposta",
        "description": "Escopo necessário: negotiations:write. Dados integralmente fictícios.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9_.:-]+$"
            },
            "description": "Reutilize a mesma chave e corpo quando o resultado for desconhecido. Uma chave com corpo diferente retorna 409."
          }
        ],
        "responses": {
          "201": {
            "description": "Operação concluída.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "requestId"
                  ],
                  "properties": {
                    "data": {
                      "type": "object",
                      "additionalProperties": true
                    },
                    "requestId": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "payment",
                  "down",
                  "installments",
                  "due"
                ],
                "properties": {
                  "payment": {
                    "type": "string",
                    "enum": [
                      "cash",
                      "installments"
                    ]
                  },
                  "down": {
                    "type": "integer",
                    "minimum": 0,
                    "description": "Valor em centavos de real (BRL)."
                  },
                  "installments": {
                    "type": "integer",
                    "enum": [
                      1,
                      2,
                      3,
                      6,
                      12
                    ]
                  },
                  "due": {
                    "type": "string",
                    "format": "date",
                    "description": "Hoje até 90 dias à frente, America/Sao_Paulo."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/proposals/{id}": {
      "get": {
        "summary": "Consultar proposta",
        "description": "Escopo necessário: contracts:read. Dados integralmente fictícios.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Operação concluída.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "requestId"
                  ],
                  "properties": {
                    "data": {
                      "type": "object",
                      "additionalProperties": true
                    },
                    "requestId": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/proposals/{id}/formalize": {
      "post": {
        "summary": "Formalizar proposta pendente",
        "description": "Escopo necessário: negotiations:write. Dados integralmente fictícios.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9_.:-]+$"
            },
            "description": "Reutilize a mesma chave e corpo quando o resultado for desconhecido. Uma chave com corpo diferente retorna 409."
          }
        ],
        "responses": {
          "201": {
            "description": "Operação concluída.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "requestId"
                  ],
                  "properties": {
                    "data": {
                      "type": "object",
                      "additionalProperties": true
                    },
                    "requestId": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        }
      }
    },
    "/api/v1/agreements": {
      "get": {
        "summary": "Listar os últimos 100 acordos da empresa",
        "description": "Escopo necessário: agreements:read. Dados integralmente fictícios.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Operação concluída.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "requestId"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": true
                      }
                    },
                    "requestId": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agreements/{id}": {
      "get": {
        "summary": "Consultar acordo, parcelas e eventos",
        "description": "Escopo necessário: agreements:read. Dados integralmente fictícios.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Operação concluída.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "requestId"
                  ],
                  "properties": {
                    "data": {
                      "type": "object",
                      "additionalProperties": true
                    },
                    "requestId": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agreements/{id}/sign": {
      "post": {
        "summary": "Simular assinatura de acordo aguardando assinatura",
        "description": "Escopo necessário: agreements:write. Dados integralmente fictícios.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9_.:-]+$"
            },
            "description": "Reutilize a mesma chave e corpo quando o resultado for desconhecido. Uma chave com corpo diferente retorna 409."
          }
        ],
        "responses": {
          "200": {
            "description": "Operação concluída.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "requestId"
                  ],
                  "properties": {
                    "data": {
                      "type": "object",
                      "additionalProperties": true
                    },
                    "requestId": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        }
      }
    },
    "/api/v1/agreements/{id}/pay": {
      "post": {
        "summary": "Simular pagamento de acordo ativo",
        "description": "Escopo necessário: agreements:write. Dados integralmente fictícios.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9_.:-]+$"
            },
            "description": "Reutilize a mesma chave e corpo quando o resultado for desconhecido. Uma chave com corpo diferente retorna 409."
          }
        ],
        "responses": {
          "200": {
            "description": "Operação concluída.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "requestId"
                  ],
                  "properties": {
                    "data": {
                      "type": "object",
                      "additionalProperties": true
                    },
                    "requestId": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "amount"
                ],
                "properties": {
                  "amount": {
                    "type": "integer",
                    "minimum": 1,
                    "description": "Valor em centavos de real (BRL)."
                  },
                  "installmentId": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Opcional. Sem este campo, aloca nas parcelas por ordem, sem ultrapassar seus saldos."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agreements/{id}/cancel": {
      "post": {
        "summary": "Cancelar acordo sem pagamentos",
        "description": "Escopo necessário: agreements:write. Dados integralmente fictícios.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9_.:-]+$"
            },
            "description": "Reutilize a mesma chave e corpo quando o resultado for desconhecido. Uma chave com corpo diferente retorna 409."
          }
        ],
        "responses": {
          "200": {
            "description": "Operação concluída.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "requestId"
                  ],
                  "properties": {
                    "data": {
                      "type": "object",
                      "additionalProperties": true
                    },
                    "requestId": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "reason"
                ],
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 5,
                    "maxLength": 500
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agreements/{id}/document": {
      "get": {
        "summary": "Obter documento demonstrativo sem valor financeiro",
        "description": "Escopo necessário: agreements:read. Dados integralmente fictícios.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Operação concluída.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "requestId"
                  ],
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "contentType": {
                          "type": "string"
                        },
                        "filename": {
                          "type": "string"
                        },
                        "content": {
                          "type": "string"
                        }
                      }
                    },
                    "requestId": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Erro validado, sem detalhes internos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "opaque token"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          },
          "requestId": {
            "type": "string"
          }
        }
      },
      "Simulation": {
        "type": "object",
        "required": [
          "contractId",
          "total",
          "discount",
          "down",
          "count",
          "due",
          "installment",
          "last",
          "schedule"
        ],
        "properties": {
          "contractId": {
            "type": "string"
          },
          "customerId": {
            "type": "string"
          },
          "payment": {
            "enum": [
              "cash",
              "installments"
            ]
          },
          "balance": {
            "type": "integer",
            "minimum": 0,
            "description": "Valor em centavos de real (BRL)."
          },
          "total": {
            "type": "integer",
            "minimum": 0,
            "description": "Valor em centavos de real (BRL)."
          },
          "discount": {
            "type": "integer",
            "minimum": 0,
            "description": "Valor em centavos de real (BRL)."
          },
          "down": {
            "type": "integer",
            "minimum": 0,
            "description": "Valor em centavos de real (BRL)."
          },
          "count": {
            "type": "integer"
          },
          "due": {
            "type": "string",
            "format": "date"
          },
          "installment": {
            "type": "integer",
            "minimum": 0,
            "description": "Valor em centavos de real (BRL)."
          },
          "last": {
            "type": "integer",
            "minimum": 0,
            "description": "Valor em centavos de real (BRL)."
          },
          "schedule": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "sequence": {
                  "type": "integer"
                },
                "due": {
                  "type": "string",
                  "format": "date"
                },
                "amount": {
                  "type": "integer",
                  "minimum": 0,
                  "description": "Valor em centavos de real (BRL)."
                },
                "kind": {
                  "enum": [
                    "down_payment",
                    "installment"
                  ]
                }
              }
            }
          }
        }
      },
      "Terms": {
        "type": "object",
        "required": [
          "payment",
          "down",
          "installments",
          "due"
        ],
        "properties": {
          "payment": {
            "type": "string",
            "enum": [
              "cash",
              "installments"
            ]
          },
          "down": {
            "type": "integer",
            "minimum": 0,
            "description": "Valor em centavos de real (BRL)."
          },
          "installments": {
            "type": "integer",
            "enum": [
              1,
              2,
              3,
              6,
              12
            ]
          },
          "due": {
            "type": "string",
            "format": "date",
            "description": "Hoje até 90 dias à frente, America/Sao_Paulo."
          }
        }
      }
    }
  }
}
