Data for Good FoundationSandbox

Connect to the DfG Professional sandbox

Six steps from an invitation link to a decision you can read back from the Evidence record. Allow 15 minutes. You need Node 22 or later.

Sandbox addresshttps://dfgsandbox5b17fb5f-dfg-core-sandbox.functions.fnc.fr-par.scw.cloud
Token audiencedfg-core-sandbox
Limit120 calls a minute for each team
PeopleTest people only

The technical names in this guide still say "dfg-core": the audience value, the package @dfg/core-sdk and the field core_url. Use them exactly as written.

1. Get your keys

Sign in on the sandbox and press Make a key on the page Your sandbox keys. With an invitation link from the organisers, open the link and press Accept and make my keys, or run this in an empty folder:

curl -fsSO https://developers.dfgfoundation.com/join.mjs
node join.mjs "PASTE-YOUR-INVITATION-LINK"

Every way leaves one file, dfg-sandbox.json. Put it in the folder you work in. It holds:

FieldWhat it is
core_url, audienceThe sandbox address and the audience every token must carry
client_id, private_jwkYour system's name in DfG Professional and its private key
collaboration_id, recipient_org_id, roleYour collaboration, its test clinic and the role that may ask
purpose, workflow, output_kind, categoriesThe values a request in your collaboration uses
collaboration_key_hexThe key derivePseudonym turns your own account IDs into code names with. DfG Professional never sees it

2. Install the SDK

npm init -y
npm install https://developers.dfgfoundation.com/sdk/dfg-core-sdk-0.1.0-draft.1.tgz

The package is @dfg/core-sdk, an ES module with no dependencies, licensed under Apache-2.0. Its README is written for the full developer kit: skip its install section, and the files it names under api/ are not part of this download.

3. Make a first call

curl -fsSO https://developers.dfgfoundation.com/first-call.mjs
node first-call.mjs

The script runs the diabetes follow-up from start to end with one test person and prints a line for each step:

  1. The sandbox answers and names its audience.
  2. The person grants the clinic four kinds of data: tir, mean_g, sleep and steps. Your system reports the consent.
  3. A nurse asks to see the summary before a planned visit. DfG Professional answers permit and gives a ticket.
  4. Your system reports the summary's fingerprint against the ticket. DfG Professional answers released.
  5. You read the request's trail from the Evidence record and check every hash on your own machine. The rows are config.published, consent.granted, request.decided and result.released.
  6. The person withdraws. The nurse asks again. DfG Professional answers deny with the reason CONSENT_WITHDRAWN.

4. Read the script

first-call.mjs is the shortest working use of each call. The client is set up like this:

import { readFileSync } from 'node:fs';
import { DfgCoreClient } from '@dfg/core-sdk';

const s = JSON.parse(readFileSync('dfg-sandbox.json', 'utf8'));
const core = new DfgCoreClient({
  baseUrl: s.core_url,
  clientId: s.client_id,
  privateKey: s.private_jwk,
  audience: s.audience,   // the sandbox has its own; the default is for the live DfG Professional
});
CallWhat it does
core.recordConsentEvent(...)Reports a grant or a withdrawal
core.submitGovernedRequest(...)Asks whether a use of data may go ahead. The answer is permit or deny, with reasons
core.releaseResult(...)Reports the output's SHA-256 against the ticket. DfG Professional never receives the output
core.evidenceTrail(requestId)Reads every Evidence row of one request
core.evidenceVerify()Asks DfG Professional to check its Evidence chain

5. Build your own

Your client is consent source, requester and data holder in your collaboration, so one system can play all three parts. The collaboration lets a clinical_nurse at your test clinic ask for tir, mean_g, bolus, sleep, rhr, steps and exercise for the purpose planned_control.

6. Rules of the sandbox

Stuck? Write to the Data for Good Foundation, or to the organisers who sent your invitation. Give the request_id from the error. It finds the call in the sandbox's log.