{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/atlar/json-schema/atlar-create-counterparty-request-schema.json",
  "title": "CreateCounterpartyRequest",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/atlar-counterparties-api-openapi.yml#/components/schemas/CreateCounterpartyRequest",
  "type": "object",
  "properties": {
    "legalName": {
      "description": "Legal name of the counterparty. E.g. a company's legal business name, or an individual's full legal name.",
      "type": "string",
      "maxLength": 96
    },
    "alias": {
      "description": "An additional name, an alias, for the counterparty.",
      "type": "string",
      "maxLength": 255
    },
    "partyType": {
      "$ref": "#/$defs/PartyType"
    },
    "address": {
      "description": "Address details for the counterparty.",
      "$ref": "#/$defs/Address"
    },
    "email": {
      "description": "Email of the counterparty.",
      "type": "string",
      "maxLength": 256
    },
    "phone": {
      "description": "Phone number of the counterparty.",
      "type": "string",
      "maxLength": 64
    },
    "accounts": {
      "type": "array",
      "description": "An optional list of external accounts to create for this counterparty. Note that external account is a separate API resource. One counterparty can have multiple external accounts.",
      "items": {
        "$ref": "#/$defs/CreateEmbeddedExternalAccountRequest"
      },
      "x-omitempty": true
    },
    "externalId": {
      "$ref": "#/$defs/ExternalID"
    },
    "metadata": {
      "$ref": "#/$defs/Metadata"
    },
    "nationalIdentifier": {
      "description": "The national identifier of the counterparty.",
      "$ref": "#/$defs/NationalIdentifier"
    },
    "entityIds": {
      "type": "array",
      "description": "An optional list of entity IDs that this counterparty belongs to. If empty, the counterparty is not associated with any specific entity and can be used by all in the organization.",
      "items": {
        "$ref": "#/$defs/ResourceID"
      },
      "maxItems": 100,
      "uniqueItems": true,
      "x-omitempty": true
    }
  },
  "required": [
    "legalName"
  ],
  "$defs": {
    "AccountIdentifier": {
      "type": "object",
      "properties": {
        "type": {
          "$ref": "#/$defs/AccountIdentifierType"
        },
        "market": {
          "$ref": "#/$defs/MarketCode",
          "description": "The market of the `AccountIdentifier` specifies in which market-context the identifier should be treated.\n\nA `NUMBER` from Sweden does not look and does not validate in the same way as a `NUMBER` from GB. The market\ncode is, in most cases, the same as where the account itself is domiciled, but not necessarily. An examples\nof this discrepancy is Jersey which may have domiciled accounts with market `JE`, but the account identifier\nwould be an `IBAN` with country code `GB`."
        },
        "number": {
          "type": "string",
          "description": "The unformatted identifier itself. For type `NUMBER` the structure of the account number is country-specific.",
          "minLength": 1,
          "maxLength": 255
        },
        "invalid": {
          "type": "boolean",
          "description": "Will be `true` if the account identifier is invalid according to Atlar account identifier validation rules.",
          "readOnly": true
        }
      },
      "required": [
        "type",
        "market",
        "number"
      ]
    },
    "AccountIdentifierType": {
      "type": "string",
      "enum": [
        "IBAN",
        "NUMBER",
        "ADYEN",
        "AU_BPAY_BILLER_CODE",
        "DK_FIK",
        "INVESTMENT_NUMBER",
        "NATIONAL_ID_NUMBER",
        "PAYPAL",
        "PROPRIETARY",
        "SE_BANKGIRO",
        "SE_PLUSGIRO",
        "SOLDO",
        "WALLET_ADYEN_BALANCE_PLATFORM",
        "WALLET_AIRWALLEX",
        "WALLET_AIRWALLEX_NUMBER",
        "WALLET_CURRENCYCLOUD",
        "WALLET_FLASH_PAYMENTS",
        "WALLET_FREEMARKET",
        "WALLET_HYPERWALLET",
        "WALLET_INPAY",
        "WALLET_LEAD",
        "WALLET_MERCURY",
        "WALLET_MONEYCORP",
        "WALLET_PAYHAWK",
        "WALLET_REVOLUT",
        "WALLET_SKRILL",
        "WALLET_STRIPE",
        "WALLET_SWISSQUOTE",
        "WALLET_UNIT"
      ],
      "description": "Account Identifier type. Choose among:\n<ul>\n<li><code>IBAN</code> — IBAN</li>\n<li><code>NUMBER</code> — Account number</li>\n<li><code>ADYEN</code> — Adyen identifier</li>\n<li><code>AU_BPAY_BILLER_CODE</code> — Australian BPAY Biller Code</li>\n<li><code>DK_FIK</code> — FIK creditor number</li>\n<li><code>INVESTMENT_NUMBER</code> — Investment number</li>\n<li><code>NATIONAL_ID_NUMBER</code> — National Identification Number</li>\n<li><code>PAYPAL</code> — PayPal wallet identifier</li>\n<li><code>PROPRIETARY</code> — Proprietary identifier</li>\n<li><code>SE_BANKGIRO</code> — <a href=\"https://www.bankgirot.se/en/\">Bankgiro number</a></li>\n<li><code>SE_PLUSGIRO</code> — <a href=\"https://www.nordea.se/foretag/produkter/betala/plusgirot.html\">Plusgiro number</a></li>\n<li><code>SOLDO</code> — Soldo entity identifier</li>\n<li><code>WALLET_ADYEN_BALANCE_PLATFORM</code> — Adyen balance platform wallet identifier</li>\n<li><code>WALLET_AIRWALLEX</code> — Airwallex wallet identifier</li>\n<li><code>WALLET_AIRWALLEX_NUMBER</code> — Airwallex account number</li>\n<li><code>WALLET_CURRENCYCLOUD</code> — Currencycloud wallet identifier</li>\n<li><code>WALLET_FLASH_PAYMENTS</code> — Flash Payments wallet identifier</li>\n<li><code>WALLET_FREEMARKET</code> — Freemarket wallet identifier</li>\n<li><code>WALLET_HYPERWALLET</code> — Hyperwallet wallet identifier</li>\n<li><code>WALLET_INPAY</code> — Inpay account identifier</li>\n<li><code>WALLET_LEAD</code> — Lead wallet identifier</li>\n<li><code>WALLET_MERCURY</code> — Mercury wallet identifier</li>\n<li><code>WALLET_MONEYCORP</code> — Moneycorp wallet identifier</li>\n<li><code>WALLET_PAYHAWK</code> — Payhawk wallet identifier</li>\n<li><code>WALLET_REVOLUT</code> — Revolut wallet identifier</li>\n<li><code>WALLET_SKRILL</code> — Skrill wallet identifier</li>\n<li><code>WALLET_STRIPE</code> — Stripe wallet identifier</li>\n<li><code>WALLET_SWISSQUOTE</code> — Swissquote wallet identifier</li>\n<li><code>WALLET_UNIT</code> — Unit wallet identifier</li>\n</ul>\nFor further information please refer to <a href=\"https://docs.atlar.com/v2.0/docs/payment-details#account-identifiers\">Account Identifiers</a>"
    },
    "Address": {
      "description": "Postal address.",
      "type": "object",
      "properties": {
        "country": {
          "$ref": "#/$defs/CountryCode",
          "x-go-type-skip-optional-pointer": true
        },
        "countrySubdivision": {
          "$ref": "#/$defs/CountrySubdivision",
          "x-go-type-skip-optional-pointer": true
        },
        "city": {
          "type": "string",
          "maxLength": 64
        },
        "postalCode": {
          "type": "string",
          "maxLength": 16
        },
        "streetName": {
          "type": "string",
          "maxLength": 64
        },
        "streetNumber": {
          "type": "string",
          "maxLength": 16
        }
      }
    },
    "CountryCode": {
      "type": "string",
      "description": "Two-letter ISO 3166-1 alpha2 country code.",
      "minLength": 2,
      "maxLength": 2,
      "pattern": "^[A-Z]{2,2}$"
    },
    "CountrySubdivision": {
      "type": "string",
      "description": "Country subdivision code (second part of the ISO 3166-2 code).\nE.g. state code `CA` for the state of California in the USA, `ON` for the province of Ontario in Canada, `NSW` for the state of New South Wales in Australia.\nISO 3166-2 codes can be found on the ISO website, for example, for the USA: https://www.iso.org/obp/ui/#iso:code:3166:US.\nIn the USA the state code is required for domestic payments, in Canada the province code is required for domestic payments.",
      "maxLength": 6,
      "pattern": "^[A-Z]{2,2}-[A-Z0-9]{1,3}$"
    },
    "CreateEmbeddedExternalAccountRequest": {
      "type": "object",
      "properties": {
        "market": {
          "$ref": "#/$defs/MarketCode"
        },
        "identifiers": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/AccountIdentifier"
          },
          "minItems": 1,
          "maxItems": 1,
          "uniqueItems": true
        },
        "routing": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/RoutingIdentifier"
          },
          "maxItems": 5,
          "uniqueItems": true,
          "x-omitempty": true
        },
        "alias": {
          "description": "An additional name, an alias, for the account.",
          "type": "string",
          "maxLength": 255
        },
        "externalId": {
          "$ref": "#/$defs/ExternalID"
        },
        "metadata": {
          "$ref": "#/$defs/Metadata"
        }
      },
      "required": [
        "market",
        "identifiers"
      ]
    },
    "ExternalID": {
      "type": "string",
      "pattern": "^[a-zA-Z0-9._\\-+=]{1,64}$",
      "description": "External ID is optional to use, but if used, the Atlar platform will persist it, index it, as well as require it to be unique across all resources. It is possible to retrieve a resource using the external ID using the prefix `external:`.",
      "x-omitempty": true
    },
    "MarketCode": {
      "type": "string",
      "description": "Two-letter ISO 3166-1 alpha2 country code.",
      "minLength": 2,
      "maxLength": 2,
      "pattern": "^[A-Z]{2,2}$"
    },
    "Metadata": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": {
        "type": "string"
      },
      "description": "Metadata is a `string-string` key-value container that\ncan be used to store information known at the time of resource\ncreation. This can be retrieved later on, for instance when a\npayment or expected transaction is reconciled with the booked\ntransaction on the bank statement.\n\nMetadata can have at most 20 entries. Keys may have a\nmaximum length of 64 chars and values a maximum length of 512\nchars.\n\nBy default, this field is optional. It is possible to make it\nrequired in the Atlar Dashboard by visiting the [Metadata keys\npage](https://app.atlar.com/metadata-keys). Requirement rules\ncan be specified per API resource. Both the Dashboard and the\nAPI will then enforce these rules and give validation errors\nwhen the required fields are not set.",
      "maxProperties": 20,
      "x-omitempty": true
    },
    "NationalIdentifier": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "description": "Type of the national identifier.",
          "enum": [
            "CIVIC",
            "COMPANY"
          ]
        },
        "market": {
          "$ref": "#/$defs/MarketCode"
        },
        "number": {
          "type": "string",
          "description": "The identifier itself."
        }
      },
      "required": [
        "type",
        "market",
        "number"
      ]
    },
    "PartyType": {
      "type": "string",
      "description": "The legal type of a party",
      "enum": [
        "INDIVIDUAL",
        "COMPANY"
      ]
    },
    "ResourceID": {
      "type": "string",
      "description": "Unique resource identifier.",
      "minLength": 32,
      "maxLength": 64
    },
    "RoutingConstraints": {
      "description": "Constraints on a `RoutingIdentifier`.",
      "type": "object",
      "properties": {
        "accountNumberType": {
          "$ref": "#/$defs/AccountIdentifierType",
          "x-go-type-skip-optional-pointer": true
        },
        "scheme": {
          "type": "string"
        }
      }
    },
    "RoutingIdentifier": {
      "type": "object",
      "properties": {
        "type": {
          "$ref": "#/$defs/RoutingIdentifierType"
        },
        "number": {
          "type": "string",
          "description": "The form of the routing number depends on `type`. E.g. for `BIC` the value should be an 8 or 11 character BIC/SWIFT code. For `GB_DSC` (UK domestic routing) the value should be a six digit sort code.",
          "minLength": 1,
          "maxLength": 255
        },
        "invalid": {
          "type": "boolean",
          "description": "Will be `true` if the routing identifier is invalid according to Atlar validation rules.",
          "readOnly": true
        },
        "constraints": {
          "$ref": "#/$defs/RoutingConstraints"
        }
      },
      "required": [
        "type",
        "number"
      ]
    },
    "RoutingIdentifierType": {
      "type": "string",
      "enum": [
        "BIC",
        "AT_BLZ",
        "AU_BSB",
        "BD_BRN",
        "BR_BRANCH",
        "BR_COMPE",
        "BR_ISP",
        "CA_CPA",
        "CH_BCC",
        "CH_SIC",
        "CL_SBIF",
        "CN_APS",
        "CZ_NBC",
        "DE_BLZ",
        "ES_NCC",
        "GB_DSC",
        "GR_BIC",
        "HK_NCC",
        "IE_NCC",
        "IL_NCC",
        "IN_FSC",
        "IT_NCC",
        "JP_ZGN",
        "KR_BOK",
        "KR_KFTC",
        "MX_ABM",
        "MY_NCC",
        "NZ_NCC",
        "PH_BRSTN",
        "PL_KNR",
        "PT_NCC",
        "RU_CBC",
        "SE_SBA",
        "SG_IBG",
        "TH_CBC",
        "TW_NCC",
        "US_ABA",
        "US_PID",
        "VN_CITAD",
        "ZA_NCC"
      ],
      "description": "A routing identifier of type `BIC` must be provided to support cross-border/SWIFT payments."
    }
  }
}