Developer

Zapeir API docs

Base URL

The base URL we are using for the current version of our Zapier endpoints is https://api.offlight.work this will be referred to as {{BASE_URL}}.

Authentication

This is the endpoint that return if the api_key is valid or not.

It lives at GET {{BASE_URL}}/auth/check.

Request:

<script>
const res = await axios.get(`{{BASE_URL}/auth/check`, {
  headers: {
    'X-API-KEY': api_key,
  },
});

const isValid = res.data.isValid;
if (isValid) {
  return res.data;
} else {
  throw "invalid api key";
}
</script>

api_key is the api_key given by Offlight.

Response:

A successful call will authorize the user:

<script>
return { isValid, userName, email };
</script>

userName and email are returned to make a connection label in Zapier.

Subscribe

This is the endpoint Zapier calls to subscribe to a webhook.

It lives at POST {{BASE_URL}}/zapier/webhook.

Request:

<script>
const res = await axios.post(`{{BASE_URL}/zapier/webhook`,
  {
    hookUrl: hook_url,
    purpose: "doneTask",
  },
  {
    headers: {
      'X-API-KEY': api_key,
    },
  }
);

const success = res.data.success;
return success;
</script>

api_key is the api_key given by Offlight.

hook_url is the hook URL given by Zapier.

Response:

A successful call will subscribe the user:

<script>
// if creating subscription success
return true;
// if creating subscription failed
return false;
</script>

Unsubscribe

This is the endpoint Zapier calls to unsubscribe to a webhook.

It lives at DELETE {{BASE_URL}}/zapier/webhook.

Request:

<script>
const res = await axios.delete(`{{BASE_URL}/zapier/webhook`,
  {
    hookUrl: hook_url,
    purpose: "doneTask",
  },
  {
    headers: {
      'X-API-KEY': api_key,
    },
  }
);

const success = res.data.success;
return success;
</script>

api_key is the api_key given by Offlight.

hook_url is the hook URL given by Zapier.

Response:

A successful call will unsubscribe the user:

<script>
// if deleting subscription success
return true;
// if deleting subscription failed
return false;
</script>

Get Done Tasks

This is the endpoint Zapier calls to get the example data when webhook is called by offlight server.

It lives at GET {{BASE_URL}}/zapier/doneTasks.

Request:

<script>
const res = await axios.get(`{{BASE_URL}/zapier/doneTasks`, {
  headers: {
    'X-API-KEY': api_key,
  },
});

const tasks = res.data;
return tasks;
</script>

api_key is the api_key given by Offlight.

Response:

A successful call will return the most recent done tasks:

<script>
const task = {
  createdAt: Date,
  updatedAt: Date,
  plannedDate: Date,
  doneAt: Date,
  deletedAt: Date,
  id: string,
  name: string,
  note: string,
  status: string,
  deadline: Date,
  goal: string,
	source: string,
  identifier: string,
	sourceName: string,
  link: string,
  creator: string
}

return task[];
</script>

Create A Task

This is the endpoint Zapier calls to when to do action that create a task.

It lives at POST {{BASE_URL}}/zapier/task.

Request:

<script>
const res = await axios.post(`{{BASE_URL}/zapier/task`,
  {
	  task_name: string,
	  task_note: string,
	  task_deadline: Date,
	  identifier: string,
	  source_name: string,
	  source_link: string
  },
  {
    headers: {
      'X-API-KEY': api_key,
    },
  }
);

const id = res.data.id;
return id;
</script>

Response:

A successful call will return the created task’s id:

<script>
return taskId;
</script>
ON THIS PAGE