{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/grainfinance-co/json-schema/grainfinance-co-create-vendor-request-schema.json",
  "title": "CreateVendorRequest",
  "description": "Request body for `POST /v1/vendors`. Creates a vendor with a single payout method. The conditional\ncontact fields (`contactState`, `contactTaxId`, `contactPhoneNumber`, `companyRegisterNumber`) are\nrequired for some countries.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/grainfinance-co-vendors-api-openapi.yml#/components/schemas/CreateVendorRequest",
  "properties": {
    "externalVendorId": {
      "$ref": "#/$defs/ExternalVendorId",
      "description": "The vendor id, as identified within your system."
    },
    "contactFullName": {
      "type": "string",
      "description": "The full name of the vendor's contact person or business."
    },
    "contactCountry": {
      "$ref": "#/$defs/CountryCode",
      "description": "The alpha-2 ISO 3166 country code of the vendor."
    },
    "contactCity": {
      "type": "string",
      "description": "The city of the vendor's address."
    },
    "contactEmail": {
      "type": "string",
      "description": "The email address of the vendor."
    },
    "contactStreetName": {
      "type": "string",
      "description": "The street name of the vendor's address."
    },
    "contactBuildingName": {
      "type": "string",
      "description": "The building name or number of the vendor's address."
    },
    "contactPostalCode": {
      "type": "string",
      "description": "The postal code of the vendor's address."
    },
    "contactState": {
      "type": "string",
      "description": "The ISO state code of the vendor's address. Required for vendors in US, CA, NZ and AU."
    },
    "contactTaxId": {
      "type": "string",
      "description": "The tax id of the vendor. Required for vendors in some countries."
    },
    "contactPhoneNumber": {
      "type": "string",
      "description": "The phone number of the vendor's contact. Required for vendors in some countries."
    },
    "companyRegisterNumber": {
      "type": "string",
      "description": "The company register number of the vendor. Required for vendors in some countries."
    },
    "payoutMethod": {
      "$ref": "#/$defs/VendorPayoutMethod",
      "description": "The payout method to register for the vendor."
    }
  },
  "required": [
    "externalVendorId",
    "contactFullName",
    "contactCountry",
    "contactCity",
    "contactEmail",
    "contactStreetName",
    "contactBuildingName",
    "contactPostalCode",
    "payoutMethod"
  ],
  "type": "object",
  "additionalProperties": false,
  "$defs": {
    "CountryCode": {
      "type": "string",
      "description": "The alpha-2 ISO 3166 country code of the entity's country.",
      "pattern": "^[A-Za-z]{2}$"
    },
    "CurrencyCode": {
      "type": "string",
      "description": "The alpha-3 ISO 4217 currency code of the related entity, in upper case.",
      "pattern": "^[A-Z]{3}$"
    },
    "DisplayPaymentMethod": {
      "enum": [
        "SWIFT",
        "SEPA",
        "WIRE",
        "ACH",
        "FPS",
        "CA ACSS",
        "NPP",
        "IBG",
        "BECS",
        "CCASS",
        "TEF",
        "UAEFTS",
        "SIC",
        "CERTIS",
        "DKSMC",
        "NICS",
        "SORBNET",
        "RIX",
        "SAMOS",
        "ZAHAV",
        "SARIE",
        "QPS"
      ],
      "type": "string"
    },
    "ExternalVendorId": {
      "type": "string",
      "description": "Partner's own reference ID for the vendor.",
      "pattern": "^[A-Za-z0-9_.\\-]{1,64}$"
    },
    "VendorPayoutMethod": {
      "description": "A payout method registered for the vendor — the bank account payouts in `currency` are sent to.\nBank account fields are corridor-specific: only the fields relevant to the method's currency,\ncountry, and type are returned.",
      "properties": {
        "type": {
          "$ref": "#/$defs/DisplayPaymentMethod",
          "description": "The payment method used to send payouts to this bank account."
        },
        "currency": {
          "$ref": "#/$defs/CurrencyCode",
          "description": "The alpha-3 ISO 4217 currency code of payouts sent with this method."
        },
        "bankName": {
          "type": "string",
          "description": "The name of the bank holding the account."
        },
        "bankCountry": {
          "$ref": "#/$defs/CountryCode",
          "description": "The alpha-2 ISO 3166 country code of the bank."
        },
        "bankState": {
          "type": "string",
          "description": "The ISO state code of the bank's location, when applicable."
        },
        "accountNumber": {
          "type": "string",
          "description": "The account number, when applicable."
        },
        "iban": {
          "type": "string",
          "description": "The IBAN of the account, when applicable.",
          "pattern": "^[A-Z0-9]{15,34}$"
        },
        "bicSwift": {
          "type": "string",
          "description": "The SWIFT/BIC code of the bank, when applicable.",
          "pattern": "^[A-Z]{6}[A-Z0-9]{2}([A-Z0-9]{3})?$"
        },
        "routingCode": {
          "type": "string",
          "description": "Country-specific routing code, when applicable — the nine-digit ABA routing number for USD payouts."
        },
        "bankCode": {
          "type": "string",
          "description": "Country-specific bank code, when applicable — CAD (EFT), HKD (CCASS), SGD (IBG) and MXN (SPEI) payouts."
        },
        "branchCode": {
          "type": "string",
          "description": "Country-specific branch code, when applicable — CAD (EFT), HKD (CCASS), SGD (IBG) and MXN (SPEI) payouts."
        },
        "sortCode": {
          "type": "string",
          "description": "UK sort code, when applicable. Six digits, no hyphens.",
          "pattern": "^\\d{6}$"
        },
        "bsbCode": {
          "type": "string",
          "description": "Australian BSB code, when applicable. Six digits, no hyphens.",
          "pattern": "^\\d{6}$"
        },
        "bankAddress": {
          "type": "string",
          "description": "The full address of the bank, when provided."
        }
      },
      "required": [
        "type",
        "currency",
        "bankName",
        "bankCountry"
      ],
      "type": "object",
      "additionalProperties": false
    }
  }
}