{
  "openapi": "3.0.1",
  "info": {
    "title": "Exchange API",
    "version": "v1"
  },
  "paths": {
    "/v1/exchange/ach_transactions": {
      "post": {
        "summary": "Creates an ACH transaction",
        "tags": [
          "ACH Transactions"
        ],
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "description": "Bearer Token",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "ACH transaction created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id"
                  ],
                  "properties": {
                    "id": {
                      "type": "string",
                      "pattern": "^[a-f0-9]{64}$",
                      "description": "A 64-character SHA256 hex ID"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "errors"
                  ],
                  "properties": {
                    "errors": {
                      "type": "array",
                      "maxItems": 50,
                      "items": {
                        "type": "object",
                        "required": [
                          "code",
                          "detail"
                        ],
                        "properties": {
                          "code": {
                            "type": "string"
                          },
                          "detail": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "422": {
            "description": "Invalid ACH transaction"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "achTransaction"
                ],
                "additionalProperties": false,
                "properties": {
                  "achTransaction": {
                    "type": "object",
                    "required": [
                      "companyId",
                      "traceId",
                      "amountCents",
                      "effectiveDate",
                      "transactionCode"
                    ],
                    "additionalProperties": false,
                    "properties": {
                      "companyId": {
                        "type": "string"
                      },
                      "traceId": {
                        "type": "string"
                      },
                      "amountCents": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "effectiveDate": {
                        "type": "string",
                        "format": "date"
                      },
                      "transactionCode": {
                        "type": "string",
                        "pattern": "^\\d{2}$"
                      },
                      "returnCode": {
                        "type": "string",
                        "pattern": "^R(0[1-9]|[1-9]\\d)$|^R[A-Z]$|^R[345]$"
                      },
                      "furnishingType": {
                        "type": "string",
                        "enum": [
                          "procured",
                          "exchange"
                        ]
                      },
                      "bankAccount": {
                        "type": "object",
                        "required": [
                          "number",
                          "routingNumber"
                        ],
                        "additionalProperties": false,
                        "properties": {
                          "number": {
                            "type": "string"
                          },
                          "routingNumber": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "required": true
        }
      }
    },
    "/v1/exchange/tradelines": {
      "post": {
        "summary": "Furnishes a tradeline report",
        "tags": [
          "Tradelines"
        ],
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "description": "Bearer Token",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Tradeline created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Tradeline ID"
                    }
                  },
                  "required": [
                    "id"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Exchange not enabled for organization",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "tradeline"
                ],
                "additionalProperties": false,
                "properties": {
                  "tradeline": {
                    "type": "object",
                    "required": [
                      "dateOfBirth",
                      "name",
                      "furnisher",
                      "account",
                      "status"
                    ],
                    "additionalProperties": false,
                    "properties": {
                      "dateOfBirth": {
                        "type": "string",
                        "format": "date",
                        "description": "Consumer date of birth in YYYY-MM-DD."
                      },
                      "name": {
                        "type": "object",
                        "required": [
                          "first",
                          "last"
                        ],
                        "additionalProperties": false,
                        "properties": {
                          "first": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "last": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "middle": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "generationalCode": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 16,
                            "description": "Suffix, e.g., JR, SR, II, III."
                          }
                        }
                      },
                      "address": {
                        "type": "object",
                        "required": [
                          "line1",
                          "city",
                          "state",
                          "postalCode"
                        ],
                        "additionalProperties": false,
                        "properties": {
                          "line1": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 128
                          },
                          "line2": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 128
                          },
                          "line3": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 128
                          },
                          "city": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "state": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 16
                          },
                          "postalCode": {
                            "type": "string",
                            "minLength": 3,
                            "maxLength": 16
                          }
                        }
                      },
                      "governmentId": {
                        "type": "object",
                        "required": [
                          "number",
                          "type"
                        ],
                        "additionalProperties": false,
                        "properties": {
                          "number": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 32
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "social_security_number"
                            ]
                          }
                        }
                      },
                      "bankAccount": {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                          "number": {
                            "type": "string",
                            "nullable": true,
                            "maxLength": 32,
                            "description": "Bank account number."
                          },
                          "routingNumber": {
                            "type": "string",
                            "nullable": true,
                            "maxLength": 32,
                            "description": "Routing number."
                          },
                          "revokedOn": {
                            "type": "string",
                            "nullable": true,
                            "format": "date",
                            "description": "Date the consumer revoked ACH debit authorization (YYYY-MM-DD)."
                          }
                        }
                      },
                      "furnisher": {
                        "type": "object",
                        "required": [
                          "companyId"
                        ],
                        "additionalProperties": false,
                        "properties": {
                          "companyId": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64,
                            "description": "Internal identifier for the furnishing company."
                          }
                        }
                      },
                      "account": {
                        "type": "object",
                        "required": [
                          "accountNumber",
                          "dateOpened",
                          "dateReported",
                          "currentBalance",
                          "terms"
                        ],
                        "additionalProperties": false,
                        "properties": {
                          "accountNumber": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "portfolioType": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8,
                            "description": "Optional. Defaults to the furnisher's portfolio lender_bucket if omitted."
                          },
                          "accountType": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 32,
                            "description": "Optional. Defaults to the furnisher's portfolio tradeline_type (or \"01\") if omitted."
                          },
                          "dateOpened": {
                            "type": "string",
                            "format": "date"
                          },
                          "dateReported": {
                            "type": "string",
                            "format": "date"
                          },
                          "firstDueDate": {
                            "type": "string",
                            "format": "date"
                          },
                          "terms": {
                            "type": "object",
                            "required": [
                              "termFrequency",
                              "termLength"
                            ],
                            "additionalProperties": false,
                            "properties": {
                              "termFrequency": {
                                "type": "string",
                                "enum": [
                                  "W",
                                  "B",
                                  "S",
                                  "M"
                                ]
                              },
                              "termLength": {
                                "type": "integer",
                                "minimum": 1,
                                "maximum": 1000
                              },
                              "termUnit": {
                                "type": "string"
                              },
                              "scheduledPaymentAmount": {
                                "description": "Payment amount. Accepts integer or string."
                              }
                            }
                          },
                          "originalAmount": {
                            "type": "integer",
                            "minimum": 0,
                            "description": "Whole dollar amount."
                          },
                          "highCredit": {
                            "type": "integer",
                            "minimum": 0,
                            "description": "Whole dollar amount."
                          },
                          "currentBalance": {
                            "type": "integer",
                            "minimum": 0,
                            "description": "Whole dollar amount."
                          },
                          "amountPastDue": {
                            "type": "integer",
                            "minimum": 0,
                            "description": "Whole dollar amount."
                          },
                          "dateOfFirstDelinquency": {
                            "type": "string",
                            "format": "date"
                          }
                        }
                      },
                      "status": {
                        "type": "object",
                        "required": [
                          "asOfDate",
                          "accountStatus"
                        ],
                        "additionalProperties": false,
                        "properties": {
                          "asOfDate": {
                            "type": "string",
                            "format": "date"
                          },
                          "accountStatus": {
                            "type": "string",
                            "enum": [
                              "open",
                              "past_due",
                              "charged_off",
                              "paid_off",
                              "closed"
                            ],
                            "description": "Account status. Must be one of the Genoa domain values."
                          },
                          "missedPayments": {
                            "type": "array",
                            "items": {
                              "type": "integer",
                              "enum": [
                                1,
                                2,
                                3
                              ]
                            },
                            "uniqueItems": true
                          },
                          "missedPmt1": {
                            "type": "boolean"
                          },
                          "missedPmt2": {
                            "type": "boolean"
                          },
                          "missedPmt3": {
                            "type": "boolean"
                          },
                          "firstDueDate": {
                            "type": "string",
                            "format": "date"
                          },
                          "amountPastDue": {
                            "type": "integer",
                            "minimum": 0,
                            "description": "Whole dollar amount."
                          },
                          "firstPaymentDefault": {
                            "type": "boolean"
                          },
                          "noPay": {
                            "type": "boolean"
                          }
                        }
                      },
                      "paymentHistory": {
                        "type": "object",
                        "required": [
                          "startDate",
                          "history"
                        ],
                        "additionalProperties": false,
                        "properties": {
                          "startDate": {
                            "type": "string",
                            "pattern": "^[0-9]{4}-(0[1-9]|1[0-2])$"
                          },
                          "history": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 60,
                            "pattern": "^[0-9A-Z]+$"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "required": true
        }
      }
    }
  },
  "components": {
    "schemas": {},
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  },
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "x-tagGroups": [
    {
      "name": "Exchange",
      "tags": [
        "ACH Transactions",
        "Tradelines"
      ]
    }
  ],
  "servers": [
    {
      "url": "https://api.sandbox.congruitcredit.com",
      "description": "Sandbox Environment"
    },
    {
      "url": "https://api.congruitcredit.com",
      "description": "Production Environment"
    }
  ]
}