Payments API examples

Create a new vendor with ACH details and initiate a payment.

  1. Create a new vendor.
Copy
Copied
POST "https://platform.brexapis.com/v1/vendors"
Requires "vendors" scope

REQUEST BODY
{
    "company_name": "Schrute Farms"
    "payment_accounts": [
      {
          "details": {
              "type": "ACH",
              "routing_number": "1234567",
              "account_number": "3818193555",
              "account_type": "CHECKING",
              "account_class": "BUSINESS"
          }
      }
    ]
}

RESPONSE
{
    "id": "pdcont_ckt6g23823883x0fek",
    "company_name": "Schrute Farms"
    "payment_accounts": [
        {
            "details": {
                "type": "ACH",
                "payment_instrument_id": "pdinstl_ckt6g2y2m001c0e54n4urkbh1",
                "routing_number": "1234567",
                "account_number": "3818193555",
                "account_type": "CHECKING",
                "account_class": "BUSINESS"
            }
        }
    ]
}
  1. Get your Brex Cash account ID.
Copy
Copied
GET "https://platform.brexapis.com/v2/accounts/cash" // From Transactions API
Requires "accounts.cash.readonly" scope

RESPONSE

{
    "items": [
        {
            "id": "dpacc_ckrqrb91z990d01h4yz3f1k0f", // use in next call for originating_account id
            "description": "Primary Cash Account",
            "status": "ACTIVE",
            "account_number": "668210333973",
            "routing_number": "211179322",
            "current_balance": {
                "amount": 1133000,
                "currency": "USD"
            },
            "available_balance": {
                "amount": 623200,
                "currency": "USD"
            }
        }
    ]
}
  1. Initiate the ACH transfer.
Copy
Copied
POST "https://platform.brexapis.com/v1/transfers"
Requires "transfers" scope

REQUEST BODY
{
    "amount": {
        "amount": 100000, // 100000 cents = $1000
        "currency": "USD"
    },
    "counterparty": {
        "type": "VENDOR",
        "payment_instrument_id": "pdinstl_ckt6g2y2m001c0e54n4urkbh1", // From vendor creation response
    },
    "description": "Never go to Schrute Farms again -Angela",
    "external_memo": "Company outing",
    "originating_account": {
        "type": "BREX_CASH",
        "id": "dpacc_ckrqrb91z990d01h4yz3f1k0f", // Cash account ID
    }
}


RESPONSE
{
    "id": "dptx_ckt6h1lwz0cx401htea89ez4g",
    "counterparty": {
        "type": "VENDOR",
        "payment_instrument_id": "pdinstl_ckt6g2y2m001c0e54n4urkbh1",
        "id": "pdcont_ckt6g23823883x0fek",
    },
    "description": "Never go to Schrute Farms again -Angela",
    "payment_type": "ACH",
    "amount": {
        "amount": 1000,
        "currency": "USD"
    },
    "originating_account": {
        "type": "BREX_CASH",
        "id": "dpacc_ckrqrb91z990d01h4yz3f1k0f", // Cash account ID
    }
    "status": "SCHEDULED",
    "estimated_delivery_date": "2021-09-09",
    "creator_user_id": "cuuser_ckrqmr4oq123o01pyzzf609yf"
}
Copyright © Brex 2019–2022. All rights reserved.