This guide shows you how to send transactions programmatically using the Formance SDK. By the end, you'll have a working script that creates a transaction via the API.
Prerequisite: Complete the Platform Quick Start first. You need a running sandbox.
Generate API Credentials
Create OAuth client credentials to authenticate your application.
First, get your stack ID:
Look for the ID field in the output:
Create the client using your stack ID:
You'll see output like:
Copy the ID — this is your Client ID.
Now create a secret for this client:
Replace <CLIENT_ID> with the ID from above. You'll see:
Copy the Clear value immediately — this is your Client Secret and it's only shown once!
Finally, get your API endpoint:
Look for the URL pattern: https://xxxxxxxxxx-xxxx.sandbox.formance.cloud
You now have everything you need:
Client ID— from the first commandClient Secret— the "Clear" value from the second commandAPI URL— fromfctl stack show
Install the SDK & Send a Transaction
Create a new project:
Open package.json and add "type": "module" after the "name" line:
Create index.ts:
Run it:
Getting an authentication error? Check these common issues:
- Make sure your
serverURLhas no trailing slash - Verify you created the client with the correct
--stackflag - Confirm your sandbox is still active with
fctl stack show --name=playground
Expected output:
Verify Your Transaction#
Check that the transaction was recorded using the CLI:
You should see both your CLI transaction from the Quick Start and your new SDK transaction.
Security Note: The client_credentials grant shown here is for server-to-server communication. Never expose these credentials in client-side code. For web/mobile apps, use the authorization code flow.