# Create a Funding Source for an External Party

This section details how to add a bank account to external parties. To add a bank account to an external party, you can use one of two methods:

- Option 1: Provide the account number, routing number, type, and a nickname.
- Option 2: Create an exchange for the external party, which will create a secure connection between Dwolla and a third-party provider for account creation and verification.

Funding Sources are relational to an External Party and have the ability to send and receive funds.

## HTTP request

`POST https://api.dwolla.com/external-parties/{id}/funding-sources`

## Request parameters

| Parameter          | Required | Type   | Description |
|--------------------|----------|--------|-------------|
| routingNumber      | yes      | string | A bank routing number that identifies a bank or credit union in the U.S. Note: Validation of the routing number includes: a checksum, the first two digits of the routing number must fall within the range “01” through “12”, or “21” through “32”, and the string value must consist of nine digits. |
| accountNumber      | yes      | string | The bank account number. Note: The account number is validated to check if it is a numeric string of 4-17 digits. |
| bankAccountType    | yes      | string | Type of bank account: `checking`, `savings`. |
| name               | yes      | string | Arbitrary nickname for the funding source. Must be 50 characters or less. |
| correlationId      | no       | string | A unique string value attached to a funding source which can be used for traceability between Dwolla and your application. **Note:** A correlationId is not a replacement for an [idempotency-key](https://developers.dwolla.com/api-reference#idempotency-key). Must be less than or equal to 255 characters and contain no spaces. Acceptable characters are: `a-Z`, `0-9`, `-`, `.`, and `_`. **Note:** Sensitive Personal Identifying Information (PII) should not be used in this field and it is recommended to use a random value for correlationId, like a UUID. |

## HTTP status and error codes

| HTTP Status | Code       | Message                                        | Description |
|-------------|------------|------------------------------------------------|-------------|
| 201         | Created    | Success                                        | Funding source created. |
| 400         | BadRequest | Validation error(s) present. See embedded errors list for more details. | An error exists with the request. Check the embedded list of errors for more detailed error messages. Also check [Validation Errors](https://developers.dwolla.com/api-reference#validation-errors) section in the API reference. |
| 404         | NotFound   | The requested resource was not found.         | External Party not found. Check External Party Id. |

## Request and response

```
POST https://api.dwolla.com/external-parties/{id}/funding-sources
Authorization: Bearer connect.eyJraWQiOiJPNVV...FnZGxlY1B...JzI4I...
{
  "routingNumber": "222222226",
  "accountNumber": "123456789",
  "bankAccountType": "checking",
  "name": "Jane Doe's Checking"
}
```

```
HTTP/1.1 201 Created
Location: https://api.dwolla.com/funding-sources/fc451a7a-ae30-4404-aB95-e3553fcd7
```

### Request and response - using an exchange

```
POST https://api.dwolla.com/external-parties/99bfb139-eadd-4cdf-b346-7504f0c16c60/funding-sources
Content-Type: application/vnd.dwolla.v1.hal+json
Accept: application/vnd.dwolla.v1.hal+json
Authorization: Bearer pBA9fVDBEyYZCEsLf/wKehyh1RTpzjUj5KzIRfDi0wKTii7DqY
{
  "_links": {
    "exchange": {
      "href": "https://api.dwolla.com/exchanges/6bc9109a-04fd-49b6-ace6-ca06fd282d65"
    }
  },
  "bankAccountType": "checking",
  "name": "Jane Doe - Checking"
}
```

```
HTTP/1.1 201 Created
Location: https://api.dwolla.com/funding-sources/375c6781-2a17-476c-84f7-db7d2f6ffb31
```

### Code Examples

#### Using dwolla_v2 - Ruby
```ruby
external_party_url = 'https://api.dwolla.com/external-parties/AB443D36-3757-44C1-A1B4-29727FB3111C'
request_body = {
  routingNumber: '222222226',
  accountNumber: '123456789',
  bankAccountType: 'checking',
  name: 'Jane Doe’s Checking'
}

funding_source = app_token.post "#{external_party_url}/funding-sources", request_body
funding_source.response_headers[:location] # => "https://api.dwolla.com/funding-sources/375c6781-2a17-476c-84f7-db7d2f6ffb31"
```

#### Using dwollav2 - Python
```python
external_party_url = 'https://api.dwolla.com/external-parties/AB443D36-3757-44C1-A1B4-29727FB3111C'
request_body = {
  'routingNumber': '222222226',
  'accountNumber': '123456789',
  'bankAccountType': 'checking',
  'name': 'Jane Doe’s Checking'
}

fundingSource = app_token.post('%s/funding-sources' % external_party_url, request_body)
fundingSource.headers['location'] # => 'https://api.dwolla.com/funding-sources/375c6781-2a17-476c-84f7-db7d2f6ffb31'
```

#### Using dwolla-v2 - Node.js
```javascript
var externalPartyUrl =
  "https://api.dwolla.com/external-parties/AB443D36-3757-44C1-A1B4-29727FB3111C";

var requestBody = {
  routingNumber: "222222226",
  accountNumber: "123456789",
  bankAccountType: "checking",
  name: "Jane Doe’s Checking",
};

dwolla
  .post(`${externalPartyUrl}/funding-sources`, requestBody)
  .then((res) => res.headers.get("location")); // => 'https://api.dwolla.com/funding-sources/375c6781-2a17-476c-84f7-db7d2f6ffb31'
```
