> ## Documentation Index
> Fetch the complete documentation index at: https://developers.dwolla.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create an exchange for a customer

> Creates an exchange connection between a customer and Dwolla. Request body varies by partner (Plaid, MX, Flinks, Finicity, Checkout.com). For bank accounts, use Plaid, MX, Flinks, or Finicity to establish secure access to the customer's bank account data. For debit cards (Push to Card), use Checkout.com and pass the payment ID from Checkout.com Flow.



## OpenAPI

````yaml post /customers/{id}/exchanges
openapi: 3.1.0
info:
  title: Dwolla API
  description: Dwolla API Documentation
  contact:
    name: Dwolla Developer Relations Team
    url: https://developers.dwolla.com
    email: api@dwolla.com
  version: '2.0'
  termsOfService: https://www.dwolla.com/legal/tos/
  license:
    name: MIT
    url: https://github.com/Dwolla/dwolla-openapi/blob/master/LICENSE
servers:
  - url: https://api.dwolla.com
    description: Production server
  - url: https://api-sandbox.dwolla.com
    description: Sandbox server
security:
  - clientCredentials: []
tags:
  - name: tokens
    description: Operations related to Application Access Tokens
  - name: root
    description: Root API operations
  - name: accounts
    description: Operations related to Accounts
  - name: customers
    description: Operations related to Customers
  - name: kba
    description: Operations related to Knowledge-Based Authentication
  - name: beneficial owners
    description: Operations related to Beneficial Owners
  - name: documents
    description: Operations related to Documents
  - name: exchanges
    description: Operations related to Exchanges
  - name: exchange sessions
    description: Operations related to Exchange Sessions
  - name: funding sources
    description: Operations related to Funding Sources
  - name: transfers
    description: Operations related to Transfers
  - name: labels
    description: Operations related to Labels
  - name: mass payments
    description: Operations related to Mass Payments
  - name: events
    description: Operations related to Events
  - name: webhook subscriptions
    description: Operations related to Webhook Subscriptions
  - name: webhooks
    description: Operations related to Webhooks
  - name: client tokens
    description: Operations related to Client Tokens
  - name: sandbox simulations
    description: Sandbox-only operations for simulating processing of bank transfers
