{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/meld/json-schema/meld-headless-order-offramp-request-schema.json",
  "title": "HeadlessOrderOfframpRequest",
  "description": "Request to create a headless offramp order",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/meld-headless-api-openapi.yml#/components/schemas/HeadlessOrderOfframpRequest",
  "type": "object",
  "properties": {
    "customerId": {
      "type": "string",
      "description": "Customer id",
      "minLength": 1
    },
    "destinationCurrencyCode": {
      "type": "string",
      "description": "Destination fiat currency code",
      "minLength": 1
    },
    "externalSubaccountCustomerId": {
      "type": "string",
      "description": "Optional external identifier for the sub-account customer this transaction belongs to. Used for tracking when multiple businesses operate under one Meld account. A sub-account customer must be created first before it can be referenced."
    },
    "fiatPayoutMethod": {
      "description": "Payout method details for how and where the fiat currency will be received",
      "allOf": [
        {
          "$ref": "#/$defs/FiatPayoutMethod"
        }
      ]
    },
    "serviceProvider": {
      "type": "string",
      "description": "Service provider to use for this offramp order",
      "enum": [
        "NOAH",
        "DUENETWORK",
        "BRALE",
        "YELLOWCARD"
      ]
    },
    "sourceAmount": {
      "type": "number",
      "description": "Source amount in cryptocurrency",
      "minimum": 0.0
    },
    "sourceCurrencyCode": {
      "type": "string",
      "description": "Source cryptocurrency code",
      "minLength": 1
    },
    "sourceWalletAddress": {
      "type": "string",
      "description": "Source wallet address to send cryptocurrency from",
      "minLength": 1
    },
    "subaccountCustomerId": {
      "type": "string",
      "description": "Optional Meld customer id used to track the business sub-account this transaction belongs to when multiple businesses operate under one Meld account."
    }
  },
  "required": [
    "customerId",
    "destinationCurrencyCode",
    "fiatPayoutMethod",
    "serviceProvider",
    "sourceAmount",
    "sourceCurrencyCode",
    "sourceWalletAddress"
  ],
  "$defs": {
    "AchPaymentMethodDetails": {
      "allOf": [
        {
          "$ref": "#/$defs/FiatPayoutMethodDetails"
        },
        {
          "type": "object",
          "properties": {
            "bankName": {
              "type": "string",
              "description": "Bank's name"
            },
            "accountType": {
              "type": "string",
              "description": "Bank account type",
              "minLength": 1
            },
            "routingNumber": {
              "type": "string",
              "description": "Bank routing number",
              "minLength": 1
            },
            "accountNumber": {
              "type": "string",
              "description": "Bank account number",
              "minLength": 1
            },
            "beneficiaryAddress": {
              "description": "Beneficiary's address",
              "allOf": [
                {
                  "$ref": "#/$defs/Address"
                }
              ]
            },
            "bankAddress": {
              "description": "Bank address",
              "allOf": [
                {
                  "$ref": "#/$defs/Address"
                }
              ]
            }
          }
        }
      ],
      "description": "Payout method details for ACH / PAYOUT_TO_BANK / NG_BANK_TRANSFER / ZA_BANK_TRANSFER",
      "required": [
        "accountNumber",
        "accountType",
        "bankAddress",
        "beneficiaryAddress",
        "routingNumber"
      ]
    },
    "Address": {
      "type": "object",
      "description": "Address information",
      "properties": {
        "city": {
          "type": "string",
          "description": "City",
          "minLength": 1
        },
        "country": {
          "type": "string",
          "description": "Two-letter country code (ISO 3166-1 alpha-2)",
          "minLength": 1
        },
        "postalCode": {
          "type": "string",
          "description": "Postal code",
          "minLength": 1
        },
        "state": {
          "type": "string",
          "description": "State"
        },
        "streetLineOne": {
          "type": "string",
          "description": "Street line 1",
          "minLength": 1
        },
        "streetLineTwo": {
          "type": "string",
          "description": "Street line 2"
        }
      },
      "required": [
        "city",
        "country",
        "postalCode",
        "streetLineOne"
      ]
    },
    "FiatPayoutMethod": {
      "type": "object",
      "description": "Payout method for offramp",
      "properties": {
        "details": {
          "description": "Payout method details",
          "oneOf": [
            {
              "title": "AchPaymentMethodDetails",
              "allOf": [
                {
                  "$ref": "#/$defs/AchPaymentMethodDetails"
                }
              ]
            },
            {
              "title": "MobilePaymentMethodDetails",
              "allOf": [
                {
                  "$ref": "#/$defs/MobilePaymentMethodDetails"
                }
              ]
            },
            {
              "title": "SepaPaymentMethodDetails",
              "allOf": [
                {
                  "$ref": "#/$defs/SepaPaymentMethodDetails"
                }
              ]
            }
          ]
        },
        "owner": {
          "type": "string",
          "description": "Account owner's first and last name",
          "minLength": 1
        },
        "type": {
          "type": "string",
          "description": "Fiat Payout method type",
          "enum": [
            "PAYOUT_TO_BANK",
            "ACH",
            "SEPA",
            "MOBILE_MONEY",
            "NG_BANK_TRANSFER",
            "ZA_BANK_TRANSFER"
          ]
        }
      },
      "required": [
        "details",
        "owner",
        "type"
      ]
    },
    "FiatPayoutMethodDetails": {
      "description": "Payout method details. The schema depends on fiatPayoutMethod.type."
    },
    "MobilePaymentMethodDetails": {
      "allOf": [
        {
          "$ref": "#/$defs/FiatPayoutMethodDetails"
        },
        {
          "type": "object",
          "properties": {
            "phoneNumber": {
              "type": "string",
              "description": "Customer phone number",
              "minLength": 1
            }
          }
        }
      ],
      "description": "Payout method details for MOBILE_MONEY",
      "required": [
        "phoneNumber"
      ]
    },
    "SepaPaymentMethodDetails": {
      "allOf": [
        {
          "$ref": "#/$defs/FiatPayoutMethodDetails"
        },
        {
          "type": "object",
          "properties": {
            "iban": {
              "type": "string",
              "description": "IBAN",
              "minLength": 1
            }
          }
        }
      ],
      "description": "Payout method details for SEPA",
      "required": [
        "iban"
      ]
    }
  }
}