Adding Webhooks

This article shows how to integrate webhooks in your Teachable school on the Basic plan and up.

What are Webhooks?[back to top]

Webhooks are an easy way to send information from one app to another. They can be configured in a way that will invoke behavior on another website.

You can create your own webhook to integrate into your Teachable school. There are nine kinds of events that can be added with webhooks:

  1. New users join your school
  2. Users update their contact information
  3. New sales
  4. Transactions for one-time/recurring payments
  5. Student cancels a subscription
  6. Enrollment is created
  7. Lecture completions
  8. Lecture Progress Created (user completes a lecture)
  9. Response Created (user completes a graded quiz)

NOTE: using Webhooks is a more advanced feature of Teachable.

Adding a Webhook on Your Teachable School[back to top]

  1. Log into your Teachable school.
  2. Select Settings from the admin sidebar.
  3. Click Webhooks.

    admin-settings-webhooks

  4. Select New Webhook.

  5. Enter a valid Webhook URL from a third-party application and select an Event Type from the list. Set the Send as JSON Array toggle to On if your integration needs that data format. Learn more about how to set up third-party Teachable integrations here.

    NOTE: Make sure you include the correct web protocol (https or http) in your Webhook URL.

  6. Click the orange Create Webhook button at the bottom.

Your webhook is now set up! When the event type you chose occurs, it will fire off a webhook event and the status of your webhook will change from “pending" to “verified." 

Editing and Deleting Webhooks

To edit a webhook, click the teal pencil icon on the main webhooks page. There, you can change the URL, event type, and JSON array toggle, and view the webhook's trigger history. In the trigger history you will see whether the webhook was executed successfully or unsuccessfully each time it was triggered.

If a webhook fails four times, it will be automatically disabled. If this happens, you can manually enable it from the edit page. This is what a failed webhook's edit page will look like:

To delete a webhook, click the red trash icon on the main webhooks page. 

Data Returned From Webhooks[back to top]

You’ll receive the following data, divided by type of event:

Lecture Completions

[
{
 "type": "lectureprogress.created",
 "object": "event",
 "id": 1,
 "livemode": false,
 "created": 628232405,
 "data": {
   "object": {
     "id": 1,
     "is_completed": true,
     "course_id": 1,
     "lecture_id": 1,
     "school_id": 1,
     "course": {
       "id": 1
     },
     "lecture": {
       "id": 1
     },
     "user": {
       "id": 1,
       "role": "student",
       "email": "student@example.com"
     },
     "object": "lectureprogress",
     "created": 628232405,
     "livemode": false
   }
 }
}
]

New Sales

[

{
 "created": 1326853478,
 "livemode": false,
 "id": 345,
 "type": "sale.created",
 "object": "event",
 "data": {
   "object": {
     "object": "sale",
     "school_id": 1,
     "created": 1405501752,
     "id": 495,
     "price": 400,
     "currency": "USD",
     "product_id": 47,
     "course_id": 47,
     "is_active": true,
     "livemode": false,
     "is_recurring": false,
     "user_id": 1,
     "product": {
       "id": 47,
       "name": "foo"
     },
     "course": {
       "id": 47,
       "name": "foo"
     },
     "user": {
       "id": 1,
       "email": "foo@example.com"
     }
   }
 }
}

]
]

New Users Join Your School

[

{
 "type": "user.created",
 "object": "event",
 "id": 1,
 "livemode": false,
 "created": 628232400,
 "data": {
   "object": {
     "id": 1,
     "role": "student",
     "email": "student@example.com",
     "name": "John Doe",
     "school_id": 1,
     "object": "user",
     "created": 628232400,
     "livemode": false,

}
 }
}

]
]

Transactions for One-time/Recurring Sales

