It has been generated successfully based on your OpenAPI spec. However, it is not yet ready for production use. Here are some next steps:
- 🛠 Make your SDK feel handcrafted by customizing it
- ♻️ Refine your SDK quickly by iterating locally with the Speakeasy CLI
- 🎁 Publish your SDK to package managers by configuring automatic publishing
- ✨ When ready to productionize, delete this section from the README
Formance Stack API: Open, modular foundation for unique payments flows
This API is documented in OpenAPI format.
Formance Stack offers one forms of authentication:
- OAuth2 OAuth2 - an open protocol to allow secure authorization in a simple and standard method from web, mobile and desktop applications.
- SDK Installation
- SDK Example Usage
- Available Resources and Operations
- Error Handling
- Server Selection
- Authentication
JDK 11 or later is required.
The samples below show how a published SDK artifact is used:
Gradle:
implementation 'com.formance:formance-sdk:4.2.0'
Maven:
<dependency>
<groupId>com.formance</groupId>
<artifactId>formance-sdk</artifactId>
<version>4.2.0</version>
</dependency>
After cloning the git repository to your file system you can build the SDK artifact from source to the build
directory by running ./gradlew build
on *nix systems or gradlew.bat
on Windows systems.
If you wish to build from source and publish the SDK artifact to your local Maven repository (on your filesystem) then use the following command (after cloning the git repo locally):
On *nix:
./gradlew publishToMavenLocal -Pskip.signing
On Windows:
gradlew.bat publishToMavenLocal -Pskip.signing
package hello.world;
import com.formance.formance_sdk.SDK;
import com.formance.formance_sdk.models.operations.GetVersionsResponse;
import com.formance.formance_sdk.models.shared.Security;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Exception {
SDK sdk = SDK.builder()
.security(Security.builder()
.clientID("<YOUR_CLIENT_ID_HERE>")
.clientSecret("<YOUR_CLIENT_SECRET_HERE>")
.build())
.build();
GetVersionsResponse res = sdk.getVersions()
.call();
if (res.getVersionsResponse().isPresent()) {
// handle response
}
}
}
Available methods
- createClient - Create client
- createSecret - Add a secret to a client
- deleteClient - Delete client
- deleteSecret - Delete a secret from a client
- getOIDCWellKnowns - Retrieve OpenID connect well-knowns.
- getServerInfo - Get server info
- listClients - List clients
- listUsers - List users
- readClient - Read client
- readUser - Read user
- updateClient - Update client
- createTransactions - Create a new batch of transactions to a ledger
- addMetadataOnTransaction - Set the metadata of a transaction by its ID
- addMetadataToAccount - Add metadata to an account
- countAccounts - Count the accounts from a ledger
- countTransactions - Count the transactions from a ledger
- createTransaction - Create a new transaction to a ledger
- getAccount - Get account by its address
- getBalances - Get the balances from a ledger's account
- getBalancesAggregated - Get the aggregated balances from selected accounts
- getInfo - Show server information
- getLedgerInfo - Get information about a ledger
- getMapping - Get the mapping of a ledger
- getTransaction - Get transaction from a ledger by its ID
- listAccounts - List accounts from a ledger
- listLogs - List the logs from a ledger
- listTransactions - List transactions from a ledger
- readStats - Get statistics from a ledger
- revertTransaction - Revert a ledger transaction by its ID
runScript- Execute a Numscript⚠️ Deprecated- updateMapping - Update the mapping of a ledger
- addMetadataOnTransaction - Set the metadata of a transaction by its ID
- addMetadataToAccount - Add metadata to an account
- countAccounts - Count the accounts from a ledger
- countTransactions - Count the transactions from a ledger
- createBulk - Bulk request
- createLedger - Create a ledger
- createTransaction - Create a new transaction to a ledger
- deleteAccountMetadata - Delete metadata by key
- deleteLedgerMetadata - Delete ledger metadata by key
- deleteTransactionMetadata - Delete metadata by key
- exportLogs - Export logs
- getAccount - Get account by its address
- getBalancesAggregated - Get the aggregated balances from selected accounts
- getInfo - Show server information
- getLedger - Get a ledger
- getLedgerInfo - Get information about a ledger
- getTransaction - Get transaction from a ledger by its ID
- getVolumesWithBalances - Get list of volumes with balances for (account/asset)
- importLogs
- listAccounts - List accounts from a ledger
- listLedgers - List ledgers
- listLogs - List the logs from a ledger
- listTransactions - List transactions from a ledger
- readStats - Get statistics from a ledger
- revertTransaction - Revert a ledger transaction by its ID
- updateLedgerMetadata - Update ledger metadata
- cancelEvent - Cancel a running workflow
- createTrigger - Create trigger
- createWorkflow - Create workflow
- deleteTrigger - Delete trigger
- deleteWorkflow - Delete a flow by id
- getInstance - Get a workflow instance by id
- getInstanceHistory - Get a workflow instance history by id
- getInstanceStageHistory - Get a workflow instance stage history
- getWorkflow - Get a flow by id
- listInstances - List instances of a workflow
- listTriggers - List triggers
- listTriggersOccurrences - List triggers occurrences
- listWorkflows - List registered workflows
- orchestrationgetServerInfo - Get server info
- readTrigger - Read trigger
- runWorkflow - Run workflow
- sendEvent - Send an event to a running workflow
- cancelEvent - Cancel a running workflow
- createTrigger - Create trigger
- createWorkflow - Create workflow
- deleteTrigger - Delete trigger
- deleteWorkflow - Delete a flow by id
- getInstance - Get a workflow instance by id
- getInstanceHistory - Get a workflow instance history by id
- getInstanceStageHistory - Get a workflow instance stage history
- getServerInfo - Get server info
- getWorkflow - Get a flow by id
- listInstances - List instances of a workflow
- listTriggers - List triggers
- listTriggersOccurrences - List triggers occurrences
- listWorkflows - List registered workflows
- readTrigger - Read trigger
- runWorkflow - Run workflow
- sendEvent - Send an event to a running workflow
- testTrigger - Test trigger
- addAccountToPool - Add an account to a pool
- connectorsTransfer - Transfer funds between Connector accounts
- createAccount - Create an account
- createBankAccount - Create a BankAccount in Payments and on the PSP
- createPayment - Create a payment
- createPool - Create a Pool
- createTransferInitiation - Create a TransferInitiation
- deletePool - Delete a Pool
- deleteTransferInitiation - Delete a transfer initiation
- forwardBankAccount - Forward a bank account to a connector
- getAccountBalances - Get account balances
- getBankAccount - Get a bank account created by user on Formance
getConnectorTask- Read a specific task of the connector⚠️ Deprecated- getConnectorTaskV1 - Read a specific task of the connector
- getPayment - Get a payment
- getPool - Get a Pool
- getPoolBalances - Get pool balances
- getTransferInitiation - Get a transfer initiation
- installConnector - Install a connector
- listAllConnectors - List all installed connectors
- listBankAccounts - List bank accounts created by user on Formance
- listConfigsAvailableConnectors - List the configs of each available connector
listConnectorTasks- List tasks from a connector⚠️ Deprecated- listConnectorTasksV1 - List tasks from a connector
- listPayments - List payments
- listPools - List Pools
- listTransferInitiations - List Transfer Initiations
- paymentsgetAccount - Get an account
- paymentsgetServerInfo - Get server info
- paymentslistAccounts - List accounts
readConnectorConfig- Read the config of a connector⚠️ Deprecated- readConnectorConfigV1 - Read the config of a connector
- removeAccountFromPool - Remove an account from a pool
resetConnector- Reset a connector⚠️ Deprecated- resetConnectorV1 - Reset a connector
- retryTransferInitiation - Retry a failed transfer initiation
- reverseTransferInitiation - Reverse a transfer initiation
- udpateTransferInitiationStatus - Update the status of a transfer initiation
uninstallConnector- Uninstall a connector⚠️ Deprecated- uninstallConnectorV1 - Uninstall a connector
- updateBankAccountMetadata - Update metadata of a bank account
- updateConnectorConfigV1 - Update the config of a connector
- updateMetadata - Update metadata
- createPolicy - Create a policy
- deletePolicy - Delete a policy
- getPolicy - Get a policy
- getReconciliation - Get a reconciliation
- listPolicies - List policies
- listReconciliations - List reconciliations
- reconcile - Reconcile using a policy
- reconciliationgetServerInfo - Get server info
- getVersions - Show stack version information
search- search.v1⚠️ DeprecatedsearchgetServerInfo- Get server info⚠️ Deprecated
- confirmHold - Confirm a hold
- createBalance - Create a balance
- createWallet - Create a new wallet
- creditWallet - Credit a wallet
- debitWallet - Debit a wallet
- getBalance - Get detailed balance
- getHold - Get a hold
- getHolds - Get all holds for a wallet
- getTransactions
- getWallet - Get a wallet
- getWalletSummary - Get wallet summary
- listBalances - List balances of a wallet
- listWallets - List all wallets
- updateWallet - Update a wallet
- voidHold - Cancel a hold
- walletsgetServerInfo - Get server info
- activateConfig - Activate one config
- changeConfigSecret - Change the signing secret of a config
- deactivateConfig - Deactivate one config
- deleteConfig - Delete one config
- getManyConfigs - Get many configs
- insertConfig - Insert a new config
- testConfig - Test one config
You can override the default server globally using the .serverIndex(int serverIdx)
builder method 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 indexes associated with the available servers:
# | Server | Variables | Default values |
---|---|---|---|
0 | http://localhost |
||
1 | https://{organization}.{environment}.formance.cloud |
ServerEnvironment environment String organization |
"sandbox" "orgID-stackID" |
If the selected server has variables, you may override their default values using their associated builder method(s):
environment(ServerEnvironment environment)
organization(String organization)
package hello.world;
import com.formance.formance_sdk.SDK;
import com.formance.formance_sdk.models.operations.GetVersionsResponse;
import com.formance.formance_sdk.models.shared.Security;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Exception {
SDK sdk = SDK.builder()
.serverIndex(1)
.security(Security.builder()
.clientID("<YOUR_CLIENT_ID_HERE>")
.clientSecret("<YOUR_CLIENT_SECRET_HERE>")
.build())
.build();
GetVersionsResponse res = sdk.getVersions()
.call();
if (res.getVersionsResponse().isPresent()) {
// handle response
}
}
}
The default server can also be overridden globally using the .serverURL(String serverUrl)
builder method when initializing the SDK client instance. For example:
package hello.world;
import com.formance.formance_sdk.SDK;
import com.formance.formance_sdk.models.operations.GetVersionsResponse;
import com.formance.formance_sdk.models.shared.Security;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Exception {
SDK sdk = SDK.builder()
.serverURL("http://localhost")
.security(Security.builder()
.clientID("<YOUR_CLIENT_ID_HERE>")
.clientSecret("<YOUR_CLIENT_SECRET_HERE>")
.build())
.build();
GetVersionsResponse res = sdk.getVersions()
.call();
if (res.getVersionsResponse().isPresent()) {
// handle response
}
}
}
Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an exception.
By default, an API error will throw a models/errors/SDKError
exception. When custom error responses are specified for an operation, the SDK may also throw their associated exception. You can refer to respective Errors tables in SDK docs for more details on possible exception types for each operation. For example, the createTransactions
method throws the following exceptions:
Error Type | Status Code | Content Type |
---|---|---|
models/errors/ErrorResponse | default | application/json |
models/errors/SDKError | 4XX, 5XX | */* |
package hello.world;
import com.formance.formance_sdk.SDK;
import com.formance.formance_sdk.models.errors.ErrorResponse;
import com.formance.formance_sdk.models.operations.CreateTransactionsRequest;
import com.formance.formance_sdk.models.operations.CreateTransactionsResponse;
import com.formance.formance_sdk.models.shared.Posting;
import com.formance.formance_sdk.models.shared.Security;
import com.formance.formance_sdk.models.shared.TransactionData;
import com.formance.formance_sdk.models.shared.Transactions;
import java.lang.Exception;
import java.math.BigInteger;
import java.util.List;
public class Application {
public static void main(String[] args) throws ErrorResponse, Exception {
SDK sdk = SDK.builder()
.security(Security.builder()
.clientID("<YOUR_CLIENT_ID_HERE>")
.clientSecret("<YOUR_CLIENT_SECRET_HERE>")
.build())
.build();
CreateTransactionsRequest req = CreateTransactionsRequest.builder()
.transactions(Transactions.builder()
.transactions(List.of(
TransactionData.builder()
.postings(List.of(
Posting.builder()
.amount(new BigInteger("100"))
.asset("COIN")
.destination("users:002")
.source("users:001")
.build()))
.reference("ref:001")
.build()))
.build())
.ledger("ledger001")
.build();
CreateTransactionsResponse res = sdk.ledger().v1().createTransactions()
.request(req)
.call();
if (res.transactionsResponse().isPresent()) {
// handle response
}
}
}
This SDK supports the following security scheme globally:
Name | Type | Scheme |
---|---|---|
clientID clientSecret |
oauth2 | OAuth2 Client Credentials Flow |
You can set the security parameters through the security
builder method when initializing the SDK client instance. For example:
package hello.world;
import com.formance.formance_sdk.SDK;
import com.formance.formance_sdk.models.operations.GetVersionsResponse;
import com.formance.formance_sdk.models.shared.Security;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Exception {
SDK sdk = SDK.builder()
.security(Security.builder()
.clientID("<YOUR_CLIENT_ID_HERE>")
.clientSecret("<YOUR_CLIENT_SECRET_HERE>")
.build())
.build();
GetVersionsResponse res = sdk.getVersions()
.call();
if (res.getVersionsResponse().isPresent()) {
// handle response
}
}
}
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.
While we value open-source contributions to this SDK, this library is generated programmatically. Feel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release!