## Create an exchange for an account

### Endpoint

`POST https://api.dwolla.com/exchanges`

### Request Body

```json
{
  "_links": {
    "exchange-partner": {
      "href": "https://api.dwolla.com/exchange-partners/292317ec-e252-47d8-93c3-2d128e037aa4"
    }
  },
  "finicity": {
    "profile": 3,
    "version": "1",
    "receiptId": "cr_4N47ou7SlppuIxq0ZUtACh10vYcloY",
    "receiptVersion": "1",
    "customerId": "5454874858510164117",
    "partnerId": 2445583946651,
    "products": [
      {
        "product": "moneyTransferDetails",
        "accountId": "1015199035827334916",
        "accessPeriod": {
          "type": "timeframe",
          "startTime": "2022-07-06",
          "endTime": "2022-08-16T06:06:20Z"
        }
      }
    ],
    "timestamp": "2022-07-11T06:06:23Z"
  }
}
```

### cURL Example

```bash
curl --request POST \
  --url https://api.dwolla.com/exchanges \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "_links": {
    "exchange-partner": {
      "href": "https://api.dwolla.com/exchange-partners/292317ec-e252-47d8-93c3-2d128e037aa4"
    }
  },
  "finicity": {
    "profile": 3,
    "version": "1",
    "receiptId": "cr_4N47ou7SlppuIxq0ZUtACh10vYcloY",
    "receiptVersion": "1",
    "customerId": "5454874858510164117",
    "partnerId": 2445583946651,
    "products": [
      {
        "product": "moneyTransferDetails",
        "accountId": "1015199035827334916",
        "accessPeriod": {
          "type": "timeframe",
          "startTime": "2022-07-06",
          "endTime": "2022-08-16T06:06:20Z"
        }
      }
    ],
    "timestamp": "2022-07-11T06:06:23Z"
  }
}'
```

### Expected Response Codes

- **201 Created**: The exchange was successfully created.
- **400 Bad Request**: The request was malformed.
- **401 Unauthorized**: Authentication failed.
- **403 Forbidden**: The user is not permitted to access this resource.
- **404 Not Found**: The resource could not be found.

### Error Responses

```json
{
  "code": "InvalidExchangeToken",
  "message": "Exchange token is expired."
}
```

```json
{
  "code": "InvalidExchange",
  "message": "The exchange is no longer active."
}
```

```json
{
  "code": "Forbidden",
  "message": "The supplied credentials are not authorized for this resource."
}
```

```json
{
  "code": "NotFound",
  "message": "The requested resource was not found."
}
```

### Authorization

Authorization: `Bearer <token>`

### Additional Information

- **_links**: This object is required and contains the exchange partner link.
- **finicity**: This object is required and contains parameters for creating the exchange.