[

{
 "type": "transaction.created",
 "object": "event",
 "id": 1,
 "livemode": false,
 "created": 628232401,
 "data": {
   "object": {

"id": 12345,

"price": 4900,

"currency": "USD",

"is_active": true,

"is_recurring": false,

"user_id": 1,

"school_id": 12345,

"course": {

"id": 12345,

"name": "AngularJS: Fundamentals",

"url": "http://school.codecraftpro.com/courses/angularjs-1x-fundamentals"

},

"product": {

"id": 29514,

"is_recurring": false,

"price": 4900,

"name": "Paid Course",

"currency": "USD"

},

"user": {

"id": 667725,

"role": "guest",

"email": "jmonteroc@gmail.com",

"name": "John Montero",

"school_id": 12345,

"src": null,

"first_touch": null,

"last_touch": null,

"last_sign_in_at": "2015-09-16T15:58:01Z",

"sign_in_count": 2

},

"coupon": {

"calculate_discount_amount": 4900,

"calculate_final_price": 0,

"calculate_percent_off": 100,

"usable?": true,

"id": 10424991,

"school_id": 17424,

"discount_percent": 1.0,

"discount_amount": null,

"number_available": 9868,

"code": "SOCIAL100",

"name": null,

"expiration_date": "2017-09-15",

"product_id": 12345,

"is_published": true,

"duration_kind": "once",

"currency": "USD",

"discount_in_months": null,

"number_of_uses": 132,

"is_single_use": false,

"class_period_id": null,

"meta": {

"class": "coupon",

"url": null,

"name": null,

"description": null,

"image_url": null

},

"product": {

"currency_symbol": "$",

"formatted_price": "$49",

"accepts_paypal?": true,

"effective_author_revenue_share": 0.0,

"id": 29514,

"name": "Paid Course",

"description": null,

"billing_interval": "f",

"created_at": "2015-09-14T22:08:41Z",

"detailed_description": null,

"currency": "USD",

"position": 4,

"price": 4900,

"cc_statement_description": "cc description",

"is_recurring": false,

"is_published": true,

"course_id": 28017,

"author_revenue_share": null,

"meta": {

"class": "product",

"url": "/courses/28017/products/29514",

"name": "Paid Course",

"description": null,

"image_url": null

}

}

},

"affiliate": {

"id": 667725,

"role": "guest",

"email": "jmonteroc@gmail.com",

"name": "John Montero",

"school_id": 12345,

"src": null,

"first_touch": null,

"last_touch": null,

"last_sign_in_at": "2015-09-16T15:58:01Z",

"sign_in_count": 2

}

}
 }
}

]
]

Users Update Their Profiles

[

{
 "type": "user.updated",
 "object": "event",
 "id": 1,
 "livemode": false,
 "created": 628232401,
 "data": {
   "object": {
     "id": 1,
     "role": "student",
     "email": "student@example.com",
     "name": "John Doe",
     "school_id": 1,
     "changes": {
       "email": [
         "before_change@example.com",
         "after_change@example.com"
       ]
     },
     "object": "user",
     "created": 628232401,
     "livemode": false
   }
 }
}

]
]

Student Cancels A Subscription

