Skip to content

Working with Macrometa GDN and Cloudflare Workers

This brief tutorial will show you have to authenticate to the GDN using it's REST API and Cloudflare workers. It will then create a collection!

Auth and create first collection:

const macrometaHost = ""
const authEndpoint = macrometaHost + "/_open/auth"
const collectionEndpoint = macrometaHost + "/_fabric/_system/_api/collection"
const type = "application/json;charset=UTF-8"
const authInfo = {
  "email": "[email protected]",
  "password": "<[email protected]>",
  "tenant": "",
  "username": "root"

const newCollection = {
  "name": "mySecondCollection"
const getOptions = (requestBody,token) => ({
headers: { authorization:token,
       "content-type": type

async function handleRequest() { 
  const jwtRequest = await fetch(authEndpoint,getOptions(authInfo,""))
  const jwtResponse = await jwtRequest.json();
  const jwtToken=`bearer ${jwtResponse.jwt}`

  const collectionRequest = await fetch(collectionEndpoint,getOptions(newCollection,jwtToken))
  const collectionResponse = await collectionRequest.json()
  return new Response(JSON.stringify(collectionResponse))

addEventListener("fetch", event => {
  return event.respondWith(handleRequest())


Response to collection creation:


Now you have a collection created, you can check it out in the Macrometa console under the collections tab.


If you'd like to learn more about the Macrometa service, head over to Essentials section to get acquainted with the entire platform.