Introduction
Get to know the basics of the DFend API.
Authentication
Publishable key
Secret key
In use
Example (Node.js)
import fetch from 'isomorphic-fetch';
const apiUrl = 'https://api.dfend.app';
const headers = {
Accept: 'application/json',
'Content-Type': 'application/json',
'X-Api-Key': process.env.DFEND_SECRET_KEY
};
const post = async (endpoint, data = {}) => {
const res = await fetch(`${apiUrl}/${endpoint}`, {
method: 'POST',
body: JSON.stringify(data),
credentials: 'omit',
headers
});
return res.json();
};
const createIdentity = (data = {}) => {
return post('identity', data);
};
try {
const { id, created, merged } = await createIdentity({
userId: 'PU4ME2B68N8K6xz0Ku0BQ',
name: 'Jane Doe',
email: 'jane@yourdomain.com',
phone: '+15435551234',
merge: true,
metadata: {
test: true
}
});
console.log('[DFend] identity created:', id);
// You can now send signals to DFend with the Identity ID or user ID.
} catch (e) {
console.error(e);
}Last updated