Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Zapier Code > xAPI Template

Zapier Code > xAPI Template

Send xAPI statements using Zapier Code Action

Zapier Code Documentation

=== Copyright 2016 TorranceLearning

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

// This example uses input from Rocketbook > Google Drive Trigger (
// but can be altered for most Zapier triggers.
var stmt = {
actor: {
mbox: inputData.mbox
verb: {
id: '',
display: {
'en-US': 'uploaded'
object: {
id: '',
definition: {
name: { 'en-US': inputData.title },
description: { 'en-US': inputData.desc }
{ "usageType": "",
context: {
extensions: {
'': inputData.url,
'': inputData.alt_url
timestamp: (new Date()).toISOString()
var endpoint = '[YOUR XAPI ENDPOINT HERE]';
var basicAuth = 'Basic [YOUR BASIC AUTH HERE]';
fetch(endpoint, {
method: 'POST',
headers: {
'X-Experience-API-Version': '1.0.0',
'Content-Type': 'application/json',
'Authorization': basicAuth
body: JSON.stringify(stmt)
.then(function(res) {
return res.json();
}).then(function(json) {
json = json || {};
callback(null, { success: true });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.