[

{
       "type" => "Sale.subscription_canceled",
         "id" => 4242424242,
   "livemode" => "true",
    "created" => "2016-03-24T11:26:30-04:00",
     "object" => {
                 "id" => 1289757,
              "price" => 1000,
           "currency" => "USD",
          "is_active" => false,
       "is_recurring" => true,
            "user_id" => 4567,
          "school_id" => 1234,
        "final_price" => 1000,
             "course" => {
             "id" => 686868,
           "name" => "How To Groove: A Songwriter's Guide To Drum-Writing",
            "url" => "http://holistic-songwriting.teachable.com/courses/how-to-groove"
       },
            "product" => {
                     "id" => 73593,
           "is_recurring" => true,
                  "price" => 1000,
                   "name" => "Monthly Payment (12 months)",
               "currency" => "USD"
       },
               "user" => {
                        "id" => 4567,
                      "role" => "guest",
                     "email" => "test@testing.com",
                      "name" => "Barry",
                 "school_id" => 1234,
                       "src" => nil,
               "first_touch" => nil,
                "last_touch" => nil,
           "last_sign_in_at" => "2016-03-08T19:31:05Z",
             "sign_in_count" => 6
       },
             "coupon" => nil,
          "affiliate" => nil,
       "transactions" => [
           [0] {
                   "custom_gateway?" => nil,
                   "fully_refunded?" => false,
                                "id" => 166020,
                           "user_id" => 4567,
                         "school_id" => 1234,
                        "created_at" => "2016-02-08T18:39:32Z",
                        "updated_at" => "2016-03-08T18:40:32Z",
                       "final_price" => 1000,
                          "currency" => "USD",
                 "affiliate_percent" => nil,
                    "author_percent" => 0.0,
                         "author_id" => nil,
                    "fedora_percent" => 0.1,
               "total_processor_fee" => 59,
                   "amount_refunded" => 0,
                            "status" => "paid",
                    "affiliate_fees" => 0,
                       "author_fees" => 0,
                         "coupon_id" => nil,
                        "net_charge" => 1000,
                      "earnings_usd" => 747,
                    "net_charge_usd" => 1000,
                        "fedora_fee" => 1,
                  "total_fedora_fee" => 194,
                   "net_revenue_usd" => 747,
                      "purchased_at" => "2016-02-08T18:39:32Z",
                        "refundable" => true,
                          "vat_fees" => 0,
                     "is_chargeback" => nil,
                              "meta" => {
                         "class" => "transaction",
                           "url" => nil,
                          "name" => nil,
                   "description" => nil,
                     "image_url" => nil
         }

     }

  }

]
]

Enrollment Created

[

  {

     "type":"Enrollment.created",

     "id":1,

     "livemode":"true",

     "created":"2016-08-08T10:38:24-04:00",

     "hook_event_id":31,

     "object":{

        "created_at":null,

        "coupon":null,

        "user_id":1,

        "course_id":2,

        "primary_course_id":2,

        "sale_id":1,

        "is_active":true,

        "enrolled_at":"2016-08-08T14:38:24Z",

        "percent_complete":0.0,

        "has_full_access":false,

        "id":1,

        "meta":{

           "class":"enrollment",

           "url":null,

           "name":"1",

           "description":null,

           "image_url":null

        },

        "course":{

           "created_at":"2016-08-05T20:38:32Z",

           "path":"/courses/good-course",

           "safe_image_url":"//d6xfpzo6h49n1.cloudfront.net/O3FPQEI9tlnWDtlA0vVKvDA8gLM=/fit-in/705x0/https://d3gvvapon6fqzo.cloudfront.net/icons/default-course-image.png",

           "default_product_formatted_price":"$10",

           "has_published_lecture":false,

           "has_published_product":true,

           "promo_video":null,

           "name":"Good course",

           "heading":null,

           "page_title":"Good course",

           "meta_description":null,

           "friendly_url":"good-course",

           "description":null,

           "author_bio_id":1,

           "position":0,

           "conversion_pixels":null,

           "closing_letter":null,

           "image_url":null,

           "hero_image_url":"https://d3gvvapon6fqzo.cloudfront.net/bg/default-hero.png",

           "is_published":false,

           "bundled_courses_count":0,

           "child_course_ids":[

           ],

           "preenrollment_call_to_action":"Sign up to get this course when it launches",

           "is_open":true,

           "is_accepting_preenrollments":false,

           "use_old_course_page":null,

           "purchase_redirect_url":null,

           "skip_thank_you_page":null,

           "onboarded_at":null,

           "id":2,

           "meta":{

              "class":"course",

              "url":"/courses/2/",

              "name":"Good course",

              "description":null,

              "image_url":null

           },

           "categories":[

           ],

           "author_bio":{

              "created_at":"2016-08-03T04:03:58Z",

              "headline":"Da Boss",

              "profile_image_url":null,

              "bio":"Bacon ipsum dolor amet shankle ham pork belly jowl.",

              "position":null,

              "user_id":2,

              "name":"Noah",

              "id":1,

              "meta":{

                 "class":"authorbio",

                 "url":"/author_bios/1",

                 "name":"Noah",

                 "description":null,

                 "image_url":null

              }

           }

        },

        "user":{

           "created_at":"2016-08-03T04:03:58Z",

           "Role":"owner",

"gravatar_url":"https://s.gravatar.com/avatar/4cb1f144288e5d61695b0d3f9c63835c?d=mm\u0026s=70",

"email":"owner@example.com",

           "notes":null,

           "affiliate_code":"1_12orpy2s",

           "name":"John Doe",

           "is_owner":true,

           "sign_in_count":7,

           "is_student":true,

           "is_affiliate":false,

           "is_author":false,

           "src":null,

           "current_sign_in_at":"2016-08-05T20:17:15Z",

           "last_four":null,

           "paypal_email":"owner@example.com",

           "affiliate_revenue_share":null,

           "joined_at":"2016-08-03T14:13:37Z",

           "transactions_gross":0,

           "signed_up_affiliate_code":null,

           "author_revenue_share":0.0,

           "last_sign_in_ip":"::1",

           "current_sign_in_ip":"::1",

           "id":1,

           "school_id":1,

           "meta":{

              "class":"user",

              "url":null,

              "name":"John Doe",

              "description":"owner@example.com",

"image_url":"https://s.gravatar.com/avatar/4cb1f144288e5d61695b0d3f9c63835c?d=mm\u0026s=100"

   },

           "author_bio_id":null,

           "total_sales":0,

           "author_bio":null

        }

     }

  }

]
]