paths:
  /customers/{id}/exchanges:
    post:
      tags:
        - exchanges
      summary: Create an exchange for a customer
      description: >-
        Creates an exchange connection between a customer and Dwolla. Request
        body varies by partner (Plaid, MX, Flinks, Finicity, Checkout.com). For
        bank accounts, use Plaid, MX, Flinks, or Finicity to establish secure
        access to the customer's bank account data. For debit cards (Push to
        Card), use Checkout.com and pass the payment ID from Checkout.com Flow.
      operationId: createCustomerExchange
      parameters:
        - name: id
          in: path
          description: The ID of the customer to create an exchange for
          required: true
          schema:
            type: string
        - $ref: '#/components/parameters/Accept'
      requestBody:
        required: true
        content:
          application/vnd.dwolla.v1.hal+json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/CreateFinicitySecureExchange'
                - $ref: '#/components/schemas/CreateTokenBasedExchange'
                - $ref: '#/components/schemas/CreateMXOpenBankingExchange'
                - $ref: '#/components/schemas/CreatePlaidOpenBankingExchange'
      responses:
        '201':
          description: created
          headers:
            Location:
              $ref: '#/components/headers/Location'
              example: >-
                https://api.dwolla.com/exchanges/fcd15e5f-8d13-4570-a9b7-7fb49e55941d
        '400':
          description: Bad Request
          content:
            application/vnd.dwolla.v1.hal+json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/InvalidExchangeToken'
                  - $ref: '#/components/schemas/InvalidExchange'
        '401':
          description: Unauthorized
          content:
            application/vnd.dwolla.v1.hal+json:
              schema:
                oneOf:
                  - type: object
                    properties:
                      code:
                        type: string
                        example: InvalidExchangeToken
                      message:
                        type: string
                        example: >-
                          The exchange token is not valid to perform this
                          operation. Either the token is expired or invalid, or
                          the products permissions to the token are invalid or
                          expired.
                  - type: object
                    properties:
                      code:
                        type: string
                        example: InvalidScope
                      message:
                        type: string
                        example: >-
                          The scopes for creating an exchange resource for a
                          customer is not enabled for this application. Reach
                          out to Dwolla for more information.
        '404':
          description: Not Found
          content:
            application/vnd.dwolla.v1.hal+json:
              schema:
                $ref: '#/components/schemas/NotFoundError'
      x-codeSamples:
        - lang: bash
          source: >
            POST
            https://api.dwolla.com/customers/74a207b2-b7b7-4efa-8bf8-582148e7b980/exchanges

            Accept: application/vnd.dwolla.v1.hal+json

            Content-Type: application/vnd.dwolla.v1.hal+json

            Authorization: Bearer
            pBA9fVDBEyYZCEsLf/wKehyh1RTpzjUj5KzIRfDi0wKTii7DqY


            {
                "_links": {
                    "exchange-partner": {
                        "href": "https://api.dwolla.com/exchange-partners/f53ffb32-c84f-496a-9d9d-acd100d396ef"
                    }
                },
                "token": "somePlaidProcessorToken"
            }


            HTTP/1.1 201 Created

            Location:
            https://api.dwolla.com/exchanges/fcd15e5f-8d13-4570-a9b7-7fb49e55941d
        - lang: javascript
          source: >
            // Using dwolla-v2 - https://github.com/Dwolla/dwolla-v2-node

            var customerUrl =
            "https://api.dwolla.com/customers/74a207b2-b7b7-4efa-8bf8-582148e7b980";

            var requestBody = {
              _links: {
                "exchange-partner": {
                  href: "https://api.dwolla.com/exchange-partners/f53ffb32-c84f-496a-9d9d-acd100d396ef",
                },
              },
              token: "somePlaidProcessorToken",
            };


            dwolla.post(`${customerUrl}/exchanges`, requestBody).then((res) =>
            res.headers.get("location")); // =>
            'https://api.dwolla.com/exchanges/fcd15e5f-8d13-4570-a9b7-7fb49e55941d'
        - lang: python
          source: >
            # Using dwollav2 - https://github.com/Dwolla/dwolla-v2-python

            customer_url =
            'https://api.dwolla.com/customers/74a207b2-b7b7-4efa-8bf8-582148e7b980'

            request_body = {
              '_links': {
                'exchange-partner': {
                  'href': 'https://api.dwolla.com/exchange-partners/f53ffb32-c84f-496a-9d9d-acd100d396ef'
                }
              },
              'token': 'somePlaidProcessorToken'
            }


            exchange = app_token.post('%s/exchanges' % customer_url,
            request_body)

            exchange.headers['location'] # =>
            'https://api.dwolla.com/exchanges/fcd15e5f-8d13-4570-a9b7-7fb49e55941d'
        - lang: php
          source: >
            <?php

            // Using dwollaswagger -
            https://github.com/Dwolla/dwolla-swagger-php

            $exchangesApi = new ExchangesApi($apiClient);

            $customerUrl =
            "https://api.dwolla.com/customers/74a207b2-b7b7-4efa-8bf8-582148e7b980";


            $exchange = $exchangesApi->createCustomerExchange(new
            CreateExchangeRequest([
                "_links" => [
                    "exchange-partner" => [
                        "href" => "https://api.dwolla.com/exchange-partners/f53ffb32-c84f-496a-9d9d-acd100d396ef"
                    ]
                ],
                "token" => "somePlaidProcessorToken"
            ]), $customerUrl);


            $exchange; # =>
            https://api.dwolla.com/exchanges/fcd15e5f-8d13-4570-a9b7-7fb49e55941d

            ?>
        - lang: ruby
          source: >
            # Using dwolla_v2 - https://github.com/Dwolla/dwolla-v2-ruby

            customer_url =
            'https://api.dwolla.com/customers/74a207b2-b7b7-4efa-8bf8-582148e7b980'

            request_body = {
              _links: {
                'exchange-partner': {
                  href: "https://api.dwolla.com/exchange-partners/f53ffb32-c84f-496a-9d9d-acd100d396ef"
                }
              },
              token: 'somePlaidProcessorToken'
            }


            exchange = app_token.post "#{customer_url}/exchanges", request_body

            exchange.response_headers[:location] # =>
            "https://api.dwolla.com/exchanges/fcd15e5f-8d13-4570-a9b7-7fb49e55941d"
