πAPI Key
Learn how to access your Swapped Commerce API Key, which is required when creating payments and interacting with the Swapped Commerce API.

Get your API Key
To retrieve your API Key, visit the Developers section of the Swapped Commerce dashboard. There, you can generate and view your API Key, which is required for specific Swapped Commerce endpoints.
Using your API Key
When using your API Key to make requests to the Swapped Commerce API directly, you'll need to sign your API Key in a specific way. Set this as the X-API-Key Header, as seen below:
const axios = require('axios');
// Config
const API_KEY = 'YOUR_API_KEY';
const BASE_URL = 'https://pay-api.swapped.com';
const ENDPOINT = '/v1/orders';
// Payload
const payload = {
purchase: {
name: 'text',
description: 'text',
imageUrl: 'text',
price: 'text',
currency: 'USD'
},
metadata: {
externalId: 'text',
userId: 'text',
userCountry: 'text',
userEmail: 'text',
redirectUrl: 'text'
}
};
// Headers
const headers = {
'X-API-Key': API_KEY,
'Content-Type': 'application/json',
'Accept': '*/*'
};
// Request
axios.post(`${BASE_URL}${ENDPOINT}`, payload, { headers })
.then(response => {
console.log('β
Success:', response.status);
console.log(response.data);
})
.catch(error => {
console.error(error);
});
If you lose your API Key or believe it has been compromised, you should delete the API credentials and request a new one immediately.
If you believe your merchant account has been compromised, please contact us immediately.
Last updated