dwolla
v1.0.3
Published
Dwolla TypeScript SDK.
Readme
dwolla-typescript
Developer-friendly & type-safe Typescript SDK specifically catered to leverage dwolla-typescript API.
Summary
Dwolla API: Dwolla API Documentation
Table of Contents
SDK Installation
The SDK can be installed with either npm, pnpm, bun or yarn package managers.
NPM
npm add dwollaPNPM
pnpm add dwollaBun
bun add dwollaYarn
yarn add dwolla[!NOTE] This package is published with CommonJS and ES Modules (ESM) support.
Requirements
For supported JavaScript runtimes, please consult RUNTIMES.md.
SDK Example Usage
Example
import { Dwolla } from "dwolla";
const dwolla = new Dwolla();
async function run() {
const result = await dwolla.tokens.create({
basicAuth: process.env["DWOLLA_BASIC_AUTH"] ?? "",
}, {
grantType: "client_credentials",
});
console.log(result);
}
run();
Authentication
Per-Client Security Schemes
This SDK supports the following security scheme globally:
| Name | Type | Scheme | Environment Variable |
| -------------------------------------------- | ------ | ------------------------------ | -------------------------------------------------------------------- |
| clientIDclientSecrettokenURL | oauth2 | OAuth2 Client Credentials Flow | DWOLLA_CLIENT_IDDWOLLA_CLIENT_SECRETDWOLLA_TOKEN_URL |
You can set the security parameters through the security optional parameter when initializing the SDK client instance. For example:
import { Dwolla } from "dwolla";
const dwolla = new Dwolla({
security: {
clientID: process.env["DWOLLA_CLIENT_ID"] ?? "",
clientSecret: process.env["DWOLLA_CLIENT_SECRET"] ?? "",
},
});
async function run() {
const result = await dwolla.root.get();
console.log(result);
}
run();
Per-Operation Security Schemes
Some operations in this SDK require the security scheme to be specified at the request level. For example:
import { Dwolla } from "dwolla";
const dwolla = new Dwolla();
async function run() {
const result = await dwolla.tokens.create({
basicAuth: process.env["DWOLLA_BASIC_AUTH"] ?? "",
}, {
grantType: "client_credentials",
});
console.log(result);
}
run();
Available Resources and Operations
Accounts
- get - Retrieve account details
Accounts.Exchanges
Accounts.FundingSources
Accounts.MassPayments
- list - List account mass payments
Accounts.Transfers
- list - List and search account transfers
BeneficialOwners
BeneficialOwners.Documents
BusinessClassifications
ClientTokens
- create - Create a client token
Customers
- list - List and search customers
- create - Create a customer
- get - Retrieve a customer
- update - Update a customer
- listAvailableConnections - List available exchange connections
Customers.BeneficialOwners
Customers.BeneficialOwnership
Customers.Documents
Customers.Exchanges
Customers.ExchangeSessions
- create - Create customer exchange session
Customers.FundingSources
Customers.Kba
- initiate - Initiate a KBA session
Customers.Labels
Customers.MassPayments
- list - List mass payments for customer
Customers.Transfers
- list - List and search transfers for a customer
Documents
- get - Retrieve a document
Events
ExchangePartners
Exchanges
- get - Retrieve exchange resource
Exchanges.ExchangeSessions
- createReAuth - Create re-authentication exchange session
ExchangeSessions
- get - Retrieve exchange session
FundingSources
- get - Retrieve a funding source
- updateOrRemove - Update or remove a funding source
- getVanRouting - Retrieve VAN account and routing numbers
FundingSources.Balance
- get - Retrieve funding source balance
FundingSources.MicroDeposits
- get - Retrieve micro-deposits details
- initiate - Initiate micro-deposits
- verify - Verify micro-deposits
FundingSources.OnDemandTransferAuthorizations
- create - Create an on-demand transfer authorization
Kba
- getQuestions - Retrieve KBA Questions
- verify - Verify KBA Questions
Labels
Labels.LedgerEntries
- list - List label ledger entries
- create - Create a label ledger entry
- get - Retrieve a label ledger entry
Labels.Reallocations
MassPayments
MassPayments.Items
Root
- get - root
SandboxSimulations
- simulate - Simulate bank transfer processing (Sandbox only)
Tokens
- create - Create an application access token
Transfers
Transfers.Failure
- get - Retrieve a transfer failure reason
Transfers.Fees
- list - List fees for a transfer
Webhooks
Webhooks.Retries
- list - List retries for a webhook
WebhookSubscriptions
- list - List webhook subscriptions
- create - Create a webhook subscription
- get - Retrieve a webhook subscription
- update - Update a webhook subscription
- delete - Delete a webhook subscription
WebhookSubscriptions.Webhooks
- list - List webhooks for a webhook subscription
Standalone functions
All the methods listed above are available as standalone functions. These functions are ideal for use in applications running in the browser, serverless runtimes or other environments where application bundle size is a primary concern. When using a bundler to build your application, all unused functionality will be either excluded from the final bundle or tree-shaken away.
To read more about standalone functions, check FUNCTIONS.md.
accountsExchangesCreate- Create an exchange for an accountaccountsExchangesList- List exchanges for an accountaccountsFundingSourcesCreate- Create a funding source for an accountaccountsFundingSourcesList- List funding sources for an accountaccountsGet- Retrieve account detailsaccountsMassPaymentsList- List account mass paymentsaccountsTransfersList- List and search account transfersbeneficialOwnersDelete- Remove beneficial ownerbeneficialOwnersDocumentsCreate- Create a document for beneficial ownerbeneficialOwnersDocumentsList- List documents for beneficial ownerbeneficialOwnersGet- Retrieve beneficial ownerbeneficialOwnersUpdate- Update beneficial ownerbusinessClassificationsGet- Retrieve a business classificationbusinessClassificationsList- List business classificationsclientTokensCreate- Create a client tokencustomersBeneficialOwnersCreate- Create customer beneficial ownercustomersBeneficialOwnershipCertify- Certify beneficial ownershipcustomersBeneficialOwnershipGet- Retrieve beneficial ownership statuscustomersBeneficialOwnersList- List customer beneficial ownerscustomersCreate- Create a customercustomersDocumentsCreate- Create a document for customercustomersDocumentsList- List documents for customercustomersExchangesCreate- Create an exchange for a customercustomersExchangeSessionsCreate- Create customer exchange sessioncustomersExchangesList- List exchanges for a customercustomersFundingSourcesCreate- Create customer funding sourcecustomersFundingSourcesList- List customer funding sourcescustomersGet- Retrieve a customercustomersKbaInitiate- Initiate a KBA sessioncustomersLabelsCreate- Create a label for a customercustomersLabelsList- List labels for a customercustomersList- List and search customerscustomersListAvailableConnections- List available exchange connectionscustomersMassPaymentsList- List mass payments for customercustomersTransfersList- List and search transfers for a customercustomersUpdate- Update a customerdocumentsGet- Retrieve a documenteventsGet- Retrieve eventeventsList- List eventsexchangePartnersGet- Retrieve exchange partnerexchangePartnersList- List exchange partnersexchangeSessionsGet- Retrieve exchange sessionexchangesExchangeSessionsCreateReAuth- Create re-authentication exchange sessionexchangesGet- Retrieve exchange resourcefundingSourcesBalanceGet- Retrieve funding source balancefundingSourcesGet- Retrieve a funding sourcefundingSourcesGetVanRouting- Retrieve VAN account and routing numbersfundingSourcesMicroDepositsGet- Retrieve micro-deposits detailsfundingSourcesMicroDepositsInitiate- Initiate micro-depositsfundingSourcesMicroDepositsVerify- Verify micro-depositsfundingSourcesOnDemandTransferAuthorizationsCreate- Create an on-demand transfer authorizationfundingSourcesUpdateOrRemove- Update or remove a funding sourcekbaGetQuestions- Retrieve KBA QuestionskbaVerify- Verify KBA QuestionslabelsGet- Retrieve a labellabelsLedgerEntriesCreate- Create a label ledger entrylabelsLedgerEntriesGet- Retrieve a label ledger entrylabelsLedgerEntriesList- List label ledger entrieslabelsReallocationsCreate- Create a label reallocationlabelsReallocationsGet- Retrieve a label reallocationlabelsRemove- Remove a labelmassPaymentsCreate- Initiate a mass paymentmassPaymentsGet- Retrieve a mass paymentmassPaymentsItemsGet- Retrieve mass payment itemmassPaymentsItemsList- List items for a mass paymentmassPaymentsUpdate- Update a mass paymentrootGet- rootsandboxSimulationsSimulate- Simulate bank transfer processing (Sandbox only)tokensCreate- Create an application access tokentransfersCancel- Cancel a transfertransfersCreate- Initiate a transfertransfersFailureGet- Retrieve a transfer failure reasontransfersFeesList- List fees for a transfertransfersGet- Retrieve a transferwebhooksGet- Retrieve a webhookwebhooksRetriesList- List retries for a webhookwebhooksRetry- Retry a webhookwebhookSubscriptionsCreate- Create a webhook subscriptionwebhookSubscriptionsDelete- Delete a webhook subscriptionwebhookSubscriptionsGet- Retrieve a webhook subscriptionwebhookSubscriptionsList- List webhook subscriptionswebhookSubscriptionsUpdate- Update a webhook subscriptionwebhookSubscriptionsWebhooksList- List webhooks for a webhook subscription
File uploads
Certain SDK methods accept files as part of a multi-part request. It is possible and typically recommended to upload files as a stream rather than reading the entire contents into memory. This avoids excessive memory consumption and potentially crashing with out-of-memory errors when working with very large files. The following example demonstrates how to attach a file stream to a request.
[!TIP]
Depending on your JavaScript runtime, there are convenient utilities that return a handle to a file without reading the entire contents into memory:
- Node.js v20+: Since v20, Node.js comes with a native
openAsBlobfunction innode:fs.- Bun: The native
Bun.filefunction produces a file handle that can be used for streaming file uploads.- Browsers: All supported browsers return an instance to a
Filewhen reading the value from an<input type="file">element.- Node.js v18: A file stream can be created using the
fileFromhelper fromfetch-blob/from.js.
import { Dwolla } from "dwolla";
import { openAsBlob } from "node:fs";
const dwolla = new Dwolla({
security: {
clientID: process.env["DWOLLA_CLIENT_ID"] ?? "",
clientSecret: process.env["DWOLLA_CLIENT_SECRET"] ?? "",
},
});
async function run() {
const result = await dwolla.customers.documents.create({
id: "<id>",
requestBody: {
documentType: "license",
file: await openAsBlob("example.file"),
},
});
console.log(result);
}
run();
Retries
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
import { Dwolla } from "dwolla";
const dwolla = new Dwolla();
async function run() {
const result = await dwolla.tokens.create({
basicAuth: process.env["DWOLLA_BASIC_AUTH"] ?? "",
}, {
grantType: "client_credentials",
}, {
retries: {
strategy: "backoff",
backoff: {
initialInterval: 1,
maxInterval: 50,
exponent: 1.1,
maxElapsedTime: 100,
},
retryConnectionErrors: false,
},
});
console.log(result);
}
run();
If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
import { Dwolla } from "dwolla";
const dwolla = new Dwolla({
retryConfig: {
strategy: "backoff",
backoff: {
initialInterval: 1,
maxInterval: 50,
exponent: 1.1,
maxElapsedTime: 100,
},
retryConnectionErrors: false,
},
});
async function run() {
const result = await dwolla.tokens.create({
basicAuth: process.env["DWOLLA_BASIC_AUTH"] ?? "",
}, {
grantType: "client_credentials",
});
console.log(result);
}
run();
Error Handling
DwollaError is the base class for all HTTP error responses. It has the following properties:
| Property | Type | Description |
| ------------------- | ---------- | --------------------------------------------------------------------------------------- |
| error.message | string | Error message |
| error.statusCode | number | HTTP response status code eg 404 |
| error.headers | Headers | HTTP response headers |
| error.body | string | HTTP body. Can be empty string if no body is returned. |
| error.rawResponse | Response | Raw HTTP response |
| error.data$ | | Optional. Some errors may contain structured data. See Error Classes. |
Example
import { Dwolla } from "dwolla";
import * as errors from "dwolla/models/errors";
const dwolla = new Dwolla();
async function run() {
try {
const result = await dwolla.tokens.create({
basicAuth: process.env["DWOLLA_BASIC_AUTH"] ?? "",
}, {
grantType: "client_credentials",
});
console.log(result);
} catch (error) {
// The base class for HTTP error responses
if (error instanceof errors.DwollaError) {
console.log(error.message);
console.log(error.statusCode);
console.log(error.body);
console.log(error.headers);
// Depending on the method different errors may be thrown
if (error instanceof errors.UnauthorizedError) {
console.log(error.data$.error); // string
}
}
}
}
run();
Error Classes
Primary error:
DwollaError: The base class for HTTP error responses.
Network errors:
ConnectionError: HTTP client was unable to make a request to a server.RequestTimeoutError: HTTP request timed out due to an AbortSignal signal.RequestAbortedError: HTTP request was aborted by the client.InvalidRequestError: Any input used to create a request is invalid.UnexpectedClientError: Unrecognised or unexpected error.
Inherit from DwollaError:
NotFoundError: Error response schema for 404 NotFound. Status code404. Applicable to 36 of 83 methods.*ForbiddenError: Error response schema for 403 Forbidden. Status code403. Applicable to 24 of 83 methods.*BadRequestError: Error response schema for 400 Bad Request. Status code400. Applicable to 11 of 83 methods.*DuplicateResourceSchemaError: Status code400. Applicable to 3 of 83 methods.*ValidationErrorSchema: ValidationError. Status code400. Applicable to 2 of 83 methods.*InvalidExchangeTokenError: Bad Request. Status code400. Applicable to 2 of 83 methods.*InvalidExchangeError: Bad Request. Status code400. Applicable to 2 of 83 methods.*MaximumNumberOfResourcesSchemaError: Bad Request. Status code400. Applicable to 2 of 83 methods.*InvalidFileTypeSchemaError: Bad Request. Status code400. Applicable to 2 of 83 methods.*InvalidResourceStateSchemaError: Status code403. Applicable to 2 of 83 methods.*UpdateBadRequestDwollaV1HalJSONError: bad request. Status code400. Applicable to 1 of 83 methods.*UpdateOrRemoveFundingSourceBadRequestDwollaV1HalJSONError: validation error. Status code400. Applicable to 1 of 83 methods.*SourceNotFoundError: Bad Request. Status code400. Applicable to 1 of 83 methods.*ReceiverNotFoundError: Bad Request. Status code400. Applicable to 1 of 83 methods.*InvalidSourceFundingSourceError: Bad Request. Status code400. Applicable to 1 of 83 methods.*SenderRestrictedError: Bad Request. Status code400. Applicable to 1 of 83 methods.*ReceiverRestrictedError: Bad Request. Status code400. Applicable to 1 of 83 methods.*InvalidMetadataError: Bad Request. Status code400. Applicable to 1 of 83 methods.*OperationBlockedError: Bad Request. Status code400. Applicable to 1 of 83 methods.*InvalidAmountLimitError: Bad Request. Status code400. Applicable to 1 of 83 methods.*CannotParseAmountError: Bad Request. Status code400. Applicable to 1 of 83 methods.*InsufficientFundsError: Bad Request. Status code400. Applicable to 1 of 83 methods.*FacilitatorFeeAccountNotFoundError: Bad Request. Status code400. Applicable to 1 of 83 methods.*FacilitatorFeeSumTooLargeError: Bad Request. Status code400. Applicable to 1 of 83 methods.*FacilitatorFeeBelowMinimumError: Bad Request. Status code400. Applicable to 1 of 83 methods.*HighRiskError: Bad Request. Status code400. Applicable to 1 of 83 methods.*IncompatibleHoldingsError: Bad Request. Status code400. Applicable to 1 of 83 methods.*DirectAccountWithoutBankError: Bad Request. Status code400. Applicable to 1 of 83 methods.*SourceSameAsDestinationError: Bad Request. Status code400. Applicable to 1 of 83 methods.*InvalidFacilitatorError: Bad Request. Status code400. Applicable to 1 of 83 methods.*InvalidFacilitatorFeeCollectFromError: Bad Request. Status code400. Applicable to 1 of 83 methods.*InvalidFacilitatorFeeCollectFromCombinationError: Bad Request. Status code400. Applicable to 1 of 83 methods.*InvalidDestinationFundingSourceError: Bad Request. Status code400. Applicable to 1 of 83 methods.*InvalidOrRemovedCardDestinationError: Bad Request. Status code400. Applicable to 1 of 83 methods.*InvalidFacilitatorFeeAmountError: Bad Request. Status code400. Applicable to 1 of 83 methods.*WeeklyReceiveLimitReachedError: Bad Request. Status code400. Applicable to 1 of 83 methods.*InvalidDestinationClearingTypeError: Bad Request. Status code400. Applicable to 1 of 83 methods.*InvalidAmountForDestinationClearingTypeError: Bad Request. Status code400. Applicable to 1 of 83 methods.*InvalidCorrelationIdError: Bad Request. Status code400. Applicable to 1 of 83 methods.*SourceAddendaMaxLengthError: Bad Request. Status code400. Applicable to 1 of 83 methods.*DestinationAddendaMaxLengthError: Bad Request. Status code400. Applicable to 1 of 83 methods.*AchAddendaEntriesNotEnabledForAccountError: Bad Request. Status code400. Applicable to 1 of 83 methods.*PointOfSaleAddendaEntriesNotEnabledForAccountError: Bad Request. Status code400. Applicable to 1 of 83 methods.*IncompatibleAddendaEntriesError: Bad Request. Status code400. Applicable to 1 of 83 methods.*InvalidPointOfSaleAddendaIdentificationCodeError: Bad Request. Status code400. Applicable to 1 of 83 methods.*InvalidPointOfSaleAddendaSerialNumberError: Bad Request. Status code400. Applicable to 1 of 83 methods.*InvalidPointOfSaleAddendaDateError: Bad Request. Status code400. Applicable to 1 of 83 methods.*InvalidPointOfSaleAddendaAddressError: Bad Request. Status code400. Applicable to 1 of 83 methods.*InvalidPointOfSaleAddendaCityError: Bad Request. Status code400. Applicable to 1 of 83 methods.*InvalidPointOfSaleAddendaStateError: Bad Request. Status code400. Applicable to 1 of 83 methods.*TransferExpiredForFeeError: Bad Request. Status code400. Applicable to 1 of 83 methods.*InvalidFeeOdfiError: Bad Request. Status code400. Applicable to 1 of 83 methods.*InvalidSourceBankAccountTypeError: Bad Request. Status code400. Applicable to 1 of 83 methods.*InvalidDestinationBankAccountTypeError: Bad Request. Status code400. Applicable to 1 of 83 methods.*IncompatibleSourceAndDestinationTypesError: Bad Request. Status code400. Applicable to 1 of 83 methods.*SourceNotCardNetworkSettlementError: Bad Request. Status code400. Applicable to 1 of 83 methods.*CardSourceNotAllowedError: Error returned when attempting to use a debit card funding source as the transfer source. Status code400. Applicable to 1 of 83 methods.*IncompatibleSourceForRtpDestinationError: Bad Request. Status code400. Applicable to 1 of 83 methods.*InvalidAmountForDestinationProcessingChannelError: Bad Request. Status code400. Applicable to 1 of 83 methods.*RtpFacilitatorFeeNotSupportedError: Bad Request. Status code400. Applicable to 1 of 83 methods.*RtpUnverifiedSenderNotSupportedError: Bad Request. Status code400. Applicable to 1 of 83 methods.*RtpPersonalToPersonalNotSupportedError: Bad Request. Status code400. Applicable to 1 of 83 methods.*DestinationProcessingChannelNotSupportedError: Bad Request. Status code400. Applicable to 1 of 83 methods.*DestinationRemittanceDataMaxLengthError: Bad Request. Status code400. Applicable to 1 of 83 methods.*WithdrawInvalidAmountError: Bad Request. Status code400. Applicable to 1 of 83 methods.*WithdrawInvalidFundingSourceError: Bad Request. Status code400. Applicable to 1 of 83 methods.*WithdrawAccountRestrictedError: Bad Request. Status code400. Applicable to 1 of 83 methods.*WithdrawInvalidAmountForClearingTypeError: Bad Request. Status code400. Applicable to 1 of 83 methods.*WithdrawInvalidWireBeneficiaryLocalityError: Bad Request. Status code400. Applicable to 1 of 83 methods.*WithdrawInvalidWireBeneficiaryRegionError: Bad Request. Status code400. Applicable to 1 of 83 methods.*WithdrawInvalidWireBeneficiaryCountryError: Bad Request. Status code400. Applicable to 1 of 83 methods.*WithdrawInvalidWireOriginatorToBeneficiaryError: Bad Request. Status code400. Applicable to 1 of 83 methods.*WithdrawProcessingChannelNotSupportedError: Bad Request. Status code400. Applicable to 1 of 83 methods.*WithdrawRtpUnverifiedSenderNotSupportedError: Bad Request. Status code400. Applicable to 1 of 83 methods.*WithdrawRtpPersonalWithdrawalNotSupportedError: Bad Request. Status code400. Applicable to 1 of 83 methods.*DepositAccountRestrictedError: Bad Request. Status code400. Applicable to 1 of 83 methods.*WireInvalidImadError: Bad Request. Status code400. Applicable to 1 of 83 methods.*WireAccountRestrictedError: Bad Request. Status code400. Applicable to 1 of 83 methods.*WireNotEnabledError: Bad Request. Status code400. Applicable to 1 of 83 methods.*WireAccountNotFoundError: Bad Request. Status code400. Applicable to 1 of 83 methods.*PrefundingSourceNotAllowedError: Bad Request. Status code400. Applicable to 1 of 83 methods.*StatusInvalidError: 400 Bad Request. Status code400. Applicable to 1 of 83 methods.*StatusNotAllowedError: 400 Bad Request. Status code400. Applicable to 1 of 83 methods.*InvalidUrlFormatError: Bad request. Status code400. Applicable to 1 of 83 methods.*SecretTooLongError: Bad request. Status code400. Applicable to 1 of 83 methods.*MaxSubscriptionsReachedError: Bad request. Status code400. Applicable to 1 of 83 methods.*BadRequestSchemaError: Bad request or duplicate resource. Status code400. Applicable to 1 of 83 methods.*InactiveExchangeError: validation error. Status code400. Applicable to 1 of 83 methods.*InvalidExchangeTokenErrorError: validation error. Status code400. Applicable to 1 of 83 methods.*DuplicateFundingSourceError: validation error. Status code400. Applicable to 1 of 83 methods.*UnsupportedCardCountryError: Error returned when attempting to create a debit card funding source from an unsupported country. Status code400. Applicable to 1 of 83 methods.*InvalidCardTokenError: Error returned when attempting to create a debit card funding source with an invalid card token. Status code400. Applicable to 1 of 83 methods.*MaximumCardsExceededError: Error returned when a customer has exceeded the maximum number of debit card funding sources. Status code400. Applicable to 1 of 83 methods.*CardMissingRequiredFieldsError: Error returned when required fields are missing when creating a debit card funding source. Status code400. Applicable to 1 of 83 methods.*ResponseBodyBadRequestError1: validation error. Status code400. Applicable to 1 of 83 methods.*ResponseBodyBadRequestError2: validation error. Status code400. Applicable to 1 of 83 methods.*ResponseBodyBadRequestError3: validation error. Status code400. Applicable to 1 of 83 methods.*VerifyMicroDepositsBadRequestDwollaV1HalJSONError: Bad Request - invalid deposit amounts. Status code400. Applicable to 1 of 83 methods.*CreateReAuthExchangeSessionBadRequestDwollaV1HalJSONError: validation error. Status code400. Applicable to 1 of 83 methods.*UnauthorizedError: Unauthorized. Status code401. Applicable to 1 of 83 methods.*GetRootDwollaV1HalJSONError: unauthorized. Status code401. Applicable to 1 of 83 methods.*SimulateBankTransferProcessingUnauthorizedDwollaV1HalJSONError: unauthorized. Status code401. Applicable to 1 of 83 methods.*GetExchangeUnauthorizedDwollaV1HalJSONError: Invalid Scope. Status code401. Applicable to 1 of 83 methods.*CreateAccountExchangeDwollaV1HalJSONError: Invalid Scope. Status code401. Applicable to 1 of 83 methods.*CreateCustomerExchangeResponseBodyError1: Unauthorized. Status code401. Applicable to 1 of 83 methods.*CreateCustomerExchangeResponseBodyError2: Unauthorized. Status code401. Applicable to 1 of 83 methods.*CreateCustomerExchangeSessionDwollaV1HalJSONError: unauthorized. Status code401. Applicable to 1 of 83 methods.*GetAccountDwollaV1HalJSONError: forbidden. Status code403. Applicable to 1 of 83 methods.*CreateCustomerForbiddenDwollaV1HalJSONError: forbidden. Status code403. Applicable to 1 of 83 methods.*GetCustomerForbiddenDwollaV1HalJSONError: forbidden. Status code403. Applicable to 1 of 83 methods.*UpdateForbiddenDwollaV1HalJSONError: forbidden. Status code403. Applicable to 1 of 83 methods.*UpdateBeneficialOwnerForbiddenDwollaV1HalJSONError: forbidden. Status code403. Applicable to 1 of 83 methods.*InvalidKbaSessionError: 403 Error. Status code403. Applicable to 1 of 83 methods.*ExpiredKbaSessionError: 403 Error. Status code403. Applicable to 1 of 83 methods.*UpdateOrRemoveFundingSourceForbiddenDwollaV1HalJSONError: forbidden. Status code403. Applicable to 1 of 83 methods.*InvalidAttemptToFacilitateFundsError: Forbidden. Status code403. Applicable to 1 of 83 methods.*InvalidAttemptToPayInFundsError: Forbidden. Status code403. Applicable to 1 of 83 methods.*InvalidAttemptToPayOutFundsError: Forbidden. Status code403. Applicable to 1 of 83 methods.*RtpAccountSettingNotEnabledError: Forbidden. Status code403. Applicable to 1 of 83 methods.*InitiateMassPaymentDwollaV1HalJSONError: Forbidden. Status code403. Applicable to 1 of 83 methods.*GetMassPaymentForbiddenDwollaV1HalJSONError: Forbidden. Status code403. Applicable to 1 of 83 methods.*UpdateMassPaymentForbiddenDwollaV1HalJSONError: Forbidden. Status code403. Applicable to 1 of 83 methods.*RemoveLabelDwollaV1HalJSONError: forbidden. Status code403. Applicable to 1 of 83 methods.*SimulateBankTransferProcessingForbiddenDwollaV1HalJSONError: forbidden. Status code403. Applicable to 1 of 83 methods.*RetrieveCustomerExchangeSessionForbiddenDwollaV1HalJSONError: forbidden. Status code403. Applicable to 1 of 83 methods.*CreateFundingSourceDwollaV1HalJSONError: forbidden. Status code403. Applicable to 1 of 83 methods.*ListFundingSourcesForbiddenDwollaV1HalJSONError: forbidden. Status code403. Applicable to 1 of 83 methods.*ListMassPaymentsForbiddenDwollaV1HalJSONError: forbidden. Status code403. Applicable to 1 of 83 methods.*GetBeneficialOwnershipStatusForCustomerForbiddenDwollaV1HalJSONError: forbidden. Status code403. Applicable to 1 of 83 methods.*CertifyBeneficialOwnershipForCustomerDwollaV1HalJSONError: forbidden. Status code403. Applicable to 1 of 83 methods.*NotAuthorizedSchemaError: not found. Status code403. Applicable to 1 of 83 methods.*ListCustomerFundingSourcesForbiddenDwollaV1HalJSONError: forbidden. Status code403. Applicable to 1 of 83 methods.*CreateCustomerFundingSourceForbiddenDwollaV1HalJSONError: forbidden. Status code403. Applicable to 1 of 83 methods.*ListCustomerMassPaymentsForbiddenDwollaV1HalJSONError: Not authorized to list mass payments. Status code403. Applicable to 1 of 83 methods.*ListCustomerLabelsForbiddenDwollaV1HalJSONError: Forbidden. Status code403. Applicable to 1 of 83 methods.*CreateCustomerLabelForbiddenDwollaV1HalJSONError: Forbidden. Status code403. Applicable to 1 of 83 methods.*ResponseBodyForbiddenError1: forbidden. Status code403. Applicable to 1 of 83 methods.*ResponseBodyForbiddenError2: forbidden. Status code403. Applicable to 1 of 83 methods.*InitiateMicroDepositsForbiddenDwollaV1HalJSONError: Forbidden - funding source not eligible for micro-deposits. Status code403. Applicable to 1 of 83 methods.*VerifyMicroDepositsForbiddenDwollaV1HalJSONError: Forbidden - verification not allowed in current state. Status code403. Applicable to 1 of 83 methods.*ListMassPaymentItemsForbiddenDwollaV1HalJSONError: Not authorized to list mass payment items. Status code403. Applicable to 1 of 83 methods.*GetMassPaymentItemForbiddenDwollaV1HalJSONError: Forbidden. Status code403. Applicable to 1 of 83 methods.*CreateLabelReallocationForbiddenDwollaV1HalJSONError: Forbidden. Status code403. Applicable to 1 of 83 methods.*CreateReAuthExchangeSessionForbiddenDwollaV1HalJSONError: forbidden. Status code403. Applicable to 1 of 83 methods.*CreateCustomerNotFoundDwollaV1HalJSONError: not found. Status code404. Applicable to 1 of 83 methods.*GetCustomerNotFoundDwollaV1HalJSONError: not found. Status code404. Applicable to 1 of 83 methods.*ListAvailableExchangeConnectionsDwollaV1HalJSONError: not found. Status code404. Applicable to 1 of 83 methods.*RetrieveBusinessClassificationDwollaV1HalJSONError: not found. Status code404. Applicable to 1 of 83 methods.*RetrieveBeneficialOwnerDwollaV1HalJSONError: not found. Status code404. Applicable to 1 of 83 methods.*UpdateBeneficialOwnerNotFoundDwollaV1HalJSONError: not found. Status code404. Applicable to 1 of 83 methods.*DeleteBeneficialOwnerDwollaV1HalJSONError: not found. Status code404. Applicable to 1 of 83 methods.*GetKbaQuestionsDwollaV1HalJSONError: 404 Error. Status code404. Applicable to 1 of 83 methods.*VerifyKbaQuestionsDwollaV1HalJSONError: 404 Error. Status code404. Applicable to 1 of 83 methods.*GetFundingSourceDwollaV1HalJSONError: not found. Status code404. Applicable to 1 of 83 methods.*GetVanRoutingDwollaV1HalJSONError: not found. Status code404. Applicable to 1 of 83 methods.*GetMassPaymentNotFoundDwollaV1HalJSONError: Not Found. Status code404. Applicable to 1 of 83 methods.*UpdateMassPaymentNotFoundDwollaV1HalJSONError: Not Found. Status code404. Applicable to 1 of 83 methods.*GetExchangeNotFoundDwollaV1HalJSONError: Not Found. Status code404. Applicable to 1 of 83 methods.*RetrieveCustomerExchangeSessionNotFoundDwollaV1HalJSONError: not found. Status code404. Applicable to 1 of 83 methods.*ListFundingSourcesNotFoundDwollaV1HalJSONError: not found. Status code404. Applicable to 1 of 83 methods.*ListAndSearchTransfersDwollaV1HalJSONError: not found. Status code404. Applicable to 1 of 83 methods.*ListMassPaymentsNotFoundDwollaV1HalJSONError: not found. Status code404. Applicable to 1 of 83 methods.*ListBeneficialOwnersForCustomerDwollaV1HalJSONError: not found. Status code404. Applicable to 1 of 83 methods.*GetBeneficialOwnershipStatusForCustomerNotFoundDwollaV1HalJSONError: not found. Status code404. Applicable to 1 of 83 methods.*CreateCustomerDocumentNotFoundDwollaV1HalJSONError: not found. Status code404. Applicable to 1 of 83 methods.*ListCustomerFundingSourcesNotFoundDwollaV1HalJSONError: not found. Status code404. Applicable to 1 of 83 methods.*CreateCustomerFundingSourceNotFoundDwollaV1HalJSONError: not found. Status code404. Applicable to 1 of 83 methods.*ListCustomerMassPaymentsNotFoundDwollaV1HalJSONError: Customer not found. Status code404. Applicable to 1 of 83 methods.*ListCustomerLabelsNotFoundDwollaV1HalJSONError: Not Found. Status code404. Applicable to 1 of 83 methods.*CreateCustomerLabelNotFoundDwollaV1HalJSONError: Not Found. Status code404. Applicable to 1 of 83 methods.*ListCustomerExchangesDwollaV1HalJSONError: Not Found. Status code404. Applicable to 1 of 83 methods.*InitiateMicroDepositsNotFoundDwollaV1HalJSONError: Funding source not found. Status code404. Applicable to 1 of 83 methods.*VerifyMicroDepositsNotFoundDwollaV1HalJSONError: Funding source not found. Status code404. Applicable to 1 of 83 methods.*GetFundingSourceBalanceDwollaV1HalJSONError: not found. Status code404. Applicable to 1 of 83 methods.*ListMassPaymentItemsNotFoundDwollaV1HalJSONError: Mass payment not found. Status code404. Applicable to 1 of 83 methods.*GetMassPaymentItemNotFoundDwollaV1HalJSONError: Not Found. Status code404. Applicable to 1 of 83 methods.*CreateLabelReallocationNotFoundDwollaV1HalJSONError: Not Found. Status code404. Applicable to 1 of 83 methods.*CreateCustomerDocumentRequestEntityTooLargeDwollaV1HalJSONError: request entity too large. Status code413. Applicable to 1 of 83 methods.*CreateBeneficialOwnerDocumentDwollaV1HalJSONError: request entity too large. Status code413. Applicable to 1 of 83 methods.*TooManyRequestsErrorError: Too Many Requests. Status code429. Applicable to 1 of 83 methods.*ResponseValidationError: Type mismatch between the data returned from the server and the structure expected by the SDK. Seeerror.rawValuefor the raw value anderror.pretty()for a nicely formatted multi-line string.
* Check the method documentation to see if the error is applicable.
Server Selection
Select Server by Name
You can override the default server globally by passing a server name to the server: keyof typeof ServerList optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the names associated with the available servers:
| Name | Server | Description |
| --------- | -------------------------------- | ----------------- |
| prod | https://api.dwolla.com | Production server |
| sandbox | https://api-sandbox.dwolla.com | Sandbox server |
Example
import { Dwolla } from "dwolla";
const dwolla = new Dwolla({
server: "prod",
});
async function run() {
const result = await dwolla.tokens.create({
basicAuth: process.env["DWOLLA_BASIC_AUTH"] ?? "",
}, {
grantType: "client_credentials",
});
console.log(result);
}
run();
Override Server URL Per-Client
The default server can also be overridden globally by passing a URL to the serverURL: string optional parameter when initializing the SDK client instance. For example:
import { Dwolla } from "dwolla";
const dwolla = new Dwolla({
serverURL: "https://api.dwolla.com",
});
async function run() {
const result = await dwolla.tokens.create({
basicAuth: process.env["DWOLLA_BASIC_AUTH"] ?? "",
}, {
grantType: "client_credentials",
});
console.log(result);
}
run();
Custom HTTP Client
The TypeScript SDK makes API calls using an HTTPClient that wraps the native
Fetch API. This
client is a thin wrapper around fetch and provides the ability to attach hooks
around the request lifecycle that can be used to modify the request or handle
errors and response.
The HTTPClient constructor takes an optional fetcher argument that can be
used to integrate a third-party HTTP client or when writing tests to mock out
the HTTP client and feed in fixtures.
The following example shows how to use the "beforeRequest" hook to to add a
custom header and a timeout to requests and how to use the "requestError" hook
to log errors:
import { Dwolla } from "dwolla";
import { HTTPClient } from "dwolla/lib/http";
const httpClient = new HTTPClient({
// fetcher takes a function that has the same signature as native `fetch`.
fetcher: (request) => {
return fetch(request);
}
});
httpClient.addHook("beforeRequest", (request) => {
const nextRequest = new Request(request, {
signal: request.signal || AbortSignal.timeout(5000)
});
nextRequest.headers.set("x-custom-header", "custom value");
return nextRequest;
});
httpClient.addHook("requestError", (error, request) => {
console.group("Request Error");
console.log("Reason:", `${error}`);
console.log("Endpoint:", `${request.method} ${request.url}`);
console.groupEnd();
});
const sdk = new Dwolla({ httpClient: httpClient });Debugging
You can setup your SDK to emit debug logs for SDK requests and responses.
You can pass a logger that matches console's interface as an SDK option.
[!WARNING] Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It's recommended to use this feature only during local development and not in production.
import { Dwolla } from "dwolla";
const sdk = new Dwolla({ debugLogger: console });You can also enable a default debug logger by setting an environment variable DWOLLA_DEBUG to true.
Development
Testing (Maintainers Only)
This SD