components:
  parameters:
    Accept:
      name: Accept
      in: header
      required: true
      description: >-
        The media type of the response. Must be
        application/vnd.dwolla.v1.hal+json
      schema:
        type: string
        enum:
          - application/vnd.dwolla.v1.hal+json
        default: application/vnd.dwolla.v1.hal+json
  schemas:
    CreateFinicitySecureExchange:
      title: CreateFinicitySecureExchange
      type: object
      required:
        - _links
        - finicity
      properties:
        _links:
          type: object
          properties:
            exchange-partner:
              type: object
              properties:
                href:
                  type: string
                  example: >-
                    https://api.dwolla.com/exchange-partners/292317ec-e252-47d8-93c3-2d128e037aa4
        finicity:
          type: object
          properties:
            profile:
              type: integer
              format: int32
              example: 3
            version:
              type: string
              example: '1'
            receiptId:
              type: string
              example: cr_4N47ou7SlppuIxq0ZUtACh10vYcloY
            receiptVersion:
              type: string
              example: '1'
            customerId:
              type: string
              example: '5454874858510164117'
            partnerId:
              type: integer
              format: int64
              example: 2445583946651
            products:
              type: array
              items:
                type: object
                properties:
                  product:
                    type: string
                    example: moneyTransferDetails
                  accountId:
                    type: string
                    example: '1015199035827334916'
                  accessPeriod:
                    type: object
                    properties:
                      type:
                        type: string
                        example: timeframe
                      startTime:
                        type: string
                        format: date
                        example: '2022-07-06'
                      endTime:
                        type: string
                        format: date-time
                        example: '2022-08-16T06:06:20Z'
            timestamp:
              type: string
              format: date-time
              example: '2022-07-11T06:06:23Z'
    CreateTokenBasedExchange:
      title: CreateTokenBasedExchange
      description: >-
        Create an exchange using a token. Supports MX, Plaid, and Flinks secure
        exchange flows, and Checkout.com for Push to Card (debit card).
      type: object
      required:
        - _links
        - token
      properties:
        _links:
          type: object
          required:
            - exchange-partner
          properties:
            exchange-partner:
              type: object
              properties:
                href:
                  type: string
                  example: >-
                    https://api.dwolla.com/exchange-partners/292317ec-e252-47d8-93c3-2d128e037aa4
        token:
          type: string
          description: >-
            Connection or processor token from the exchange partner (e.g.,
            Plaid, MX, Flinks), or payment ID (pay_xxx) from Checkout.com Flow
            for Push to Card
          example: sandbox-token-abc123
    CreateMXOpenBankingExchange:
      title: CreateMXOpenBankingExchange
      type: object
      required:
        - _links
        - mx
      properties:
        _links:
          type: object
          required:
            - exchange-partner
          properties:
            exchange-partner:
              type: object
              required:
                - href
              properties:
                href:
                  type: string
                  format: uri
                  example: >-
                    https://api.dwolla.com/exchange-partners/bca8d065-49a5-475b-a6b4-509bc8504d22
        mx:
          type: object
          required:
            - availableConnectionToken
          properties:
            availableConnectionToken:
              type: string
              description: The MX connection token for the available connection
              example: >-
                eyJhY2NvdW50SWQiOiJBQ1QtMjAxY2FkM2MtYzc2Yi00N2M1LWI3Y2QtMTkxY2FhNzdlZWM5IiwibWVtYmVySWQiOiJNQlItZGNjZWY0ZWMtOGM4MC00NTlmLTlhMGItMTc1ZTA0OTJmZWIzIn0=
    CreatePlaidOpenBankingExchange:
      title: CreatePlaidOpenBankingExchange
      type: object
      required:
        - _links
        - plaid
      properties:
        _links:
          type: object
          required:
            - exchange-partner
          properties:
            exchange-partner:
              type: object
              required:
                - href
              properties:
                href:
                  type: string
                  format: uri
                  example: >-
                    https://api.dwolla.com/exchange-partners/f53ffb32-c84f-496a-9d9d-acd100d396ef
        plaid:
          type: object
          required:
            - publicToken
          properties:
            publicToken:
              type: string
              description: The Plaid public token for the connection
              example: public-production-d5456acb-01d5-4932-9783-e4c883cf1c0c
    InvalidExchangeToken:
      title: InvalidExchangeToken
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          example: InvalidExchangeToken
        message:
          type: string
          example: Exchange token is expired.
    InvalidExchange:
      title: InvalidExchange
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          example: InvalidExchange
        message:
          type: string
          example: The exchange is no longer active.
    NotFoundError:
      title: NotFoundError
      description: Error response schema for 404 NotFound
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          example: NotFound
        message:
          type: string
          example: The requested resource was not found.
  headers:
    Location:
      description: The location of the created resource
      schema:
        type: string
  securitySchemes:
    clientCredentials:
      type: oauth2
      flows:
        clientCredentials:
          tokenUrl: /token
          x-speakeasy-token-endpoint-authentication: client_secret_basic
          scopes: {}

````