Lecture Progress Created (user completes a lecture)

[
  {
     "type":"LectureProgress.created",
     "id":45454545454,
     "livemode":true,
     "created":"2016-08-31T16:54:47+00:00",
     "hook_event_id":1,
     "object":{
        "id":54545454545,
        "is_completed":true,
        "course_id":444444,
        "lecture_id":32322,
        "school_id":859,
        "percent_complete":21.0,
        "course":{
           "id":232323232,
           "name":"The Profitable Teacher",
           "url":"http://academy.teachable.com/courses/the-profitable-teacher"
        },
        "user":{
           "id":111111,
           "role":"student",
           "email":"test@gmail.com",
           "name":"Test Wilson",
           "school_id":859,
           "src":null,
           "first_touch":null,
           "last_touch":null,
           "last_sign_in_at":"2016-08-28T18:07:23Z",
           "sign_in_count":10
        },
        "lecture":{
           "id":43444344444,
           "name":"Lead Magnet #1: The \"Checklist\"",
           "is_published":true
        }
     }
  }
]
]

Response Created (User Completes a graded quiz)

[
  {
     "type":"Response.created",
     "id":3333333,
     "livemode":true,
     "created":"2016-08-31T16:56:00+00:00",
     "hook_event_id":1,
     "object":{
        "id":323232,
        "user_id":33333,
        "custom_form_id":122,
        "answers":{
           "answer-1":[
              "Make a quiz"
           ],
           "answer-2":[
              "Ankur"
           ]
        },
        "created_at":"2016-08-28T08:14:03Z",
        "updated_at":"2016-08-28T08:14:22Z",
        "school_id":859,
        "submitted_at":"2016-08-28T08:14:22Z",
        "grade":{
           "total":2,
           "correct":1,
           "answered":2,
           "remaining":0,
           "percent_correct":0.5,
           "percent_answered":1.0
        },
        "custom_form":{
           "id":122,
           "type":"Quiz",
           "topic_id":3333334,
           "topic_type":"Attachment",
           "data":{
              "graded":true,
              "answerKey":{
                 "answer-1":[
                    "Make a quiz"
                 ],
                 "answer-2":[
                    "Conrad",
                    "Ankur"
                 ]
              }
           },
           "school_id":859,
           "is_published":false,
           "identifier":null,
           "created_at":"2015-06-08T17:05:26Z",
           "updated_at":"2015-06-08T17:50:23Z",
           "schema":{
              "type":"object",
              "required":[
                 "answer-1",
                 "answer-2"
              ],
              "properties":{
                 "answer-1":{
                    "enum":[
                       "Make a quiz",
                       "Start a blog",
                       "Create an email campaign"
                    ],
                    "type":"string",
                    "title":"What is one of the easiest ways to engage your audience?"
                 },
                 "answer-2":{
                    "enum":[
                       "Conrad",
                       "Ankur",
                       "Oprah Winfrey"
                    ],
                    "type":"string",
                    "title":"Who are the founders of Fedora?"
                 }
              }
           },
           "attachment":{
              "id":22222222,
              "attachable_type":"Lecture",
              "attachable_id":22222222,
              "kind":"quiz"
           }
        },
        "user":{
           "id":22222222,
           "role":"student",
           "email":"thedrumboostermail@gmail.com",
           "name":"Ruggero",
           "school_id":859,
           "src":null,
           "first_touch":null,
           "last_touch":null,
           "last_sign_in_at":"2016-08-30T07:51:52Z",
           "sign_in_count":46
        }
     }
  }
]
]
thanks_illustration

Can't find what you're looking for?

Contact us
thanks_illustration